cereal_fwd
Fork of cereal library adding archive supporting forward compatibility
Classes | Public Member Functions | List of all members
cereal::ExtendableBinaryOutputArchive Class Reference

An output archive designed to save data in a portable binary representation with forward compatibility support. More...

#include </home/breiker/code/git/cereal_fwd_github/include/cereal/archives/extendable_binary.hpp>

Inheritance diagram for cereal::ExtendableBinaryOutputArchive:
cereal::OutputArchive< ExtendableBinaryOutputArchive, Flags::ForwardSupport > cereal::detail::OutputArchiveBase

Classes

class  Options
 A class containing various advanced options for the ExtendableBinaryOutput archive. More...
 

Public Member Functions

 ExtendableBinaryOutputArchive (std::ostream &stream, Options const &options=Options::Default())
 Construct, outputting to the provided stream. More...
 
template<std::size_t DataSize>
void saveBinary (const void *data, std::size_t size)
 Writes size bytes of data to the output stream. More...
 
void saveBinaryNoSwap (const void *data, std::size_t size)
 Writes size bytes of data to the output stream without any byte order swapping. More...
 
template<std::size_t DataSize>
void saveBinarySingle (const void *data, std::size_t size)
 Writes size bytes of data to the output stream. More...
 
template<class T >
void saveVarint (T v)
 Writes varint to the stream. More...
 
void saveClassVersion (std::uint32_t version)
 Store temporarily class version to be saved later. More...
 
void saveObjectId (std::uint32_t objectId_)
 Store temporarily object id for shared objects to be saved later. More...
 
void savePointerValidityTag (bool)
 Store temporarily validity of pointer (!=nullptr) to be saved later. More...
 
void savePolymorphicId (std::int32_t polymorphicId_)
 Store temporarily polymorphic id of type to be saved later. More...
 
void savePolymorphicName (const std::string &name)
 Store temporarily polymorphic name of type to be saved later. More...
 
void saveObjectBeginning ()
 Indicate beginning of new object saving. More...
 
void savingOtherField ()
 Indicate that some field (not beginning of new object) is being saved. More...
 
void saveObjectEnd ()
 End of object saving. Called in prologue for objects. More...
 
- Public Member Functions inherited from cereal::OutputArchive< ExtendableBinaryOutputArchive, Flags::ForwardSupport >
 OutputArchive (ExtendableBinaryOutputArchive *const derived)
 Construct the output archive. More...
 
OutputArchive & operator= (OutputArchive const &)=delete
 
ExtendableBinaryOutputArchive & operator() (Types &&... args)
 Serializes all passed in data. More...
 
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...
 
bool wasSerialized () const
 Indicates if last field was saved. More...
 
ExtendableBinaryOutputArchive & operator& (T &&arg)
 Serializes passed in data. More...
 
ExtendableBinaryOutputArchive & operator<< (T &&arg)
 Serializes passed in data. More...
 
- Public Member Functions inherited from cereal::detail::OutputArchiveBase
 OutputArchiveBase (OutputArchiveBase &&) CEREAL_NOEXCEPT
 
OutputArchiveBase & operator= (OutputArchiveBase &&) CEREAL_NOEXCEPT
 

Additional Inherited Members

- Public Types inherited from cereal::OutputArchive< ExtendableBinaryOutputArchive, Flags::ForwardSupport >
using is_saving = std::true_type
 indicates if archive is used for saving
 
using is_loading = std::false_type
 indicates if archive is used for loading
 

Detailed Description

An output archive designed to save data in a portable binary representation with forward compatibility support.

This archive outputs data to a stream in an compact binary representation with additional metadata needed to support forward and backward compatibility.

This archive will save data in little endian order by default. Byte order of archive can be set by setting option during construction of archive.

When using a binary archive and a file stream, you must use the std::ios::binary format flag to avoid having your data altered inadvertently.

Constructor & Destructor Documentation

◆ ExtendableBinaryOutputArchive()

cereal::ExtendableBinaryOutputArchive::ExtendableBinaryOutputArchive ( std::ostream &  stream,
Options const &  options = Options::Default() 
)
inline

Construct, outputting to the provided stream.

Parameters
streamThe stream to output to. Should be opened with std::ios::binary flag.
optionsThe ExtendableBinary specific options to use. See the Options struct for the values of default parameters

Member Function Documentation

◆ saveBinary()

template<std::size_t DataSize>
void cereal::ExtendableBinaryOutputArchive::saveBinary ( const void *  data,
std::size_t  size 
)
inline

Writes size bytes of data to the output stream.

Swaps byte order in DataSize chunks if needed. Throws Exception if size bytes cannot be writen to stream.

◆ saveBinaryNoSwap()

void cereal::ExtendableBinaryOutputArchive::saveBinaryNoSwap ( const void *  data,
std::size_t  size 
)
inline

Writes size bytes of data to the output stream without any byte order swapping.

Throws Exception if size bytes cannot be writen to stream.

◆ saveBinarySingle()

template<std::size_t DataSize>
void cereal::ExtendableBinaryOutputArchive::saveBinarySingle ( const void *  data,
std::size_t  size 
)
inline

Writes size bytes of data to the output stream.

Save least significant size bytes of type which sizeof is DataSize. size has to be less than DataSize. Used to store integers using minimal number of bytes. Throws Exception if size bytes cannot be writen to stream.

◆ saveClassVersion()

void cereal::ExtendableBinaryOutputArchive::saveClassVersion ( std::uint32_t  version)
inline

Store temporarily class version to be saved later.

Class version is saved when saveObjectData() is called.

◆ saveObjectBeginning()

void cereal::ExtendableBinaryOutputArchive::saveObjectBeginning ( )
inline

Indicate beginning of new object saving.

If metadata of previous object was not saved it's saved here.

◆ saveObjectEnd()

void cereal::ExtendableBinaryOutputArchive::saveObjectEnd ( )
inline

End of object saving. Called in prologue for objects.

Writes object metadata to stream if there wasn't any field in this object, otherwise saves end of object marker.

◆ saveObjectId()

void cereal::ExtendableBinaryOutputArchive::saveObjectId ( std::uint32_t  objectId_)
inline

Store temporarily object id for shared objects to be saved later.

Object id is saved when saveObjectData() is called.

◆ savePointerValidityTag()

void cereal::ExtendableBinaryOutputArchive::savePointerValidityTag ( bool  )
inline

Store temporarily validity of pointer (!=nullptr) to be saved later.

Pointer validity is saved when saveObjectData() is called.

◆ savePolymorphicId()

void cereal::ExtendableBinaryOutputArchive::savePolymorphicId ( std::int32_t  polymorphicId_)
inline

Store temporarily polymorphic id of type to be saved later.

Polymorphic id is saved when saveObjectData() is called.

◆ savePolymorphicName()

void cereal::ExtendableBinaryOutputArchive::savePolymorphicName ( const std::string &  name)
inline

Store temporarily polymorphic name of type to be saved later.

Polymorphic name is saved when saveObjectData() is called.

◆ saveVarint()

template<class T >
void cereal::ExtendableBinaryOutputArchive::saveVarint ( T  v)
inline

Writes varint to the stream.

Based on Protocol Buffers usage. Saves integer in variable length encoding format. For every byte most significant bit is used to denote if next byte is part of integer. If most significant bit is lit next byte is part of integer. Only unsigned integers are supported.

◆ savingOtherField()

void cereal::ExtendableBinaryOutputArchive::savingOtherField ( )
inline

Indicate that some field (not beginning of new object) is being saved.

If metadata of outer structure was not saved it is saved now.


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