cereal::JSONInputArchive Class Reference
Input and Output Archive Types

An input archive designed to load data from JSON. More...

`#include </build/libcereal-B5G4p0/libcereal-1.1.2/include/cereal/archives/json.hpp>`

Inheritance diagram for cereal::JSONInputArchive:

## Public Member Functions

Common Functionality
Common use cases for directly interacting with an JSONInputArchive
| JSONInputArchive (std::istream &stream)
| Construct, reading from the provided stream. More...
void | loadBinaryValue (void *data, size_t size, const char *name=nullptr)
| Loads some binary data, encoded as a base64 string. More...
Public Member Functions inherited from cereal::InputArchive< JSONInputArchive >
| InputArchive (JSONInputArchive *const derived)
| Construct the output archive. More...
InputArchive & | operator= (InputArchive const &)=delete
JSONInputArchive & | operator() (Types &&...args)
| Serializes all passed in data. More...
std::shared_ptr< void > | getSharedPointer (std::uint32_t const id)
| Retrieves a shared pointer given a unique key for it. More...
void | registerSharedPointer (std::uint32_t const id, std::shared_ptr< void > ptr)
| Registers a shared pointer to its unique identifier. More...
std::string | getPolymorphicName (std::uint32_t const id)
| Retrieves the string for a polymorphic type given a unique key for it. More...
void | registerPolymorphicName (std::uint32_t const id, std::string const &name)
| Registers a polymorphic name string to its unique identifier. More...
JSONInputArchive & | operator& (T &&arg)
| Serializes passed in data. More...
JSONInputArchive & | operator>> (T &&arg)
| Serializes passed in data. More...

## Internal Functionality

Functionality designed for use by those requiring control over the inner mechanisms of the JSONInputArchive
void | startNode ()
| Starts a new node, going into its proper iterator. More...
void | finishNode ()
| Finishes the most recently started node.
const char * | getNodeName () const
| Retrieves the current node name. More...
void | setNextName (const char *name)
| Sets the name for the next node created with startNode.

template<class T , traits::EnableIf< std::is_signed< T >::value, sizeof(T)< sizeof(int64_t)>=traits::sfinae > inline void loadValue(T &val){search();val=static_cast< T >(itsIteratorStack.back().value().GetInt());++itsIteratorStack.back();}template< class T, traits::EnableIf< std::is_unsigned< T >::value, sizeof(T)< sizeof(uint64_t),!std::is_same< bool, T >::value >=traits::sfinae > inlinevoid loadValue(T &val){search();val=static_cast< T >(itsIteratorStack.back().value().GetUint());++itsIteratorStack.back();}void loadValue(bool &val){search();val=itsIteratorStack.back().value().GetBool_();++itsIteratorStack.back();}void loadValue(int64_t &val){search();val=itsIteratorStack.back().value().GetInt64();++itsIteratorStack.back();}void loadValue(uint64_t &val){search();val=itsIteratorStack.back().value().GetUint64();++itsIteratorStack.back();}void loadValue(float &val){search();val=static_cast< float >(itsIteratorStack.back().value().GetDouble());++itsIteratorStack.back();}void loadValue(double &val){search();val=itsIteratorStack.back().value().GetDouble();++itsIteratorStack.back();}void loadValue(std::string &val){search();val=itsIteratorStack.back().value().GetString();++itsIteratorStack.back();}private:template< class T > inlinetypename std::enable_if< sizeof(T)==sizeof(std::int32_t)&&std::is_signed< T >::value, void >::typeloadLong(T &l){loadValue(reinterpret_cast< std::int32_t & >(l));}template< class T > inlinetypename std::enable_if< sizeof(T)==sizeof(std::int64_t)&&std::is_signed< T >::value, void >::typeloadLong(T &l){loadValue(reinterpret_cast< std::int64_t & >(l));}template< class T > inlinetypename std::enable_if< sizeof(T)==sizeof(std::uint32_t)&&!std::is_signed< T >::value, void >::typeloadLong(T &lu){loadValue(reinterpret_cast< std::uint32_t & >(lu));}template< class T > inlinetypename std::enable_if< sizeof(T)==sizeof(std::uint64_t)&&!std::is_signed< T >::value, void >::typeloadLong(T &lu){loadValue(reinterpret_cast< std::uint64_t & >(lu));}public:template< class T > inlinetypename std::enable_if< std::is_same< T, long >::value &&sizeof(T) >=sizeof(std::int64_t)&&!std::is_same< T, std::int64_t >::value, void >::type loadValue(T &t){loadLong(t);}template< class T > inline typename std::enable_if< std::is_same< T, unsigned long >::value &&sizeof(T) > = sizeof(std::uint64_t) && !std::is_same<T, std::uint64_t>::value, void >

