Ditto 2.0.6
MutableDocumentPath.hpp
1#ifndef _DITTO_MUTABLE_DOCUMENT_PATH_
2#define _DITTO_MUTABLE_DOCUMENT_PATH_
3
4#include "AbstractDocumentPath.hpp"
5#include "AttachmentToken.hpp"
6#include "Helpers.hpp"
7
8#include "UpdateResult.hpp"
9
10#include "json.hpp"
11
12typedef struct CDocument CDocument_t;
13
14namespace ditto {
15
20class MutableCounter;
21class MutableRegister;
22class MutableRga;
23
33 friend class MutableDocument;
34 friend class MutableRga;
35 friend class MutableCounter;
36 friend class MutableRegister;
37
38private:
39 std::vector<std::unique_ptr<UpdateResult>> &results;
40
58 MutableDocumentPath(CDocument_t const *document, DocumentId id,
59 std::string initial_path,
60 std::vector<std::unique_ptr<UpdateResult>> &results);
61
74 MutableDocumentPath(const MutableDocumentPath *document_path,
75 std::string key);
76
89 MutableDocumentPath(const MutableDocumentPath *document_path,
90 std::size_t index);
91
93
94 template <typename T>
95 std::shared_ptr<T>
96 get_mut_object_or_default(json_callback json_cb,
97 PathAccessorType path_type) const;
98
99public:
100 MutableDocumentPath operator[](std::string key);
101 MutableDocumentPath operator[](std::size_t index);
102
112 std::shared_ptr<AttachmentToken> get_attachment_token() const;
113
123 std::shared_ptr<MutableCounter> get_counter() const;
124
134 std::shared_ptr<MutableRegister> get_register() const;
135
145 std::shared_ptr<MutableRga> get_rga() const DITTO_DEPRECATED;
146
159 void set(nlohmann::json value, bool is_default = false) const;
160
168 void remove() const;
169
170private:
181 void increment(double amount) const;
182
192 void push(nlohmann::json value) const;
193
203 nlohmann::json pop() const;
204
214 void insert(nlohmann::json value) const;
215};
216
217} // namespace ditto
218
219#endif
Provides an interface to specify a path to a key in a document that you can then call various update ...
Definition: AbstractDocumentPath.hpp:21
Definition: MutableCounter.hpp:10
This is used as part of update operations for documents.
Definition: MutableDocument.hpp:29
Provides an interface to specify a path to a key in a document that you can then call various update ...
Definition: MutableDocumentPath.hpp:32
void set(nlohmann::json value, bool is_default=false) const
Set a value at the document's key defined by the preceding subscripting.
Definition: MutableDocumentPath.cpp:43
void remove() const
Remove a value at the document's key defined by the preceding subscripting.
Definition: MutableDocumentPath.cpp:58
std::shared_ptr< MutableRga > get_rga() const DITTO_DEPRECATED
Returns the value at the previously specified key in the document as a std::shared_ptr<MutableRga>....
Definition: MutableDocumentPath.cpp:98
std::shared_ptr< MutableCounter > get_counter() const
Returns the value at the previously specified key in the document as a std::shared_ptr<MutableCounter...
Definition: MutableDocumentPath.cpp:88
std::shared_ptr< MutableRegister > get_register() const
Returns the value at the previously specified key in the document as a std::shared_ptr<MutableRegiste...
Definition: MutableDocumentPath.cpp:93
std::shared_ptr< AttachmentToken > get_attachment_token() const
Returns the value at the previously specified key in the document as a std::shared_ptr<AttachmentToke...
Definition: MutableDocumentPath.cpp:83
Definition: MutableRegister.hpp:11
Definition: MutableRga.hpp:16
basic_json<> json
default JSON class
Definition: json.hpp:2933
An identifier for a Document.
Definition: DocumentId.hpp:21