Ditto 1.1.7
DocumentPath.hpp
1#ifndef _DITTO_DOCUMENT_PATH_
2#define _DITTO_DOCUMENT_PATH_
3
4#include "AttachmentToken.hpp"
5#include "DocumentId.hpp"
6
7#include "document_path_component.hpp"
8
9#include "json.hpp"
10
11#include <memory>
12#include <string>
13#include <vector>
14
15namespace ditto {
16
27 friend class Document;
28
29private:
30 nlohmann::json value;
31 DocumentId id;
32 std::vector<DocumentPathComponent> path_components;
33
45 DocumentPath(nlohmann::json value, DocumentId id, std::string initial_path);
46
55 DocumentPath(const DocumentPath *document_path, std::string key);
56
65 DocumentPath(const DocumentPath *document_path, std::size_t index);
66
67public:
68 DocumentPath operator[](std::string key);
69 DocumentPath operator[](std::size_t index);
70
80 std::string get_string_value() const;
81
90 int get_int_value() const;
91
100 double get_double_value() const;
101
110 float get_float_value() const;
111
120 bool get_bool_value() const;
121
131 nlohmann::json get_json() const;
132
142 std::shared_ptr<AttachmentToken> get_attachment_token() const;
143};
144} // namespace ditto
145
146#endif
A document belonging to a Collection with an inner value and an identifier (DocumentId).
Definition: Document.hpp:17
Provides an interface to specify a path to a key in a document that you can then call a function on t...
Definition: DocumentPath.hpp:26
std::string get_string_value() const
Returns the value at the previously specified key in the document as a std::string....
Definition: DocumentPath.cpp:39
double get_double_value() const
Returns the value at the previously specified key in the document as a double. If the key was invalid...
Definition: DocumentPath.cpp:55
bool get_bool_value() const
Returns the value at the previously specified key in the document as a bool. If the key was invalid a...
Definition: DocumentPath.cpp:71
float get_float_value() const
Returns the value at the previously specified key in the document as a float. If the key was invalid ...
Definition: DocumentPath.cpp:63
nlohmann::json get_json() const
Returns the value at the previously specified key in the document as a nlohmann::json object....
Definition: DocumentPath.cpp:79
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: DocumentPath.cpp:83
int get_int_value() const
Returns the value at the previously specified key in the document as an int. If the key was invalid a...
Definition: DocumentPath.cpp:47
basic_json<> json
default JSON class
Definition: json.hpp:2933
An identifier for a Document.
Definition: DocumentId.hpp:21