Ditto 3.0.11
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ditto::DocumentIdPath Class Reference

Provides an interface to specify a path to a key in a document ID that you can then call a function on to get the value at the specified key as a specific type. More...

#include <DocumentIdPath.hpp>

Public Member Functions

DocumentIdPath operator[] (std::string key)
 
DocumentIdPath operator[] (std::size_t index)
 
std::string get_string_value () const
 Returns the value at the previously specified key in the document ID 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 ID 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 ID 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 ID 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 ID 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 ID as a nlohmann::json object. If the key was invalid the return value will be a nullptr.
 

Detailed Description

Provides an interface to specify a path to a key in a document ID that you can then call a function on to get the value at the specified key as a specific type.

You obtain a DocumentIdPath by subscripting a DocumentId and you can then further subscript a DocumentIdPath to further specify the key of the document ID that you want to get the value of.

Member Function Documentation

◆ get_bool_value()

bool ditto::DocumentIdPath::get_bool_value ( ) const

Returns the value at the previously specified key in the document ID 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 ID 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::DocumentIdPath::get_double_value ( ) const

Returns the value at the previously specified key in the document ID 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 ID 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::DocumentIdPath::get_float_value ( ) const

Returns the value at the previously specified key in the document ID 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 ID 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::DocumentIdPath::get_int_value ( ) const

Returns the value at the previously specified key in the document ID 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 ID 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::DocumentIdPath::get_json ( ) const

Returns the value at the previously specified key in the document ID 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 ID subscripting as a nlohmann::json object. The return value will be a nullptr if the key was invalid.

◆ get_string_value()

std::string ditto::DocumentIdPath::get_string_value ( ) const

Returns the value at the previously specified key in the document ID 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 ID 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.