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

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

#include <cereal/archives/xml.hpp>

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

Classes

struct  NodeInfo
 A struct that contains metadata about a node. More...
 

Public Member Functions

 XMLOutputArchive (std::ostream &stream, size_t precision=10, bool outputType=false)
 Construct, outputting to the provided stream. More...
 
 ~XMLOutputArchive ()
 Destructor, flushes the XML.
 
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.
 
template<class T >
void saveValue (T const &value)
 Saves some data, encoded as a string. More...
 
void saveValue (uint8_t const &value)
 Overload for uint8_t prevents them from being serialized as characters.
 
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...
 
template<class T >
void insertType ()
 Causes the type to be appended to the most recently made node if output type is set to true.
 
- Public Member Functions inherited from cereal::OutputArchive< XMLOutputArchive >
 OutputArchive (XMLOutputArchive *const self)
 Construct the output archive. More...
 
XMLOutputArchiveoperator() (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 XML.

Constructor & Destructor Documentation

cereal::XMLOutputArchive::XMLOutputArchive ( std::ostream &  stream,
size_t  precision = 10,
bool  outputType = false 
)
inline

Construct, outputting to the provided stream.

Parameters
streamThe stream to output to. Can be a stringstream, a file stream, or even cout!
precisionThe precision for floating point output
outputTypeControls whether type information will be printed in attributes

Member Function Documentation

void cereal::XMLOutputArchive::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

template<class T >
void cereal::XMLOutputArchive::saveValue ( T const &  value)
inline

Saves some data, encoded as a string.

The data will be be named with the most recent name if one exists, otherwise it will be given some default delimited value that depends upon the parent node

void cereal::XMLOutputArchive::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: