Ditto  1.0.14
Public Member Functions | List of all members
ditto::DocumentPath Class Reference

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...

Public Member Functions

DocumentPath operator[] (std::string key)
 
DocumentPath operator[] (std::size_t index)
 
std::string get_string_value ()
 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. More...
 
int get_int_value ()
 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. More...
 
double get_double_value ()
 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. More...
 
float get_float_value ()
 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. More...
 
bool get_bool_value ()
 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. More...
 
nlohmann::json get_json ()
 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. More...
 
std::shared_ptr< AttachmentTokenget_attachment_token ()
 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. More...
 

Detailed Description

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.

Member Function Documentation

◆ get_attachment_token()

std::shared_ptr< AttachmentToken > ditto::DocumentPath::get_attachment_token ( )

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.

Returns
The value at the path specified by the document subscripting as a std::shared_ptr<AttachmentToken>. The return value will be a nullptr if the key was invalid or the value was not an AttachmentToken object.

◆ get_bool_value()

bool ditto::DocumentPath::get_bool_value ( )

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.

Returns
The value at the path specified by the document subscripting as a bool. The return value will be false if the key was invalid or the value was not a boolean type.

◆ get_double_value()

double ditto::DocumentPath::get_double_value ( )

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.

Returns
The value at the path specified by the document subscripting as a double. The return value will be 0 if the key was invalid or the value was not a numeric type.

◆ get_float_value()

float ditto::DocumentPath::get_float_value ( )

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.

Returns
The value at the path specified by the document subscripting as a float. The return value will be 0 if the key was invalid or the value was not a numeric type.

◆ get_int_value()

int ditto::DocumentPath::get_int_value ( )

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.

Returns
The value at the path specified by the document subscripting as an int. The return value will be 0 if the key was invalid or the value was not a numeric type.

◆ get_json()

json ditto::DocumentPath::get_json ( )

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.

Returns
The value at the path specified by the document subscripting as a nlohmann::json object. The return value will be a nullptr if the key was invalid.

◆ get_string_value()

std::string ditto::DocumentPath::get_string_value ( )

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.

Returns
The value at the path specified by the document subscripting as a std::string. The return value will be an empty string if the key was invalid or the value was not a string.