NlohmannJSONWriter Class Reference

#include <RobotAPI/libraries/aron/core/data/rw/writer/nlohmannJSON/NlohmannJSONWriter.h>

+ Inheritance diagram for NlohmannJSONWriter:

Public Member Functions

data::Descriptor getDescriptor (ReturnTypeConst &input) final
 
 NlohmannJSONWriter ()=default
 
nlohmann::json writeBool (const bool i, const Path &p=Path()) override
 
nlohmann::json writeDict (const std::map< std::string, nlohmann::json > &elements, const std::optional< nlohmann::json > &extends=std::nullopt, const Path &p=Path()) override
 
nlohmann::json writeDict (std::map< std::string, nlohmann::json > &&elements, const std::optional< nlohmann::json > &extends, const Path &p) override
 Overload for callers that no longer need elements afterwards - which is the case for all generated write() code, since it builds the element map purely to hand it over.
 
nlohmann::json writeDouble (const double i, const Path &p=Path()) override
 
nlohmann::json writeFloat (const float i, const Path &p=Path()) override
 
void writeImportance (ReturnType &output, const std::optional< float > &importance) final
 
nlohmann::json writeInt (const int i, const Path &p=Path()) override
 
nlohmann::json writeList (const std::vector< nlohmann::json > &elements, const Path &p=Path()) override
 
nlohmann::json writeList (std::vector< nlohmann::json > &&elements, const Path &p) override
 std::map<std::string, json> IS nlohmann's object_t and std::vector<json> IS array_t, so assigning one by const reference deep-copies every descendant – and the converter aggregates bottom-up, so that happens once per level of nesting.
 
nlohmann::json writeLong (const long i, const Path &p=Path()) override
 
nlohmann::json writeNDArray (const std::vector< int > &shape, const std::string &typeAsString, const unsigned char *data, const Path &p=Path()) override
 
nlohmann::json writeString (const std::string &i, const Path &p=Path()) override
 
- Public Member Functions inherited from WriterInterface< nlohmann::json >
virtual data::Descriptor getDescriptor (ReturnTypeConst &input)=0
 
virtual ReturnType writeNull ()
 
ReturnType writePrimitive (const bool i, const Path &p=Path())
 
ReturnType writePrimitive (const double i, const Path &p=Path())
 
ReturnType writePrimitive (const float i, const Path &p=Path())
 
ReturnType writePrimitive (const int i, const Path &p=Path())
 
ReturnType writePrimitive (const long i, const Path &p=Path())
 
ReturnType writePrimitive (const std::string &i, const Path &p=Path())
 
virtual ~WriterInterface ()=default
 

Additional Inherited Members

- Public Types inherited from WriterInterface< nlohmann::json >
using ReturnType
 
using ReturnTypeConst
 

Constructor & Destructor Documentation

◆ NlohmannJSONWriter()

NlohmannJSONWriter ( )
default

Member Function Documentation

◆ getDescriptor()

data::Descriptor getDescriptor ( ReturnTypeConst & input)
final

◆ writeBool()

nlohmann::json writeBool ( const bool i,
const Path & p = Path() )
overridevirtual

◆ writeDict() [1/2]

nlohmann::json writeDict ( const std::map< std::string, nlohmann::json > & elements,
const std::optional< nlohmann::json > & extends = std::nullopt,
const Path & p = Path() )
overridevirtual

◆ writeDict() [2/2]

nlohmann::json writeDict ( std::map< std::string, nlohmann::json > && elements,
const std::optional< nlohmann::json > & extends,
const Path & p )
overridevirtual

Overload for callers that no longer need elements afterwards - which is the case for all generated write() code, since it builds the element map purely to hand it over.

The default implementation forwards to the copying overload, so writers that cannot take ownership need not implement anything. Writers that can (see VariantWriter) override this to avoid rebuilding the map element by element.

Reimplemented from WriterInterface< nlohmann::json >.

◆ writeDouble()

nlohmann::json writeDouble ( const double i,
const Path & p = Path() )
overridevirtual

◆ writeFloat()

nlohmann::json writeFloat ( const float i,
const Path & p = Path() )
overridevirtual

◆ writeImportance()

void writeImportance ( ReturnType & output,
const std::optional< float > & importance )
finalvirtual

Reimplemented from WriterInterface< nlohmann::json >.

◆ writeInt()

nlohmann::json writeInt ( const int i,
const Path & p = Path() )
overridevirtual

◆ writeList() [1/2]

nlohmann::json writeList ( const std::vector< nlohmann::json > & elements,
const Path & p = Path() )
overridevirtual

◆ writeList() [2/2]

nlohmann::json writeList ( std::vector< nlohmann::json > && elements,
const Path & p )
overridevirtual

std::map<std::string, json> IS nlohmann's object_t and std::vector<json> IS array_t, so assigning one by const reference deep-copies every descendant – and the converter aggregates bottom-up, so that happens once per level of nesting.

These take ownership and move instead.

Reimplemented from WriterInterface< nlohmann::json >.

◆ writeLong()

nlohmann::json writeLong ( const long i,
const Path & p = Path() )
overridevirtual

◆ writeNDArray()

nlohmann::json writeNDArray ( const std::vector< int > & shape,
const std::string & typeAsString,
const unsigned char * data,
const Path & p = Path() )
overridevirtual

◆ writeString()

nlohmann::json writeString ( const std::string & i,
const Path & p = Path() )
overridevirtual

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