19#ifndef CPPREALM_BRIDGE_DICTIONARY_HPP
20#define CPPREALM_BRIDGE_DICTIONARY_HPP
26#include <cpprealm/internal/bridge/utils.hpp>
28namespace realm::object_store {
34 using CoreDictionary = Dictionary;
42 std::vector<std::string> deletions;
45 std::vector<std::string> insertions;
48 std::vector<std::string> modifications;
50 bool collection_root_was_deleted =
false;
58 std::vector<std::string>&& m,
59 std::vector<std::string>&& d,
61 : insertions(std::move(i)),
62 modifications(std::move(m)),
63 deletions(std::move(d)),
64 collection_root_was_deleted(c) {}
66 std::vector<std::string> insertions;
67 std::vector<std::string> modifications;
68 std::vector<std::string> deletions;
72 bool collection_root_was_deleted =
false;
74 [[nodiscard]]
bool empty()
const noexcept {
75 return deletions.empty() && insertions.empty() && modifications.empty() &&
76 !collection_root_was_deleted;
82 bool ignore_changes_in_initial_notification;
85 bool ignore_changes_in_initial_notification)
87 , ignore_changes_in_initial_notification(ignore_changes_in_initial_notification)
92namespace realm::internal::bridge {
93 using Dictionary = object_store::Dictionary;
94 using CoreDictionary = CoreDictionary;
102 struct notification_token;
103 struct collection_change_callback;
115 operator CoreDictionary ()
const;
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);
120 mixed get(
const std::string& key)
const;
121 void erase(
const std::string& key);
122 obj get_object(
const std::string& key);
123 std::pair<mixed, mixed> get_pair(
size_t ndx)
const;
124 size_t find_any_key(
const std::string& value)
const noexcept;
128 const CoreDictionary* get_dictionary()
const;
129 CoreDictionary* get_dictionary();
130#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
131 storage::CoreDictionary m_dictionary[1];
133 std::shared_ptr<CoreDictionary> m_dictionary;
146 operator Dictionary()
const;
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;
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&);
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);
160 const Dictionary* get_dictionary()
const;
161 Dictionary* get_dictionary();
162 friend inline Dictionary * get_dictionary(
dictionary& lst);
163 friend inline const Dictionary* get_dictionary(
const dictionary& lst);
164 template <
typename T>
165 friend T get(
dictionary&,
const std::string&);
166#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
167 storage::Dictionary m_dictionary[1];
169 std::shared_ptr<Dictionary> m_dictionary;
173 template <
typename T>
174 [[nodiscard]] T get(
dictionary&,
const std::string&);
176 [[nodiscard]] std::string get(
dictionary&,
const std::string&);
190 [[nodiscard]] int64_t get(
dictionary&,
const std::string&);
192 [[nodiscard]]
double get(
dictionary&,
const std::string&);
Definition: dictionary.hpp:80
Definition: dictionary.hpp:35
Definition: dictionary.hpp:53
Definition: binary.hpp:30
Definition: dictionary.hpp:106
Definition: dictionary.hpp:138
Definition: object.hpp:45
Definition: obj_key.hpp:33
Definition: object_id.hpp:31
Definition: timestamp.hpp:30