|
Ditto 1.1.5
|
Provides an interface to specify a path to a key in a document that you can then call various update functions on. More...
#include <MutableDocumentPath.hpp>
Public Member Functions | |
| MutableDocumentPath | 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. More... | |
| MutableDocumentPath | 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| void | set (nlohmann::json value, bool is_default=false) const |
| Set a value at the document's key defined by the preceding subscripting. More... | |
| void | remove () const |
| Remove a value at the document's key defined by the preceding subscripting. More... | |
| void | replace_with_counter (bool is_default=false) const |
| Replace a value at the document's key defined by the preceding subscripting with a counter. More... | |
| void | increment (double amount) const |
| Increment a counter at the document's key defined by the preceding subscripting. This will only succeed if the value at the subscripting-defined key is a counter. More... | |
| void | push (nlohmann::json value) const |
| Push a value on to the end of an array at the document's key defined by the preceding subscripting. This will only succeed if the value at the subscripting-defined key is an array. More... | |
| nlohmann::json | pop () const |
| Pop a value off the end of an array at the document's key defined by the preceding subscripting. This will only succeed if the value at the subscripting-defined key is an array. More... | |
| void | insert (nlohmann::json value) const |
| Inserts a value into an array at the index defined by the preceding subscripting. This will only succeed if the value at the subscripting-defined key is an index into an array. More... | |
Provides an interface to specify a path to a key in a document that you can then call various update functions on.
You obtain a MutableDocumentPath by subscripting a MutableDocument and you can then further subscript a MutableDocumentPath to further specify the key of the document that you want to update.
| std::shared_ptr< AttachmentToken > ditto::MutableDocumentPath::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. | bool ditto::MutableDocumentPath::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.
bool. The return value will be false if the key was invalid or the value was not a boolean type. | double ditto::MutableDocumentPath::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.
double. The return value will be 0 if the key was invalid or the value was not a numeric type. | float ditto::MutableDocumentPath::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.
float. The return value will be 0 if the key was invalid or the value was not a numeric type. | int ditto::MutableDocumentPath::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.
int. The return value will be 0 if the key was invalid or the value was not a numeric type. | json ditto::MutableDocumentPath::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.
nlohmann::json object. The return value will be a nullptr if the key was invalid. | std::string ditto::MutableDocumentPath::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.
std::string. The return value will be an empty string if the key was invalid or the value was not a string. | void ditto::MutableDocumentPath::increment | ( | double | amount | ) | const |
Increment a counter at the document's key defined by the preceding subscripting. This will only succeed if the value at the subscripting-defined key is a counter.
| [in] | amount | the amount to increment the counter by. This can be a positive or a negative value. |
| DittoError | thrown if trying to update the document at an invalid key. |
| void ditto::MutableDocumentPath::insert | ( | nlohmann::json | value | ) | const |
Inserts a value into an array at the index defined by the preceding subscripting. This will only succeed if the value at the subscripting-defined key is an index into an array.
| [in] | value | the value to insert into the array. |
| DittoError | thrown if trying to update the document at an invalid key. |
| MutableDocumentPath ditto::MutableDocumentPath::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.
| [in] | index | the index of the array that you wish to access in the key previously specified with the preceding subscripting. |
| MutableDocumentPath ditto::MutableDocumentPath::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.
| [in] | path | the next part of the path needed to get to the key in the document you wish to update. |
| json ditto::MutableDocumentPath::pop | ( | ) | const |
Pop a value off the end of an array at the document's key defined by the preceding subscripting. This will only succeed if the value at the subscripting-defined key is an array.
| DittoError | thrown if trying to update the document at an invalid key. |
| void ditto::MutableDocumentPath::push | ( | nlohmann::json | value | ) | const |
Push a value on to the end of an array at the document's key defined by the preceding subscripting. This will only succeed if the value at the subscripting-defined key is an array.
| [in] | value | the value to push on to the array. |
| DittoError | thrown if trying to update the document at an invalid key. |
| void ditto::MutableDocumentPath::remove | ( | ) | const |
Remove a value at the document's key defined by the preceding subscripting.
| DittoError | thrown if trying to update the document at an invalid key. |
| void ditto::MutableDocumentPath::replace_with_counter | ( | bool | is_default = false | ) | const |
Replace a value at the document's key defined by the preceding subscripting with a counter.
| [in] | is_default | represents whether or not the value is being replaced with a counter that should serve as a default value. Set this to true if you want to set a default value that you expect to be overwritten by other devices in the network. The default value is false. |
| DittoError | thrown if trying to update the document at an invalid key. |
| void ditto::MutableDocumentPath::set | ( | nlohmann::json | value, |
| bool | is_default = false |
||
| ) | const |
Set a value at the document's key defined by the preceding subscripting.
| value | the value to set at the subscripting-defined document key. |
| is_default | represents whether or not the value should be set as a default value. Set this to true if you want to set a default value that you expect to be overwritten by other devices in the network. The default value is false. |
| DittoError | thrown if trying to update the document at an invalid key. |