openPMD-api
Public Member Functions | List of all members
openPMD::auxiliary::TracingJSON Class Reference

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

#include <JSON.hpp>

Public Member Functions

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

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

◆ getShadow()

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

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::auxiliary::TracingJSON::invertShadow ( )

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()

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

Access the underlying JSON value.

Returns
nlohmann::json&

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