ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nlohmann::json_pointer< BasicJsonType > Class Template Reference

#include <acts/blob/master/thirdparty/nlohmann_json/single_include/nlohmann/json.hpp>

+ Collaboration diagram for nlohmann::json_pointer< BasicJsonType >:

Public Member Functions

 json_pointer (const std::string &s="")
 create JSON pointer
 
std::string to_string () const
 return a string representation of the JSON pointer
 
 operator std::string () const
 return a string representation of the JSON pointer
 
json_pointeroperator/= (const json_pointer &ptr)
 append another JSON pointer at the end of this JSON pointer
 
json_pointeroperator/= (std::string token)
 append an unescaped reference token at the end of this JSON pointer
 
json_pointeroperator/= (std::size_t array_index)
 append an array index at the end of this JSON pointer
 
json_pointer parent_pointer () const
 returns the parent of this JSON pointer
 
void pop_back ()
 remove last reference token
 
const std::string & back () const
 return last reference token
 
void push_back (const std::string &token)
 append an unescaped token at the end of the reference pointer
 
void push_back (std::string &&token)
 append an unescaped token at the end of the reference pointer
 
bool empty () const noexcept
 return whether pointer points to the root document
 

Private Member Functions

json_pointer top () const
 
BasicJsonType & get_and_create (BasicJsonType &j) const
 create and return a reference to the pointed to value
 
BasicJsonType & get_unchecked (BasicJsonType *ptr) const
 return a reference to the pointed to value
 
BasicJsonType & get_checked (BasicJsonType *ptr) const
 
const BasicJsonType & get_unchecked (const BasicJsonType *ptr) const
 return a const reference to the pointed to value
 
const BasicJsonType & get_checked (const BasicJsonType *ptr) const
 
bool contains (const BasicJsonType *ptr) const
 

Static Private Member Functions

static int array_index (const std::string &s)
 
static std::vector< std::string > split (const std::string &reference_string)
 split the string input to reference tokens
 
static void replace_substring (std::string &s, const std::string &f, const std::string &t)
 replace all occurrences of a substring by another string
 
static std::string escape (std::string s)
 escape "~" to "~0" and "/" to "~1"
 
static void unescape (std::string &s)
 unescape "~1" to tilde and "~0" to slash (order is important!)
 
static void flatten (const std::string &reference_string, const BasicJsonType &value, BasicJsonType &result)
 
static BasicJsonType unflatten (const BasicJsonType &value)
 

Private Attributes

std::vector< std::string > reference_tokens
 the reference tokens
 

Friends

class basic_json
 
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
 
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
 
json_pointer operator/ (const json_pointer &ptr, std::size_t array_index)
 create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
 
bool operator== (json_pointer const &lhs, json_pointer const &rhs) noexcept
 compares two JSON pointers for equality
 
bool operator!= (json_pointer const &lhs, json_pointer const &rhs) noexcept
 compares two JSON pointers for inequality
 

Detailed Description

template<typename BasicJsonType>
class nlohmann::json_pointer< BasicJsonType >

Definition at line 10092 of file json.hpp.

View newest version in sPHENIX GitHub at line 10092 of file json.hpp

Constructor & Destructor Documentation

template<typename BasicJsonType >
nlohmann::json_pointer< BasicJsonType >::json_pointer ( const std::string &  s = "")
inlineexplicit

create JSON pointer

Create a JSON pointer according to the syntax described in Section 3 of RFC6901.

Parameters
[in]sstring representing the JSON pointer; if omitted, the empty string is assumed which references the whole JSON value
Exceptions
parse_error.107if the given JSON pointer s is nonempty and does not begin with a slash (/); see example below
parse_error.108if a tilde (~) in the given JSON pointer s is not followed by 0 (representing ~) or 1 (representing /); see example below

{The example shows the construction several valid JSON pointers as well as the exceptional behavior.,json_pointer}

Since
version 2.0.0

Definition at line 10120 of file json.hpp.

View newest version in sPHENIX GitHub at line 10120 of file json.hpp

