Crossfire Server, Trunk
|
JSON Pointer. More...
#include <json.hpp>
Public Member Functions | |
const std::string & | back () const |
return last reference token More... | |
bool | empty () const noexcept |
return whether pointer points to the root document More... | |
json_pointer (const std::string &s="") | |
create JSON pointer More... | |
operator std::string () const | |
return a string representation of the JSON pointer More... | |
json_pointer & | operator/= (const json_pointer &ptr) |
append another JSON pointer at the end of this JSON pointer More... | |
json_pointer & | operator/= (std::size_t array_idx) |
append an array index at the end of this JSON pointer More... | |
json_pointer & | operator/= (std::string token) |
append an unescaped reference token at the end of this JSON pointer More... | |
json_pointer | parent_pointer () const |
returns the parent of this JSON pointer More... | |
void | pop_back () |
remove last reference token More... | |
void | push_back (const std::string &token) |
append an unescaped token at the end of the reference pointer More... | |
void | push_back (std::string &&token) |
append an unescaped token at the end of the reference pointer More... | |
std::string | to_string () const |
return a string representation of the JSON pointer More... | |
Private Member Functions | |
JSON_PRIVATE_UNLESS_TESTED JSON pointer has no | BasicJsonType ())) |
bool | contains (const BasicJsonType *ptr) const |
BasicJsonType & | get_and_create (BasicJsonType &j) const |
create and return a reference to the pointed to value More... | |
BasicJsonType & | get_checked (BasicJsonType *ptr) const |
const BasicJsonType & | get_checked (const BasicJsonType *ptr) const |
BasicJsonType & | get_unchecked (BasicJsonType *ptr) const |
return a reference to the pointed to value More... | |
const BasicJsonType & | get_unchecked (const BasicJsonType *ptr) const |
return a const reference to the pointed to value More... | |
Static Private Member Functions | |
static BasicJsonType::size_type | array_index (const std::string &s) |
static void | flatten (const std::string &reference_string, const BasicJsonType &value, BasicJsonType &result) |
static std::vector< std::string > | split (const std::string &reference_string) |
split the string input to reference tokens More... | |
static BasicJsonType | unflatten (const BasicJsonType &value) |
Private Attributes | |
JSON_PRIVATE_UNLESS_TESTED | __pad0__: json_pointer top() const { if (JSON_HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405 |
JSON_PRIVATE_UNLESS_TESTED JSON pointer has no | parent |
result | reference_tokens = {reference_tokens[0]} |
std::vector< std::string > | reference_tokens |
the reference tokens More... | |
json_pointer | result = *this |
return | result |
Friends | |
class | basic_json |
bool | operator!= (json_pointer const &lhs, json_pointer const &rhs) noexcept |
compares two JSON pointers for inequality More... | |
json_pointer | operator/ (const json_pointer &lhs, const json_pointer &rhs) |
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer More... | |
json_pointer | operator/ (const json_pointer &ptr, std::size_t array_idx) |
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer More... | |
json_pointer | operator/ (const json_pointer &ptr, std::string token) |
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer More... | |
bool | operator== (json_pointer const &lhs, json_pointer const &rhs) noexcept |
compares two JSON pointers for equality More... | |
JSON Pointer.
A JSON pointer defines a string syntax for identifying a specific value within a JSON document. It can be used with functions at
and operator[]
. Furthermore, JSON pointers are the base for JSON patches.
|
inlineexplicit |
create JSON pointer
Create a JSON pointer according to the syntax described in Section 3 of RFC6901.
[in] | s | string representing the JSON pointer; if omitted, the empty string is assumed which references the whole JSON value |
parse_error.107 | if the given JSON pointer s is nonempty and does not begin with a slash (/ ); see example below |
parse_error.108 | if a tilde (~ ) in the given JSON pointer s is not followed by 0 (representing ~ ) or 1 (representing / ); see example below |
@liveexample{The example shows the construction several valid JSON pointers as well as the exceptional behavior.,json_pointer}
Definition at line 12384 of file json.hpp.
Referenced by nlohmann::json_pointer< BasicJsonType >::unflatten().
|
inlinestaticprivate |
[in] | s | reference token to be converted into an array index |
parse_error.106 | if an array index begins with '0' |
parse_error.109 | if an array index begins not with a digit |
out_of_range.404 | if string s could not be converted to an integer |
out_of_range.410 | if an array index exceeds size_type |
Definition at line 12671 of file json.hpp.
References nlohmann::json_pointer< BasicJsonType >::BasicJsonType(), nlohmann::detail::parse_error::create(), nlohmann::detail::out_of_range::create(), JSON_CATCH, JSON_HEDLEY_UNLIKELY, JSON_THROW, JSON_TRY, say::max, and altar_valkyrie::res.
Referenced by nlohmann::json_pointer< BasicJsonType >::contains(), nlohmann::json_pointer< BasicJsonType >::get_and_create(), nlohmann::json_pointer< BasicJsonType >::get_checked(), nlohmann::json_pointer< BasicJsonType >::get_unchecked(), and nlohmann::basic_json::patch().
|
inline |
return last reference token
empty()
@liveexample{The example shows the usage of back
.,json_pointer__back}
@complexity Constant.
out_of_range.405 | if JSON pointer has no parent |
Definition at line 12608 of file json.hpp.
References nlohmann::json_pointer< BasicJsonType >::BasicJsonType(), nlohmann::detail::out_of_range::create(), nlohmann::json_pointer< BasicJsonType >::empty(), JSON_HEDLEY_UNLIKELY, JSON_THROW, and nlohmann::json_pointer< BasicJsonType >::reference_tokens.
|
private |
Referenced by nlohmann::json_pointer< BasicJsonType >::array_index(), nlohmann::json_pointer< BasicJsonType >::back(), nlohmann::json_pointer< BasicJsonType >::pop_back(), nlohmann::json_pointer< BasicJsonType >::split(), and nlohmann::json_pointer< BasicJsonType >::unflatten().
|
inlineprivate |
parse_error.106 | if an array index begins with '0' |
parse_error.109 | if an array index was not a number |
Definition at line 13035 of file json.hpp.
References nlohmann::detail::array, nlohmann::json_pointer< BasicJsonType >::array_index(), nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::discarded, JSON_HEDLEY_UNLIKELY, nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, nlohmann::json_pointer< BasicJsonType >::reference_tokens, and nlohmann::detail::string.
|
inlinenoexcept |
return whether pointer points to the root document
@complexity Constant.
@exceptionsafety No-throw guarantee: this function never throws exceptions.
@liveexample{The example shows the result of empty
for different JSON Pointers.,json_pointer__empty}
Definition at line 12655 of file json.hpp.
References nlohmann::json_pointer< BasicJsonType >::reference_tokens.
Referenced by nlohmann::json_pointer< BasicJsonType >::back(), nlohmann::json_pointer< BasicJsonType >::parent_pointer(), and nlohmann::json_pointer< BasicJsonType >::pop_back().
|
inlinestaticprivate |
[in] | reference_string | the reference string to the current value |
[in] | value | the value to consider |
[in,out] | result | the result object to insert values to |
null
. Definition at line 13191 of file json.hpp.
References nlohmann::detail::array, nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::discarded, board::element, nlohmann::detail::escape(), nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, nlohmann::json_pointer< BasicJsonType >::result, nlohmann::detail::string, nlohmann::to_string(), and autojail::value.
Referenced by nlohmann::basic_json::flatten().
|
inlineprivate |
create and return a reference to the pointed to value
@complexity Linear in the number of reference tokens.
parse_error.109 | if array index is not a number |
type_error.313 | if value cannot be unflattened |
Definition at line 12736 of file json.hpp.
References nlohmann::detail::array, nlohmann::json_pointer< BasicJsonType >::array_index(), nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::type_error::create(), nlohmann::detail::discarded, JSON_THROW, nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, nlohmann::json_pointer< BasicJsonType >::reference_tokens, nlohmann::json_pointer< BasicJsonType >::result, and nlohmann::detail::string.
|
inlineprivate |
parse_error.106 | if an array index begins with '0' |
parse_error.109 | if an array index was not a number |
out_of_range.402 | if the array index '-' is used |
out_of_range.404 | if the JSON pointer can not be resolved |
Definition at line 12882 of file json.hpp.
References nlohmann::detail::array, nlohmann::json_pointer< BasicJsonType >::array_index(), nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::out_of_range::create(), nlohmann::detail::discarded, JSON_HEDLEY_UNLIKELY, JSON_THROW, nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, nlohmann::json_pointer< BasicJsonType >::reference_tokens, nlohmann::detail::string, and nlohmann::to_string().
|
inlineprivate |
parse_error.106 | if an array index begins with '0' |
parse_error.109 | if an array index was not a number |
out_of_range.402 | if the array index '-' is used |
out_of_range.404 | if the JSON pointer can not be resolved |
Definition at line 12987 of file json.hpp.
References nlohmann::detail::array, nlohmann::json_pointer< BasicJsonType >::array_index(), nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::out_of_range::create(), nlohmann::detail::discarded, JSON_HEDLEY_UNLIKELY, JSON_THROW, nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, nlohmann::json_pointer< BasicJsonType >::reference_tokens, nlohmann::detail::string, and nlohmann::to_string().
|
inlineprivate |
return a reference to the pointed to value
"/this/that"
on a null value is equivalent to calling operator[]("this").operator[]("that")
on that value, effectively changing the null value to an object.[in] | ptr | a JSON value |
@complexity Linear in the length of the JSON pointer.
parse_error.106 | if an array index begins with '0' |
parse_error.109 | if an array index was not a number |
out_of_range.404 | if the JSON pointer can not be resolved |
Definition at line 12815 of file json.hpp.
References nlohmann::detail::array, nlohmann::json_pointer< BasicJsonType >::array_index(), nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::out_of_range::create(), nlohmann::detail::discarded, JSON_THROW, nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, nlohmann::json_pointer< BasicJsonType >::reference_tokens, nlohmann::detail::string, and diamondslots::x.
|
inlineprivate |
return a const reference to the pointed to value
[in] | ptr | a JSON value |
parse_error.106 | if an array index begins with '0' |
parse_error.109 | if an array index was not a number |
out_of_range.402 | if the array index '-' is used |
out_of_range.404 | if the JSON pointer can not be resolved |
Definition at line 12939 of file json.hpp.
References nlohmann::detail::array, nlohmann::json_pointer< BasicJsonType >::array_index(), nlohmann::detail::binary, nlohmann::detail::boolean, nlohmann::detail::out_of_range::create(), nlohmann::detail::discarded, JSON_HEDLEY_UNLIKELY, JSON_THROW, nlohmann::detail::null, nlohmann::detail::number_float, nlohmann::detail::number_integer, nlohmann::detail::number_unsigned, nlohmann::detail::object, nlohmann::json_pointer< BasicJsonType >::reference_tokens, nlohmann::detail::string, and nlohmann::to_string().
|
inline |
return a string representation of the JSON pointer
ptr
, it holds: @liveexample{The example shows the result of to_string
.,json_pointer__to_string}
Definition at line 12413 of file json.hpp.
References nlohmann::json_pointer< BasicJsonType >::to_string().
|
inline |
append another JSON pointer at the end of this JSON pointer
[in] | ptr | JSON pointer to append |
@liveexample{The example shows the usage of operator/=
.,json_pointer__operator_add}
@complexity Linear in the length of ptr.
Definition at line 12434 of file json.hpp.
References nlohmann::json_pointer< BasicJsonType >::reference_tokens.
|
inline |
append an array index at the end of this JSON pointer
[in] | array_idx | array index to append |
@liveexample{The example shows the usage of operator/=
.,json_pointer__operator_add}
@complexity Amortized constant.
Definition at line 12480 of file json.hpp.
References nlohmann::to_string().
|
inline |
append an unescaped reference token at the end of this JSON pointer
[in] | token | reference token to append |
@liveexample{The example shows the usage of operator/=
.,json_pointer__operator_add}
@complexity Amortized constant.
Definition at line 12458 of file json.hpp.
References nlohmann::json_pointer< BasicJsonType >::push_back().
|
inline |
returns the parent of this JSON pointer
@complexity Linear in the length of the JSON pointer.
@liveexample{The example shows the result of parent_pointer
for different JSON Pointers.,json_pointer__parent_pointer}
Definition at line 12559 of file json.hpp.
References nlohmann::json_pointer< BasicJsonType >::empty(), and altar_valkyrie::res.
|
inline |
remove last reference token
empty()
@liveexample{The example shows the usage of pop_back
.,json_pointer__pop_back}
@complexity Constant.
out_of_range.405 | if JSON pointer has no parent |
Definition at line 12584 of file json.hpp.
References nlohmann::json_pointer< BasicJsonType >::BasicJsonType(), nlohmann::detail::out_of_range::create(), nlohmann::json_pointer< BasicJsonType >::empty(), JSON_HEDLEY_UNLIKELY, JSON_THROW, and nlohmann::json_pointer< BasicJsonType >::reference_tokens.
|
inline |
append an unescaped token at the end of the reference pointer
[in] | token | token to add |
@complexity Amortized constant.
@liveexample{The example shows the result of push_back
for different JSON Pointers.,json_pointer__push_back}
Definition at line 12630 of file json.hpp.
References nlohmann::json_pointer< BasicJsonType >::reference_tokens.
Referenced by nlohmann::json_pointer< BasicJsonType >::operator/=(), and nlohmann::json_pointer< BasicJsonType >::split().
|
inline |
append an unescaped token at the end of the reference pointer
[in] | token | token to add |
@complexity Amortized constant.
@liveexample{The example shows the result of push_back
for different JSON Pointers.,json_pointer__push_back}
Definition at line 12636 of file json.hpp.
References nlohmann::json_pointer< BasicJsonType >::reference_tokens.
|
inlinestaticprivate |
split the string input to reference tokens
parse_error.107 | if the pointer is not empty or begins with '/' |
parse_error.108 | if character '~' is not followed by '0' or '1' |
Definition at line 13123 of file json.hpp.
References nlohmann::json_pointer< BasicJsonType >::BasicJsonType(), nlohmann::detail::parse_error::create(), JSON_ASSERT, JSON_HEDLEY_UNLIKELY, JSON_THROW, nlohmann::json_pointer< BasicJsonType >::push_back(), nlohmann::json_pointer< BasicJsonType >::result, and nlohmann::detail::unescape().
|
inline |
return a string representation of the JSON pointer
ptr
, it holds: @liveexample{The example shows the result of to_string
.,json_pointer__to_string}
Definition at line 12402 of file json.hpp.
References disinfect::a, Ice::b, and nlohmann::json_pointer< BasicJsonType >::reference_tokens.
Referenced by nlohmann::json_pointer< BasicJsonType >::operator std::string().
|
inlinestaticprivate |
[in] | value | flattened JSON |
parse_error.109 | if array index is not a number |
type_error.314 | if value is not an object |
type_error.315 | if object values are not primitive |
type_error.313 | if value cannot be unflattened |
Definition at line 13262 of file json.hpp.
References nlohmann::json_pointer< BasicJsonType >::BasicJsonType(), nlohmann::detail::type_error::create(), board::element, JSON_HEDLEY_UNLIKELY, nlohmann::json_pointer< BasicJsonType >::json_pointer(), JSON_THROW, nlohmann::json_pointer< BasicJsonType >::result, and autojail::value.
Referenced by nlohmann::basic_json::unflatten().
|
friend |
|
friend |
compares two JSON pointers for inequality
[in] | lhs | JSON pointer to compare |
[in] | rhs | JSON pointer to compare |
@complexity Linear in the length of the JSON pointer
@exceptionsafety No-throw guarantee: this function never throws exceptions.
|
friend |
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
[in] | lhs | JSON pointer |
[in] | rhs | JSON pointer |
@liveexample{The example shows the usage of operator/
.,json_pointer__operator_add_binary}
@complexity Linear in the length of lhs and rhs.
|
friend |
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
[in] | ptr | JSON pointer |
[in] | array_idx | array index |
@liveexample{The example shows the usage of operator/
.,json_pointer__operator_add_binary}
@complexity Linear in the length of ptr.
|
friend |
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
[in] | ptr | JSON pointer |
[in] | token | reference token |
@liveexample{The example shows the usage of operator/
.,json_pointer__operator_add_binary}
@complexity Linear in the length of ptr.
|
friend |
compares two JSON pointers for equality
[in] | lhs | JSON pointer to compare |
[in] | rhs | JSON pointer to compare |
@complexity Linear in the length of the JSON pointer
@exceptionsafety No-throw guarantee: this function never throws exceptions.
|
private |
|
private |
|
private |
Definition at line 12723 of file json.hpp.
Referenced by nlohmann::json_pointer< BasicJsonType >::back(), nlohmann::json_pointer< BasicJsonType >::contains(), nlohmann::json_pointer< BasicJsonType >::empty(), nlohmann::json_pointer< BasicJsonType >::get_and_create(), nlohmann::json_pointer< BasicJsonType >::get_checked(), nlohmann::json_pointer< BasicJsonType >::get_unchecked(), nlohmann::json_pointer< BasicJsonType >::operator/=(), nlohmann::json_pointer< BasicJsonType >::pop_back(), nlohmann::json_pointer< BasicJsonType >::push_back(), and nlohmann::json_pointer< BasicJsonType >::to_string().
|
private |
|
private |
Definition at line 12722 of file json.hpp.
Referenced by nlohmann::json_pointer< BasicJsonType >::flatten(), nlohmann::json_pointer< BasicJsonType >::get_and_create(), nlohmann::json_pointer< BasicJsonType >::split(), and nlohmann::json_pointer< BasicJsonType >::unflatten().
|
private |