Ditto 4.3.0
Loading...
Searching...
No Matches
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;
22
32 friend class MutableDocument;
33 friend class MutableCounter;
34 friend class MutableRegister;
35
36private:
37 std::vector<std::unique_ptr<UpdateResult>> &results;
38
56 MutableDocumentPath(CDocument_t const *document, DocumentId id,
57 std::string initial_path,
58 std::vector<std::unique_ptr<UpdateResult>> &results);
59
72 MutableDocumentPath(const MutableDocumentPath *document_path,
73 std::string key);
74
87 MutableDocumentPath(const MutableDocumentPath *document_path,
88 std::size_t index);
89
91
92 template <typename T>
93 std::shared_ptr<T>
94 get_mut_object_or_default(json_callback json_cb,
95 PathAccessorType path_type) const;
96
97public:
98 MutableDocumentPath operator[](std::string key);
99 MutableDocumentPath operator[](std::size_t index);
100
110 std::shared_ptr<AttachmentToken> get_attachment_token() const;
111
121 std::shared_ptr<MutableCounter> get_counter() const;
122
132 std::shared_ptr<MutableRegister> get_register() const;
133
146 void set(nlohmann::json value, bool is_default = false) const;
147
155 void remove() const;
156
157private:
168 void increment(double amount) const;
169};
170
171} // namespace ditto
172
173#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:31
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:89
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:94
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:84
Definition MutableRegister.hpp:11
basic_json<> json
default JSON class
Definition json.hpp:2933
An identifier for a Document.
Definition DocumentId.hpp:21