Member Function Documentation

template<typename BasicJsonType >
static int nlohmann::json_pointer< BasicJsonType >::array_index ( const std::string &  s)
inlinestaticprivate
Parameters
[in]sreference token to be converted into an array index
Returns
integer representation of s
Exceptions
out_of_range.404if string s could not be converted to an integer

Definition at line 10404 of file json.hpp.

View newest version in sPHENIX GitHub at line 10404 of file json.hpp

References nlohmann::detail::out_of_range::create(), JSON_HEDLEY_UNLIKELY, and JSON_THROW.

Referenced by nlohmann::basic_json::patch().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename BasicJsonType >
const std::string& nlohmann::json_pointer< BasicJsonType >::back ( ) const
inline

return last reference token

Precondition
not empty()
Returns
last reference token

{The example shows the usage of back.,json_pointer__back}

Constant.

Exceptions
out_of_range.405if JSON pointer has no parent
Since
version 3.6.0

Definition at line 10344 of file json.hpp.

View newest version in sPHENIX GitHub at line 10344 of file json.hpp

References nlohmann::detail::out_of_range::create(), JSON_HEDLEY_UNLIKELY, and JSON_THROW.

Referenced by nlohmann::basic_json::patch().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename BasicJsonType >
bool nlohmann::json_pointer< BasicJsonType >::contains ( const BasicJsonType *  ptr) const
inlineprivate
Exceptions
parse_error.106if an array index begins with '0'
parse_error.109if an array index was not a number

Definition at line 10774 of file json.hpp.

View newest version in sPHENIX GitHub at line 10774 of file json.hpp

References nlohmann::detail::parse_error::create(), incremental_prev_tag::idx, JSON_CATCH, JSON_HEDLEY_UNLIKELY, JSON_THROW, and JSON_TRY.

Referenced by nlohmann::basic_json::contains().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename BasicJsonType >
bool nlohmann::json_pointer< BasicJsonType >::empty ( ) const
inlinenoexcept

return whether pointer points to the root document

Returns
true iff the JSON pointer points to the root document

Constant.

No-throw guarantee: this function never throws exceptions.

{The example shows the result of empty for different JSON Pointers.,json_pointer__empty}

Since
version 3.6.0

Definition at line 10391 of file json.hpp.

View newest version in sPHENIX GitHub at line 10391 of file json.hpp

Referenced by nlohmann::basic_json::patch().

+ Here is the caller graph for this function:

template<typename BasicJsonType >
static std::string nlohmann::json_pointer< BasicJsonType >::escape ( std::string  s)
inlinestaticprivate

escape "~" to "~0" and "/" to "~1"

Definition at line 10937 of file json.hpp.

View newest version in sPHENIX GitHub at line 10937 of file json.hpp

Referenced by nlohmann::basic_json::diff().

+ Here is the caller graph for this function:

template<typename BasicJsonType >
static void nlohmann::json_pointer< BasicJsonType >::flatten ( const std::string &  reference_string,
const BasicJsonType &  value,
BasicJsonType &  result 
)
inlinestaticprivate
Parameters
[in]reference_stringthe reference string to the current value
[in]valuethe value to consider
[in,out]resultthe result object to insert values to
Note
Empty objects or arrays are flattened to null.

Definition at line 10958 of file json.hpp.

View newest version in sPHENIX GitHub at line 10958 of file json.hpp

References nlohmann::to_string().

Referenced by nlohmann::basic_json::flatten().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename BasicJsonType >
BasicJsonType& nlohmann::json_pointer< BasicJsonType >::get_and_create ( BasicJsonType &  j) const
inlineprivate

create and return a reference to the pointed to value

Linear in the number of reference tokens.

Exceptions
parse_error.109if array index is not a number
type_error.313if value cannot be unflattened

Definition at line 10438 of file json.hpp.

View newest version in sPHENIX GitHub at line 10438 of file json.hpp

