Realm C++ SDK Version v2.2.0

results.hpp

1
2//
3// Copyright 2024 Realm Inc.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
18
19#ifndef CPPREALM_BRIDGE_RESULTS_HPP
20#define CPPREALM_BRIDGE_RESULTS_HPP
21
22#include <cstddef>
23#include <cpprealm/internal/bridge/obj.hpp>
24#include <cpprealm/internal/bridge/utils.hpp>
25
26namespace realm {
27 class Results;
28}
29namespace realm::internal::bridge {
30 struct realm;
31 struct table;
32 struct query;
33 struct notification_token;
34 struct obj;
35 struct collection_change_set;
36
38 std::string key_path;
39 bool ascending;
40 private:
41 friend struct results;
42 friend struct list;
43 operator std::pair<std::string, bool>() const;
44 };
45
46 struct results {
47 results();
48 results(const results& other) ;
49 results& operator=(const results& other) ;
50 results(results&& other);
51 results& operator=(results&& other);
52 ~results();
53
54 results(const Results&); //NOLINT(google-explicit-constructor)
55 results(const realm&, const table_view&);
56 size_t size();
57 [[nodiscard]] realm get_realm() const;
58 [[nodiscard]] table get_table() const;
59 results(const realm&, const query&);
60 results sort(const std::vector<sort_descriptor>&);
61 notification_token add_notification_callback(std::shared_ptr<collection_change_callback>&&);
62 private:
63 template <typename T>
64 friend T get(results&, size_t);
65#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
66 storage::Results m_results[1];
67#else
68 std::shared_ptr<Results> m_results;
69#endif
70 };
71
72 template <typename T>
73 T get(results&, size_t);
74 template <>
75 obj get(results&, size_t);
76 template <>
77 int64_t get(results&, size_t);
78 template <>
79 bool get(results&, size_t);
80 template <>
81 double get(results&, size_t);
82 template <>
83 std::string get(results&, size_t);
84 template <>
85 ::realm::uuid get(results&, size_t);
86 template <>
87 ::realm::object_id get(results&, size_t);
88 template <>
89 ::realm::decimal128 get(results&, size_t);
90 template <>
91 std::vector<uint8_t> get(results&, size_t);
92 template <>
93 std::chrono::time_point<std::chrono::system_clock> get(results&, size_t);
94 template <>
95 mixed get(results&, size_t);
96}
97
98#endif //CPPREALM_BRIDGE_RESULTS_HPP
Definition: types.hpp:75
Definition: list.hpp:49
Definition: mixed.hpp:69
Definition: obj.hpp:123
Definition: query.hpp:131
Definition: realm.hpp:67
Definition: results.hpp:46
Definition: table.hpp:79
Definition: table.hpp:40
Definition: types.hpp:56
Definition: types.hpp:35