::type | loadValue (T &t)
| Loads a value from the current node - small signed overload.
template<class T , traits::EnableIf< std::is_arithmetic< T >::value,!std::is_same< T, long >::value,!std::is_same< T, unsigned long >::value,!std::is_same< T, std::int64_t >::value,!std::is_same< T, std::uint64_t >::value,(sizeof(T) > = sizeof(long double) || sizeof(T) >= sizeof(long long)>
void | loadValue (T &val)
| Loads a value from the current node - long double and long long overloads.
void | loadSize (size_type &size)
| Loads the size for a SizeTag.

## Detailed Description

An input archive designed to load data from JSON.

This archive uses RapidJSON to read in a JSON archive.

Input JSON should have been produced by the JSONOutputArchive. Data can only be added to dynamically sized containers (marked by JSON arrays) - the input archive will determine their size by looking at the number of child nodes. Only JSON originating from a JSONOutputArchive is officially supported, but data from other sources may work if properly formatted.

The JSONInputArchive does not require that nodes are loaded in the same order they were saved by JSONOutputArchive. Using name value pairs (NVPs), it is possible to load in an out of order fashion or otherwise skip/select specific nodes to load.

The default behavior of the input archive is to read sequentially starting with the first node and exploring its children. When a given NVP does not match the read in name for a node, the archive will search for that node at the current level and load it if it exists. After loading an out of order node, the archive will then proceed back to loading sequentially from its new position.

Consider this simple example where loading of some data is skipped:

// imagine the input file has someData(1-9) saved in order at the top level node
ar( someData1, someData2, someData3 ); // XML loads in the order it sees in the file
ar( cereal::make_nvp( "hello", someData6 ) ); // NVP given does not
// match expected NVP name, so we search
// for the given NVP and load that value
ar( someData7, someData8, someData9 ); // with no NVP given, loading resumes at its
// current location, proceeding sequentially

## Constructor & Destructor Documentation

cereal::JSONInputArchive::JSONInputArchive | ( | std::istream & | stream | ) |

inline

Construct, reading from the provided stream.

Parameters

  stream | The stream to read from

## Member Function Documentation

const char* cereal::JSONInputArchive::getNodeName | ( |  | ) | const

inline

Retrieves the current node name.

Returns
  nullptr if no name exists

void cereal::JSONInputArchive::loadBinaryValue | ( | void * | data,
|  | size_t | size,
|  | const char * | name = `nullptr`
| ) |  |

inline

Loads some binary data, encoded as a base64 string.

This will automatically start and finish a node to load the data, and can be called directly by users.

Note that this follows the same ordering rules specified in the class description in regards to loading in/out of order

void cereal::JSONInputArchive::startNode | ( |  | ) |

inline

Starts a new node, going into its proper iterator.

This places an iterator for the next node to be parsed onto the iterator stack. If the next node is an array, this will be a value iterator, otherwise it will be a member iterator.

By default our strategy is to start with the document root node and then recursively iterate through all children in the order they show up in the document. We don't need to know NVPs to do this; we'll just blindly load in the order things appear in.

If we were given an NVP, we will search for it if it does not match our the name of the next node that would normally be loaded. This functionality is provided by search().

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

- /build/libcereal-B5G4p0/libcereal-1.1.2/include/cereal/archives/json.hpp