References nlohmann::detail::parse_error::create(), nlohmann::detail::type_error::create(), JSON_CATCH, JSON_THROW, and JSON_TRY.

Referenced by nlohmann::json_pointer< BasicJsonType >::unflatten().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename BasicJsonType >
BasicJsonType& nlohmann::json_pointer< BasicJsonType >::get_checked ( BasicJsonType *  ptr) const
inlineprivate
Exceptions
parse_error.106if an array index begins with '0'
parse_error.109if an array index was not a number
out_of_range.402if the array index '-' is used
out_of_range.404if the JSON pointer can not be resolved

Definition at line 10594 of file json.hpp.

View newest version in sPHENIX GitHub at line 10594 of file json.hpp

References nlohmann::detail::parse_error::create(), nlohmann::detail::out_of_range::create(), JSON_CATCH, JSON_HEDLEY_UNLIKELY, JSON_THROW, JSON_TRY, and nlohmann::to_string().

Referenced by nlohmann::basic_json::at(), and nlohmann::basic_json::value().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename BasicJsonType >
const BasicJsonType& nlohmann::json_pointer< BasicJsonType >::get_checked ( const BasicJsonType *  ptr) const
inlineprivate
Exceptions
parse_error.106if an array index begins with '0'
parse_error.109if an array index was not a number
out_of_range.402if the array index '-' is used
out_of_range.404if the JSON pointer can not be resolved

Definition at line 10718 of file json.hpp.

View newest version in sPHENIX GitHub at line 10718 of file json.hpp

References nlohmann::detail::parse_error::create(), nlohmann::detail::out_of_range::create(), JSON_CATCH, JSON_HEDLEY_UNLIKELY, JSON_THROW, JSON_TRY, and nlohmann::to_string().

+ Here is the call graph for this function:

template<typename BasicJsonType >
BasicJsonType& nlohmann::json_pointer< BasicJsonType >::get_unchecked ( BasicJsonType *  ptr) const
inlineprivate

return a reference to the pointed to value

Note
This version does not throw if a value is not present, but tries to create nested values instead. For instance, calling this function with pointer "/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.
Parameters
[in]ptra JSON value
Returns
reference to the JSON value pointed to by the JSON pointer

Linear in the length of the JSON pointer.

Exceptions
parse_error.106if an array index begins with '0'
parse_error.109if an array index was not a number
out_of_range.404if the JSON pointer can not be resolved

Definition at line 10518 of file json.hpp.

View newest version in sPHENIX GitHub at line 10518 of file json.hpp

References nlohmann::detail::parse_error::create(), nlohmann::detail::out_of_range::create(), JSON_CATCH, JSON_HEDLEY_UNLIKELY, JSON_THROW, JSON_TRY, and x.

Referenced by nlohmann::basic_json::operator[]().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename BasicJsonType >
const BasicJsonType& nlohmann::json_pointer< BasicJsonType >::get_unchecked ( const BasicJsonType *  ptr) const
inlineprivate

return a const reference to the pointed to value

Parameters
[in]ptra JSON value
Returns
const reference to the JSON value pointed to by the JSON pointer
Exceptions
parse_error.106if an array index begins with '0'
parse_error.109if an array index was not a number
out_of_range.402if the array index '-' is used
out_of_range.404if the JSON pointer can not be resolved

Definition at line 10659 of file json.hpp.

View newest version in sPHENIX GitHub at line 10659 of file json.hpp

References nlohmann::detail::parse_error::create(), nlohmann::detail::out_of_range::create(), JSON_CATCH, JSON_HEDLEY_UNLIKELY, JSON_THROW, JSON_TRY, and nlohmann::to_string().

+ Here is the call graph for this function:

template<typename BasicJsonType >
nlohmann::json_pointer< BasicJsonType >::operator std::string ( ) const
inline

return a string representation of the JSON pointer

Invariant
For each JSON pointer ptr, it holds:
ptr == json_pointer(ptr.to_string());
Returns
a string representation of the JSON pointer

{The example shows the result of to_string.,json_pointer__to_string}

