Savarese Software Research Corporation
Packer< Archive > Class Template Reference

Packer serializes objects into ssrc::spread::detail::ByteBuffer instances (usually a ssrc::spread::Message instance). More...

#include <serialization.h>

Public Types

typedef detail::char_array_sink  sink_type
 
typedef detail::char_array_sink_buffer  sink_buffer
 
typedef Archive  output_archive
 

Public Member Functions

template<typename T >
unsigned int  pack (const T &obj, ByteBuffer &buffer, const unsigned int archive_flags=boost::archive::no_header|boost::archive::no_codecvt|boost::archive::no_tracking) SSRC_DECL_THROW(boost
  Serializes an object into a buffer. More...
 

Protected Attributes

sink_type  _sink
 
sink_buffer  _out_buf
 

Detailed Description

template<typename Archive>
class Packer< Archive >

Packer serializes objects into ssrc::spread::detail::ByteBuffer instances (usually a ssrc::spread::Message instance).

Each object type must have a Boost serialize function or method defined (or load and save).

Parameters
Archive The archive type to use for serialization.

Definition at line 150 of file serialization.h.

Member Typedef Documentation

template<typename Archive >
typedef Archive Packer< Archive >::output_archive

Definition at line 154 of file serialization.h.

template<typename Archive >
typedef detail::char_array_sink_buffer Packer< Archive >::sink_buffer

Definition at line 153 of file serialization.h.

template<typename Archive >
typedef detail::char_array_sink Packer< Archive >::sink_type

Definition at line 152 of file serialization.h.

Member Function Documentation

template<typename Archive >
template<typename T >
unsigned int Packer< Archive >::pack ( const T &  obj,
ByteBuffer &  buffer,
const unsigned int  archive_flags = boost::archive::no_header | boost::archive::no_codecvt | boost::archive::no_tracking 
)
inline

Serializes an object into a buffer.

The type of the object is automatically inferred by the compiler. The object write starts at the current buffer offset. After the object is serialized, the buffer size is adjusted and its write offset advanced to the end of the buffer. The buffer must have enough room to hold the data written or an exception will be thrown (std::ios_base::failure).

Parameters
obj The object to serialize.
buffer The buffer that will store the object.
archive_flags Boost archive constructor flags.
Returns
The number of bytes written.
Exceptions
boost::archive::archive_exception If there is an archive writing error.
std::ios_base::failure If the stream buffer fails, most likely because the buffer doesn't have enough room to hold the data.

Definition at line 181 of file serialization.h.

References detail::array_device_adapter< Ch, mode_type >::init(), and detail::char_array_streambuf< DeviceAdapter >::open().

Member Data Documentation

template<typename Archive >
sink_buffer Packer< Archive >::_out_buf
protected

Definition at line 158 of file serialization.h.

template<typename Archive >
sink_type Packer< Archive >::_sink
protected

Definition at line 157 of file serialization.h.


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

Savarese Software Research Corporation
Copyright © 2006-2012 Savarese Software Research Corporation. All rights reserved.