Ditto 3.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 Rga;
23
33 friend class MutableDocument;
34 friend class MutableCounter;
35 friend class MutableRegister;
36 friend class Rga;
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
149 std::shared_ptr<Rga> get_rga() const DITTO_DEPRECATED;
150
163 void set(nlohmann::json value, bool is_default = false) const;
164
172 void remove() const;
173
174private:
185 void increment(double amount) const;
186};
187
188} // namespace ditto
189
190#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
std::shared_ptr< Rga > get_rga() const DITTO_DEPRECATED
Returns the value at the previously specified key in the document as a std::shared_ptr<Rga>....
Definition: MutableDocumentPath.cpp:98
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< 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
Represents a CRDT Replicated Growable Array (RGA).
Definition: Rga.hpp:19
basic_json<> json
default JSON class
Definition: json.hpp:2933
An identifier for a Document.
Definition: DocumentId.hpp:21