Since
version 2.0.0

Definition at line 10149 of file json.hpp.

View newest version in sPHENIX GitHub at line 10149 of file json.hpp

References nlohmann::to_string().

+ Here is the call graph for this function:

template<typename BasicJsonType >
json_pointer& nlohmann::json_pointer< BasicJsonType >::operator/= ( const json_pointer< BasicJsonType > &  ptr)
inline

append another JSON pointer at the end of this JSON pointer

Parameters
[in]ptrJSON pointer to append
Returns
JSON pointer with ptr appended

{The example shows the usage of operator/=.,json_pointer__operator_add}

Linear in the length of ptr.

See Also
operator/=(std::string) to append a reference token
operator/=(std::size_t) to append an array index
operator/(const json_pointer&, const json_pointer&) for a binary operator
Since
version 3.6.0

Definition at line 10170 of file json.hpp.

View newest version in sPHENIX GitHub at line 10170 of file json.hpp

References nlohmann::json_pointer< BasicJsonType >::reference_tokens.

template<typename BasicJsonType >
json_pointer& nlohmann::json_pointer< BasicJsonType >::operator/= ( std::string  token)
inline

append an unescaped reference token at the end of this JSON pointer

Parameters
[in]tokenreference token to append
Returns
JSON pointer with token appended without escaping token

{The example shows the usage of operator/=.,json_pointer__operator_add}

Amortized constant.

See Also
operator/=(const json_pointer&) to append a JSON pointer
operator/=(std::size_t) to append an array index
operator/(const json_pointer&, std::size_t) for a binary operator
Since
version 3.6.0

Definition at line 10194 of file json.hpp.

View newest version in sPHENIX GitHub at line 10194 of file json.hpp

template<typename BasicJsonType >
json_pointer& nlohmann::json_pointer< BasicJsonType >::operator/= ( std::size_t  array_index)
inline

append an array index at the end of this JSON pointer

Parameters
[in]array_indexarray index to append
Returns
JSON pointer with array_index appended

{The example shows the usage of operator/=.,json_pointer__operator_add}

Amortized constant.

See Also
operator/=(const json_pointer&) to append a JSON pointer
operator/=(std::string) to append a reference token
operator/(const json_pointer&, std::string) for a binary operator
Since
version 3.6.0

Definition at line 10216 of file json.hpp.

View newest version in sPHENIX GitHub at line 10216 of file json.hpp

References nlohmann::to_string().

+ Here is the call graph for this function:

template<typename BasicJsonType >
json_pointer nlohmann::json_pointer< BasicJsonType >::parent_pointer ( ) const
inline

returns the parent of this JSON pointer

Returns
parent of this JSON pointer; in case this JSON pointer is the root, the root itself is returned

Linear in the length of the JSON pointer.

{The example shows the result of parent_pointer for different JSON Pointers.,json_pointer__parent_pointer}

Since
version 3.6.0

Definition at line 10295 of file json.hpp.

View newest version in sPHENIX GitHub at line 10295 of file json.hpp

References nlohmann::json_pointer< BasicJsonType >::pop_back().

+ Here is the call graph for this function:

template<typename BasicJsonType >
void nlohmann::json_pointer< BasicJsonType >::pop_back ( )
inline

remove last reference token

Precondition
not empty()

{The example shows the usage of pop_back.,json_pointer__pop_back}

Constant.

Exceptions
out_of_range.405if JSON pointer has no parent
Since
version 3.6.0

Definition at line 10320 of file json.hpp.

View newest version in sPHENIX GitHub at line 10320 of file json.hpp

References nlohmann::detail::out_of_range::create(), JSON_HEDLEY_UNLIKELY, and JSON_THROW.

Referenced by nlohmann::json_pointer< BasicJsonType >::parent_pointer(), and nlohmann::basic_json::patch().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename BasicJsonType >
void nlohmann::json_pointer< BasicJsonType >::push_back ( const std::string &  token)
inline

append an unescaped token at the end of the reference pointer

Parameters
[in]tokentoken to add

