Ditto 4.6.0
|
Provides an interface to specify a path to a key in a document that you can then call a function on to get the value at the specified key as a specific type. More...
#include <DocumentPath.hpp>
Public Member Functions | |
DocumentPath | operator[] (std::string key) |
DocumentPath | operator[] (std::size_t index) |
std::shared_ptr< AttachmentToken > | get_attachment_token () const |
Returns the value at the previously specified key in the document as a std::shared_ptr<AttachmentToken> . If the key was invalid the return value will be a nullptr . | |
std::shared_ptr< Counter > | get_counter () const |
Returns the value at the previously specified key in the document as a std::shared_ptr<Counter> . If the key was invalid the return value will be a nullptr . | |
std::shared_ptr< Register > | get_register () const |
Returns the value at the previously specified key in the document as a std::shared_ptr<Register> . If the key was invalid the return value will be a nullptr . | |
Public Member Functions inherited from ditto::AbstractDocumentPath | |
nlohmann::json | get_json (PathAccessorType path_type) const |
AbstractDocumentPath | operator[] (std::string path) |
Used to specify a path to a key in the document that you can subscript further to access a nested key in the document and eventually perform an update operation on. | |
AbstractDocumentPath | operator[] (std::size_t index) |
Used to specify an index in the array at the preceding key-path specified through the subscripting defined previously. You can subscript the return value further to access a further nested key in the document and eventually perform an update operation. | |
std::string | get_string_value () const |
Returns the value at the previously specified key in the document as a std::string . If the key was invalid a default value of an empty string will be returned. | |
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 default value of 0 will be returned. | |
double | get_double_value () const |
Returns the value at the previously specified key in the document as a double . If the key was invalid a default value of 0 will be returned. | |
float | get_float_value () const |
Returns the value at the previously specified key in the document as a float . If the key was invalid a default value of 0 will be returned. | |
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 default value of false will be returned. | |
nlohmann::json | get_json () const |
Returns the value at the previously specified key in the document as a nlohmann::json object. If the key was invalid the return value will be a nullptr . | |
Additional Inherited Members | |
Protected Member Functions inherited from ditto::AbstractDocumentPath | |
AbstractDocumentPath (CDocument_t const *document, DocumentId id, std::string initial_path) | |
Constructs a new initial AbstractDocumentPath for a document. | |
AbstractDocumentPath (const AbstractDocumentPath *document_path, std::string key) | |
Constructs a new AbstractDocumentPath from an existing AbstractDocumentPath by appending a path. | |
AbstractDocumentPath (const AbstractDocumentPath *document_path, std::size_t index) | |
Constructs a new AbstractDocumentPath from an existing AbstractDocumentPath by appending an index. | |
AbstractDocumentPath (const AbstractDocumentPath *document_path) | |
Copy constructor. | |
template<typename T > | |
T | get_primitive_or_default (T default_value, json_callback json_cb, PathAccessorType path_type) const |
Get the primitive stored at a given path or the correspondign default value. | |
template<typename T > | |
std::shared_ptr< T > | get_object_or_default (json_callback json_cb, PathAccessorType path_type) const |
Helper function to retrieve crdt objects. | |
template<typename T > | |
std::shared_ptr< T > | get_mut_object_or_default (json_callback json_cb, PathAccessorType path_type) const |
Protected Attributes inherited from ditto::AbstractDocumentPath | |
CDocument_t const * | document |
DocumentId | id |
std::string | path |
Provides an interface to specify a path to a key in a document that you can then call a function on to get the value at the specified key as a specific type.
You obtain a DocumentPath
by subscripting a Document and you can then further subscript a DocumentPath
to further specify the key of the document that you want to get the value of.
std::shared_ptr< AttachmentToken > ditto::DocumentPath::get_attachment_token | ( | ) | const |
Returns the value at the previously specified key in the document as a std::shared_ptr<AttachmentToken>
. If the key was invalid the return value will be a nullptr
.
std::shared_ptr<AttachmentToken>
. The return value will be a nullptr
if the key was invalid or the value was not an AttachmentToken
object. std::shared_ptr< Counter > ditto::DocumentPath::get_counter | ( | ) | const |
Returns the value at the previously specified key in the document as a std::shared_ptr<Counter>
. If the key was invalid the return value will be a nullptr
.