NDDEM
Classes | Public Member Functions | Private Attributes | List of all members
cereal::PortableBinaryOutputArchive Class Reference

An output archive designed to save data in a compact binary representation portable over different architectures. More...

#include <portable_binary.hpp>

+ Inheritance diagram for cereal::PortableBinaryOutputArchive:

Classes

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

Public Member Functions

 PortableBinaryOutputArchive (std::ostream &stream, Options const &options=Options::Default())
 Construct, outputting to the provided stream. More...
 
 ~PortableBinaryOutputArchive () CEREAL_NOEXCEPT=default
 
template<std::streamsize DataSize>
void saveBinary (const void *data, std::streamsize size)
 Writes size bytes of data to the output stream. More...
 
- Public Member Functions inherited from cereal::OutputArchive< PortableBinaryOutputArchive, AllowEmptyClassElision >
 OutputArchive (PortableBinaryOutputArchive *const derived)
 Construct the output archive. More...
 
OutputArchiveoperator= (OutputArchive const &)=delete
 
PortableBinaryOutputArchiveoperator() (Types &&... args)
 Serializes all passed in data. More...
 
void serializeDeferments ()
 Serializes any data marked for deferment using defer. More...
 
std::uint32_t registerSharedPointer (const std::shared_ptr< const void > &sharedPointer)
 Registers a shared pointer with the archive. More...
 
std::uint32_t registerPolymorphicType (char const *name)
 Registers a polymorphic type name with the archive. More...
 
PortableBinaryOutputArchiveoperator& (T &&arg)
 Serializes passed in data. More...
 
PortableBinaryOutputArchiveoperator<< (T &&arg)
 Serializes passed in data. More...
 
- Public Member Functions inherited from cereal::detail::OutputArchiveBase
 OutputArchiveBase ()=default
 
 OutputArchiveBase (OutputArchiveBase &&) CEREAL_NOEXCEPT
 
OutputArchiveBaseoperator= (OutputArchiveBase &&) CEREAL_NOEXCEPT
 
virtual ~OutputArchiveBase () CEREAL_NOEXCEPT=default
 

Private Attributes

std::ostream & itsStream
 
const uint8_t itsConvertEndianness
 If set to true, we will need to swap bytes upon saving. More...
 

Additional Inherited Members

- Public Types inherited from cereal::OutputArchive< PortableBinaryOutputArchive, AllowEmptyClassElision >
using is_loading = std::false_type
 Indicates this archive is not intended for loading. More...
 
using is_saving = std::true_type
 Indicates this archive is intended for saving. More...
 

Detailed Description

An output archive designed to save data in a compact binary representation portable over different architectures.

This archive outputs data to a stream in an extremely compact binary representation with as little extra metadata as possible.

This archive will record the endianness of the data as well as the desired in/out endianness and assuming that the user takes care of ensuring serialized types are the same size across machines, is portable over different architectures.

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.

Warning
This archive has not been thoroughly tested across different architectures. Please report any issues, optimizations, or feature requests at the project github.

Constructor & Destructor Documentation

◆ PortableBinaryOutputArchive()

cereal::PortableBinaryOutputArchive::PortableBinaryOutputArchive ( 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 PortableBinary specific options to use. See the Options struct for the values of default parameters

◆ ~PortableBinaryOutputArchive()

cereal::PortableBinaryOutputArchive::~PortableBinaryOutputArchive ( )
default

Member Function Documentation

◆ saveBinary()

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

Writes size bytes of data to the output stream.

Member Data Documentation

◆ itsConvertEndianness

const uint8_t cereal::PortableBinaryOutputArchive::itsConvertEndianness
private

If set to true, we will need to swap bytes upon saving.

◆ itsStream

std::ostream& cereal::PortableBinaryOutputArchive::itsStream
private

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