Realm C++ SDK版本 v 2.2.0

object.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_OBJECT_HPP
20#define CPPREALM_BRIDGE_OBJECT_HPP
21
22#include <any>
23#include<functional>
24#include<memory>
25#include <unordered_map>
26
27#include <cpprealm/internal/bridge/utils.hpp>
28
29命名空间域 {
30 class Object;
31 class IndexSet;
32 class CollectionChangeCallback;
33 struct CollectionChangeSet;
34 structNotificationToken
35 }
36命名空间realm::internal::bridge {
37 struct Realm;
38 struct obj;
39 struct obj_link;
40 struct object_schema;
41 struct list;
42 struct col_key;
43 struct字典;
44
47 notification_token ( const notification_token &other) = 删除 ;
48 notification_token &operator=( const notification_token &other) = delete ;
50 notification_token &operator=( notification_token && other);
51 notification_token (NotificationToken&&);
53 操作符NotificationToken() const ;
54 void unregister();
55 private :
56#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
57 storage::NotificationToken m_token[ 1 ];
58#else
59 std::shared_ptr<NotificationToken> m_token;
60#endif
61 };
62
63 struct index_set {
64 index_set(); //NOLINT(google-explicit-constructor)
65 index_set ( const index_set & other) ;
66 index_set & Operator=( const index_set & other);
67 index_set ( index_set && other);
68 index_set & 操作符=( index_set && other);
69 ~index_set();
70 index_set(const IndexSet&); //NOLINT(google-explicit-constructor)
71 [[nodiscard]] bool empty() const ;
73 // 针对设立中各个索引而不是范围的迭代器
75 public :
76 index_iterator () = 默认 ;
77 index_iterator ( const index_iterator & other) ;
78 index_iterator & 操作符=( const index_iterator & other);
80 index_iterator & 操作符=( index_iterator && other);
82 size_t Operator*() const noException ;
83 bool 操作符==( index_iterator const & it) const noException ;
84 bool操作符!=( index_iterator const & it) const noException ;
85
86 index_iterator & Operator++() noException ;
87
88 index_iterator Operator++( int ) noException ;
89
90 private :
91 朋友 struct index_iterable_adaptor ;
92#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
93 存储::IndexSet_IndexIterator m_iterator[ 1 ];
94#else
95 std::shared_ptr<std::any> m_iterator;
96#endif
97 };
98
100 index_iterable_adaptor () = 默认 ;
102 index_iterable_adaptor & 操作符=( const index_iterable_adaptor & other);
104 index_iterable_adaptor & 操作符=( index_iterable_adaptor && other);
107
108 const_iterator begin() const noException ;
109 const_iterator end() const noException ;
110 private :
111 朋友 struct index_set;
112#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
113 存储::IndexSet_IndexIteratableAdaptor m_index_iterable_adaptor[ 1 ];
114#else
115 std::shared_ptr<std::any> m_index_iterable_adaptor;
116#endif
117 };
118 index_iterable_adaptor as_indexes() const ;
119 private :
120#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
121 storage::IndexSet m_idx_set[1];
122#else
123 std::shared_ptr<IndexSet> m_idx_set;
124#endif
125 };
127 collection_change_set (); //NOLINT(google-explicit-constructor)
129 collection_change_set & 操作符=( const collection_change_set & other);
131 collection_change_set & 操作符=( collection_change_set && other);
133 collection_change_set ( const CollectionChangeSet&);
134 操作符 CollectionChangeSet() const ;
135 [[nodiscard]] index_set Deletes () const ;
136 [[nodiscard]] index_set modifications() const;
137 [[nodiscard]] index_set inserts () const ;
138 [[nodiscard]] std::unordered_map<int 64 _t, index_set>columns() const ;
139 [[nodiscard]] bool empty() const ;
140 [[nodiscard]] bool collection_root_was_deleted() const ;
141 private :
142#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
143 storage::CollectionChangeSet m_change_set[ 1 ];
144#else
145 std::shared_ptr<CollectionChangeSet> m_change_set;
146#endif
147 };
149 虚拟 ~collection_change_callback () {}
150 虚拟 void before( collection_change_set const & c) = 0 ;
151 虚拟 void after( collection_change_set const & c) = 0 ;
152 };
153
154 struct 对象{
155 对象 (); //NOLINT(google-explicit-constructor)
156 对象 ( const 对象 & other) ;
157 object & Operator=( const object & other);
158 对象 ( 对象 && other);
159 对象 & 操作符=( 对象 && other);
160 ~ 对象 ();
161 对象 ( const Object&); //NOLINT(google-explicit-constructor)
162 object ( const realm & realm , const obj & obj ); //NOLINT(google-explicit-constructor)
163 object ( const realm & realm , const obj_link & link);
164
165 操作符 Object() const ; //NOLINT(google-explicit-constructor)
166
167 [[nodiscard]] obj get_obj() const;
168
169 [[nodiscard]] get_realm() const ;
170
171 [[nodiscard]] bool is_valid() const ;
172
173 notification_token add_notification_callback(std::shared_ptr<collection_change_callback>&& cb);
174
175 [[nodiscard]] object_schema get_object_schema() const ;
176
177 [[nodiscard]] list get_list( const col_key &) const ;
178 [[nodiscard]]字典get_dictionary( const col_key &) const ;
179 private :
180#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
181 存储::Object m_object[ 1 ];
182#else
183 std::shared_ptr<Object> m_object;
184#endif
185 };
186 }
187
188#endif //CPREALM_BRIDGE_OBJECT_HPP
定义: col_key.hpp: 28
定义: dictionary.hpp: 138
定义: object.hpp: 63
定义: list.hpp: 49
定义: obj.hpp:123
定义: object_schema.hpp: 33
定义: object.hpp: 154
定义: realm.hpp: 67