Realm C++ SDK Version v2.2.0

set.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_SET_HPP
20#define CPPREALM_BRIDGE_SET_HPP
21
22#include <cstdlib>
23#include <memory>
24#include <set>
25#include <string>
26#include <cpprealm/internal/bridge/utils.hpp>
27
28namespace realm {
29 namespace object_store {
30 class Set;
31 }
32}
33
34namespace realm::internal::bridge {
35 struct realm;
36 struct obj;
37 struct obj_key;
38 struct mixed;
39 struct binary;
40 struct uuid;
41 struct object_id;
42 struct col_key;
43 struct timestamp;
44 struct table;
45 struct notification_token;
46 struct collection_change_callback;
47
48 struct set {
49 set();
50 set(const set& other) ;
51 set& operator=(const set& other) ;
52 set(set&& other);
53 set& operator=(set&& other);
54 ~set();
55 set(const object_store::Set&); //NOLINT(google-explicit-constructor)
56 operator object_store::Set() const; //NOLINT(google-explicit-constructor)
57 set(const realm& realm, const obj& obj, const col_key&);
58
59 mixed get_any(const size_t& i) const;
60 obj get_obj(const size_t& i) const;
61
62 [[nodiscard]] size_t size() const;
63 void remove_all();
64
65 table get_table() const;
66
67 std::pair<size_t, bool> insert(const std::string&);
68 std::pair<size_t, bool> insert(const int64_t &);
69 std::pair<size_t, bool> insert(const double &);
70 std::pair<size_t, bool> insert(const bool &);
71 std::pair<size_t, bool> insert(const binary &);
72 std::pair<size_t, bool> insert(const uuid &);
73 std::pair<size_t, bool> insert(const object_id &);
74 std::pair<size_t, bool> insert(const mixed &);
75 std::pair<size_t, bool> insert(const obj_key &);
76 std::pair<size_t, bool> insert(const timestamp &);
77
78 void remove(const int64_t &);
79 void remove(const bool &);
80 void remove(const double &);
81 void remove(const std::string &);
82 void remove(const uuid &);
83 void remove(const object_id &);
84 void remove(const mixed &);
85 void remove(const timestamp &);
86 void remove(const binary&);
87 void remove(const obj_key&);
88
89 size_t find(const int64_t &);
90 size_t find(const bool &);
91 size_t find(const double &);
92 size_t find(const std::string &);
93 size_t find(const uuid &);
94 size_t find(const object_id &);
95 size_t find(const mixed &);
96 size_t find(const timestamp &);
97 size_t find(const binary&);
98 size_t find(const obj_key&);
99 notification_token add_notification_callback(std::shared_ptr<collection_change_callback>);
100 private:
101 const object_store::Set* get_set() const;
102 object_store::Set* get_set();
103#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
104 storage::Set m_set[1];
105#else
106 std::shared_ptr<object_store::Set> m_set;
107#endif
108 };
109}
110
111#endif //CPPREALM_BRIDGE_SET_HPP
Definition: binary.hpp:30
Definition: col_key.hpp:28
Definition: mixed.hpp:69
Definition: obj_key.hpp:33
Definition: obj.hpp:123
Definition: object_id.hpp:31
Definition: realm.hpp:67
Definition: set.hpp:48
Definition: table.hpp:40
Definition: timestamp.hpp:30
Definition: uuid.hpp:32