openPMD-api
 
Loading...
Searching...
No Matches
openPMD::json::TracingJSON Class Reference

Extend nlohmann::json with tracing of which keys have been accessed by operator[](). More...

#include <JSON_internal.hpp>

Public Member Functions

 TracingJSON (nlohmann::json, SupportedLanguages)
 
 TracingJSON (ParsedConfig)
 
nlohmann::json & json ()
 Access the underlying JSON value.
 
nlohmann::json & json (std::vector< std::string > path)
 Access the underlying JSON value.
 
template<typename Key>
TracingJSON operator[] (Key &&key)
 
nlohmann::json const & getShadow () const
 Get the "shadow", i.e.
 
nlohmann::json & getShadow ()
 
nlohmann::json invertShadow () const
 Invert the "shadow", i.e.
 
void declareFullyRead ()
 Declare all keys of the current object read.
 

Public Attributes

SupportedLanguages originallySpecifiedAs {SupportedLanguages::JSON}
 

Detailed Description

Extend nlohmann::json with tracing of which keys have been accessed by operator[]().

An access is only registered if the current JSON value is a JSON object (not an array) and if the accessed JSON value is a leaf, i.e. anything but an object. This means that objects contained in arrays will not be traced.

If working directly with the underlying JSON value (necessary since this class only redefines operator[]), declareFullyRead() may be used to declare keys read manually.

Member Function Documentation

◆ declareFullyRead()

void openPMD::json::TracingJSON::declareFullyRead ( )

Declare all keys of the current object read.

Rationale: This class does not (yet) trace array types (or anything contained in an array). Use this call to explicitly declare an array as read.

◆ getShadow()

nlohmann::json const & openPMD::json::TracingJSON::getShadow ( ) const

Get the "shadow", i.e.

a copy of the original JSON value containing all accessed object keys.

Returns
nlohmann::json const&

◆ invertShadow()

nlohmann::json openPMD::json::TracingJSON::invertShadow ( ) const

Invert the "shadow", i.e.

a copy of the original JSON value that contains exactly those values that have not been accessed yet.

Returns
nlohmann::json

◆ json() [1/2]

nlohmann::json & openPMD::json::TracingJSON::json ( )

Access the underlying JSON value.

Returns
nlohmann::json&

◆ json() [2/2]

nlohmann::json & openPMD::json::TracingJSON::json ( std::vector< std::string > path)

Access the underlying JSON value.

See args, first arg, used to distinguish this overload.

Parameters
pathIndex to some sub-expression. Shortcut for tracingJSON[arg1][arg2][arg3].json().
Returns
nlohmann::json&

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