Amortized constant.

{The example shows the result of push_back for different JSON Pointers.,json_pointer__push_back}

Since
version 3.6.0

Definition at line 10366 of file json.hpp.

View newest version in sPHENIX GitHub at line 10366 of file json.hpp

template<typename BasicJsonType >
void nlohmann::json_pointer< BasicJsonType >::push_back ( std::string &&  token)
inline

append an unescaped token at the end of the reference pointer

Parameters
[in]tokentoken to add

Amortized constant.{The example shows the result of push_back for different JSON Pointers.,json_pointer__push_back}

Since
version 3.6.0

Definition at line 10372 of file json.hpp.

View newest version in sPHENIX GitHub at line 10372 of file json.hpp

template<typename BasicJsonType >
static void nlohmann::json_pointer< BasicJsonType >::replace_substring ( std::string &  s,
const std::string &  f,
const std::string &  t 
)
inlinestaticprivate

replace all occurrences of a substring by another string

Parameters
[in,out]sthe string to manipulate; changed so that all occurrences of f are replaced with t
[in]fthe substring to replace with t
[in]tthe string to replace f
Precondition
The search string f must not be empty. This precondition is enforced with an assertion.
Since
version 2.0.0

Definition at line 10925 of file json.hpp.

View newest version in sPHENIX GitHub at line 10925 of file json.hpp

References pos(), and t.

+ Here is the call graph for this function:

template<typename BasicJsonType >
static std::vector<std::string> nlohmann::json_pointer< BasicJsonType >::split ( const std::string &  reference_string)
inlinestaticprivate

split the string input to reference tokens

Note
This function is only called by the json_pointer constructor. All exceptions below are documented there.
Exceptions
parse_error.107if the pointer is not empty or begins with '/'
parse_error.108if character '~' is not followed by '0' or '1'

Definition at line 10850 of file json.hpp.

View newest version in sPHENIX GitHub at line 10850 of file json.hpp

References nlohmann::detail::parse_error::create(), JSON_HEDLEY_UNLIKELY, JSON_THROW, pos(), and start().

+ Here is the call graph for this function:

template<typename BasicJsonType >
std::string nlohmann::json_pointer< BasicJsonType >::to_string ( ) const
inline

return a string representation of the JSON pointer

Invariant
For each JSON pointer ptr, it holds:
ptr == json_pointer(ptr.to_string());
Returns
a string representation of the JSON pointer

{The example shows the result of to_string.,json_pointer__to_string}

Since
version 2.0.0

Definition at line 10138 of file json.hpp.

View newest version in sPHENIX GitHub at line 10138 of file json.hpp

References a, and b.

template<typename BasicJsonType >
json_pointer nlohmann::json_pointer< BasicJsonType >::top ( ) const
inlineprivate

Definition at line 10418 of file json.hpp.

View newest version in sPHENIX GitHub at line 10418 of file json.hpp

References nlohmann::detail::out_of_range::create(), JSON_HEDLEY_UNLIKELY, JSON_THROW, and nlohmann::json_pointer< BasicJsonType >::reference_tokens.

Referenced by nlohmann::basic_json::patch().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename BasicJsonType >
static void nlohmann::json_pointer< BasicJsonType >::unescape ( std::string &  s)
inlinestaticprivate

unescape "~1" to tilde and "~0" to slash (order is important!)

Definition at line 10945 of file json.hpp.

View newest version in sPHENIX GitHub at line 10945 of file json.hpp

template<typename BasicJsonType >
static BasicJsonType nlohmann::json_pointer< BasicJsonType >::unflatten ( const BasicJsonType &  value)
inlinestaticprivate
Parameters
[in]valueflattened JSON
Returns
unflattened JSON
Exceptions
parse_error.109if array index is not a number
type_error.314if value is not an object
type_error.315if object values are not primitive
type_error.313if value cannot be unflattened

Definition at line 11021 of file json.hpp.

View newest version in sPHENIX GitHub at line 11021 of file json.hpp

