Realm C++ SDK版本 v 2.2.0

dictionary.hpp

1
2//
3// 版权所有 2024 Realm Inc.
4//
5// 根据 Apache 许可证 2.0 版(“许可证”)获得许可;
6// 除非符合合规,否则不得使用此文件。
7// 您可以在以下网址获取许可证副本:
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// 除非适用法律要求或书面同意,否则软件
12// 根据许可证分发是按“原样”分发的,
13// 不提供任何类型的Express或暗示的保证或条件。
14// 请参阅管理权限的特定语言的许可证和
15// 许可证下的限制。
16//
18
19#ifndef CPPREALM_BRIDGE_DICTIONARY_HPP
20#define CPPREALM_BRIDGE_DICTIONARY_HPP
21
22#include<functional>
23#include<memory>
24#include <string>
25#include<vector>
26#include <cpprealm/internal/bridge/utils.hpp>
27
28命名空间realm::object_store {
29 classDictionary ;
30 }
31
32命名空间域 {
33 classDictionary ;
34 using CoreDictionary =Dictionary;
36 字典变更集(常量字典变更集&);
38 dictionary_change_set &操作符=( constdictionary_change_set & );
39 Dictionary_change_set & Operator=( Dictionary_change_set &&) = default ;
40
41 // 从 _old_ 字典中删除的键
42 std::vector<std::string> Deletes;
43
44 // _new_ 字典中新插入的键
45 std::vector<std::string> inserts;
46
47 // 已修改对象/值的键
48 std::vector<std::string> 修改;
49
50 bool collection_root_was_deleted = false ;
51 };
52
55
56
57 dictionary_collection_change (std::vector<std::string>&& i,
58 std::vector<std::string>&& m,
59 std::vector<std::string>&& d,
60 bool c)
61 : inserts(std::move(i)),
62修改(std::move(m)),
63 Deletes(std::move(d)),
64 collection_root_was_deleted(c) {}
65
66 std::vector<std::string> inserts;
67 std::vector<std::string> 修改;
68 std::vector<std::string> Deletes;
69 // 此标志指示作为此值来源的底层对象是否
70 // 集合已删除。 这适用于列表、字典和集合。
71 // 这使通知程序能够报告已删除的空集合的更改。
72 bool collection_root_was_deleted = false ;
73
74 [[nodiscard]] bool empty() const noException {
75 return deletements.empty() && inserts.empty() && Modifications.empty() &&
76 !collection_root_was_deleted;
77 }
78 };
79
81 std::function<void( dictionary_collection_change )> handler;
82 boolignore_changes_in_initial_notification ;
83
84 dictionary_callback_wrapper (std::function< void ( dictionary_collection_change )> 处理程序,
85 boolignore_changes_in_initial_notification )
86 : handler(handler)
87 ,ignore_changes_in_initial_notification(ignore_changes_in_initial_notification)
88 {}
89 };
90 }
91
92命名空间realm::internal::bridge {
93 usingDictionary = object_store::Dictionary;
94 using CoreDictionary = CoreDictionary;
95
96 结构体混合;
97 struct binary;
98 struct timestamp;
99 struct obj_key;
100 struct uuid;
101 struct object_id;
102 struct notification_token;
103 struct collection_change_callback;
104 struct obj;
105
108 core_dictionary ( const core_dictionary &other);
109 core_dictionary &operator=( const core_dictionary &other);
111 core_dictionary &operator=( core_dictionary && other);
113
114 core_dictionary ( const CoreDictionary& v); //NOLINT(google-explicit-constructor)
115 操作符 CoreDictionary () const ; //NOLINT(google-explicit-constructor)
116 void insert( const std::string& key, const Mixed & value);
117 void insert( const std::string& key, const std::string& value);
118 obj create_and_insert_linked_object( const std::string& key);
119 obj create_and_insert_linked_object( const std::string& key, constinternal ::bridge::mixed & pk);
120 混合get( const std::string& key) const ;
121 void delete( const std::string& key);
122 obj get_object( const std::string& key);
123 std::pair get_pair( size_t ndx) const ;
124 size_t find_any_key( const std::string& value) const noException ;
125
126 size_t size() const ;
127 private :
128 const CoreDictionary* get_dictionary() const ;
129 CoreDictionary* get_dictionary();
130#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
131 存储::CoreDictionary m_dictionary[ 1 ];
132#else
133 std::shared_ptr<CoreDictionary> m_dictionary;
134#endif
135 };
136
137
138 struct dictionary {
139 dictionary();
140 字典( const字典&其他);
141 字典&操作符=( const字典&其他);
142 字典(字典&&其他);
143 字典&操作符=(字典&&其他);
144 ~dictionary ();
145 字典( constDictionary &v); //NOLINT(google-explicit-constructor)
146 操作符Dictionary() const ; //NOLINT(google-explicit-constructor)
147 void insert( const std::string& key, const Mixed & value);
148 void insert( const std::string &key, const std::string &value);
149 [[nodiscard]] size_t size() const ;
150 void remove_all();
151 void remove( const std::string&);
152 std::pair<std::string, Mixed> get_pair( size_t );
153 [[nodiscard]] size_t get_key_index( const std::string&);
154 void clear();
155 [[nodiscard]] size_t find( const std::string&);
156 obj insert_embedded( const std::string&);
157 notification_token add_notification_callback(std::shared_ptr<collection_change_callback>&& cb);
158 notification_token add_key_based_notification_callback(std::shared_ptr<dictionary_callback_wrapper>&& cb);
159 private :
160 constDictionary* get_dictionary() const ;
161 Dictionary* get_dictionary();
162 朋友 inlineDictionary * get_dictionary( dictionary & lst);
163 朋友 内联 constDictionary * get_dictionary ( constDictionary &lst);
164 template < typename T>
165 好友T get(字典&, const std::string&);
166#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
167 存储::Dictionary m_dictionary[ 1 ];
168#else
169 std::shared_ptr<Dictionary> m_dictionary;
170#endif
171 };
172
173 template < typename T>
174 [[nodiscard]] T get( dictionary &, const std::string&);
175 template <>
176 [[nodiscard]] std::string get( dictionary &, const std::string&);
177 template <>
178 [[nodiscard]] uuid get( dictionary &, const std::string&);
179 template <>
180 [[nodiscard]] object_id get( dictionary &, const std::string&);
181 template <>
182 [[nodiscard]] timestamp get( dictionary &, const std::string&);
183 template <>
184 [[nodiscard]] binary get( dictionary &, const std::string&);
185 template <>
186 [[nodiscard]] obj get( dictionary &, const std::string&);
187 template <>
188 [[nodiscard]] obj_key get( dictionary &, const std::string&);
189 template <>
190 [[nodiscard]] int 64 _t get( dictionary &, const std::string&);
191 template <>
192 [[nodiscard]] double get( dictionary &, const std::string&);
193 }
194
195#endif //CPREALM_BRIDGE_DICTIONARY_HPP
定义: dictionary.hpp: 80
定义: dictionary.hpp: 35
定义: dictionary.hpp: 53
定义: binary.hpp: 30
定义: dictionary.hpp: 106
定义: dictionary.hpp: 138
定义: mixed.hpp:69
定义: obj_key.hpp: 33
定义: obj.hpp:123
定义: object_id.hpp:31
定义: timestamp.hpp: 30
定义: uuid.hpp:32