cereal
A C++11 library for serialization
 All Classes Files Functions Variables Typedefs Enumerations Groups
Public Member Functions | List of all members
cereal::JSONOutputArchive Class Reference

An output archive designed to save data to JSON. More...

#include <cereal/archives/json.hpp>

Inheritance diagram for cereal::JSONOutputArchive:
cereal::OutputArchive< JSONOutputArchive > cereal::detail::OutputArchiveBase

Public Member Functions

 JSONOutputArchive (std::ostream &stream)
 Construct, outputting to the provided stream. More...
 
 ~JSONOutputArchive ()
 Destructor, flushes the JSON.
 
void saveValue (bool b)
 
void saveValue (int i)
 
void saveValue (unsigned u)
 
void saveValue (int64_t i64)
 
void saveValue (uint64_t u64)
 
void saveValue (double d)
 
void saveValue (std::string const &s)
 
void saveValue (char const *s)
 
void saveNull ()
 
void writeName ()
 
void rawString (std::string const &s)
 
void startNode ()
 Creates a new node that is a child of the node at the top of the stack. More...
 
void finishNode ()
 Designates the most recently added node as finished.
 
void setNextName (const char *name)
 Sets the name for the next node created with startNode.
 
void saveBinaryValue (const void *data, size_t size, const char *name=nullptr)
 Saves some binary data, encoded as a base64 string, with an optional name. More...
 
void setOutputType (bool outputType)
 
- Public Member Functions inherited from cereal::OutputArchive< JSONOutputArchive >
 OutputArchive (JSONOutputArchive *const self)
 Construct the output archive. More...
 
JSONOutputArchiveoperator() (Types &&...args)
 Serializes all passed in data.
 
std::uint32_t registerSharedPointer (void const *addr)
 Registers a shared pointer with the archive. More...
 
std::uint32_t registerPolymorphicType (char const *name)
 Registers a polymorphic type name with the archive. More...
 

Detailed Description

An output archive designed to save data to JSON.

Note
Not working yet!

Constructor & Destructor Documentation

cereal::JSONOutputArchive::JSONOutputArchive ( std::ostream &  stream)
inline

Construct, outputting to the provided stream.

Parameters
streamThe stream to output to. Can be a stringstream, a file stream, or even cout!

Member Function Documentation

void cereal::JSONOutputArchive::saveBinaryValue ( const void *  data,
size_t  size,
const char *  name = nullptr 
)
inline

Saves some binary data, encoded as a base64 string, with an optional name.

This will create a new node, optionally named, and insert a value that consists of the data encoded as a base64 string

void cereal::JSONOutputArchive::startNode ( )
inline

Creates a new node that is a child of the node at the top of the stack.

Nodes will be given a name that has either been pre-set by a name value pair, or generated based upon a counter unique to the parent node.

The node will then be pushed onto the node stack.


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