References nlohmann::detail::type_error::create(), nlohmann::json_pointer< BasicJsonType >::get_and_create(), JSON_HEDLEY_UNLIKELY, and JSON_THROW.

Referenced by nlohmann::basic_json::unflatten().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Friends And Related Function Documentation

template<typename BasicJsonType >
friend class basic_json
friend

Definition at line 10096 of file json.hpp.

View newest version in sPHENIX GitHub at line 10096 of file json.hpp

template<typename BasicJsonType >
bool operator!= ( json_pointer< BasicJsonType > const &  lhs,
json_pointer< BasicJsonType > const &  rhs 
)
friend

compares two JSON pointers for inequality

Parameters
[in]lhsJSON pointer to compare
[in]rhsJSON pointer to compare
Returns
whether lhs is not equal rhs

Linear in the length of the JSON pointer

No-throw guarantee: this function never throws exceptions.

Definition at line 11076 of file json.hpp.

View newest version in sPHENIX GitHub at line 11076 of file json.hpp

template<typename BasicJsonType >
json_pointer operator/ ( const json_pointer< BasicJsonType > &  lhs,
const json_pointer< BasicJsonType > &  rhs 
)
friend

create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer

Parameters
[in]lhsJSON pointer
[in]rhsJSON pointer
Returns
a new JSON pointer with rhs appended to lhs

{The example shows the usage of operator/.,json_pointer__operator_add_binary}

Linear in the length of lhs and rhs.

See Also
operator/=(const json_pointer&) to append a JSON pointer
Since
version 3.6.0

Definition at line 10236 of file json.hpp.

View newest version in sPHENIX GitHub at line 10236 of file json.hpp

template<typename BasicJsonType >
json_pointer operator/ ( const json_pointer< BasicJsonType > &  ptr,
std::string  token 
)
friend

create a new JSON pointer by appending the unescaped token at the end of the JSON pointer

Parameters
[in]ptrJSON pointer
[in]tokenreference token
Returns
a new JSON pointer with unescaped token appended to ptr

{The example shows the usage of operator/.,json_pointer__operator_add_binary}

Linear in the length of ptr.

See Also
operator/=(std::string) to append a reference token
Since
version 3.6.0

Definition at line 10257 of file json.hpp.

View newest version in sPHENIX GitHub at line 10257 of file json.hpp

template<typename BasicJsonType >
json_pointer operator/ ( const json_pointer< BasicJsonType > &  ptr,
std::size_t  array_index 
)
friend

create a new JSON pointer by appending the array-index-token at the end of the JSON pointer

Parameters
[in]ptrJSON pointer
[in]array_indexarray index
Returns
a new JSON pointer with array_index appended to ptr

{The example shows the usage of operator/.,json_pointer__operator_add_binary}

Linear in the length of ptr.

See Also
operator/=(std::size_t) to append an array index
Since
version 3.6.0

Definition at line 10277 of file json.hpp.

View newest version in sPHENIX GitHub at line 10277 of file json.hpp

template<typename BasicJsonType >
bool operator== ( json_pointer< BasicJsonType > const &  lhs,
json_pointer< BasicJsonType > const &  rhs 
)
friend

compares two JSON pointers for equality

Parameters
[in]lhsJSON pointer to compare
[in]rhsJSON pointer to compare
Returns
whether lhs is equal to rhs

Linear in the length of the JSON pointer

No-throw guarantee: this function never throws exceptions.

Definition at line 11059 of file json.hpp.

View newest version in sPHENIX GitHub at line 11059 of file json.hpp

Member Data Documentation

template<typename BasicJsonType >
std::vector<std::string> nlohmann::json_pointer< BasicJsonType >::reference_tokens
private

the reference tokens

Definition at line 11083 of file json.hpp.

View newest version in sPHENIX GitHub at line 11083 of file json.hpp

Referenced by nlohmann::json_pointer< BasicJsonType >::operator/=(), and nlohmann::json_pointer< BasicJsonType >::top().


The documentation for this class was generated from the following file: