Emergency 20 Dokumentation  4.1.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
qsf::BinarySerializer Class Reference

Binary serializer class. More...

#include <BinarySerializer.h>

Inheritance diagram for qsf::BinarySerializer:
Inheritance graph
[legend]
Collaboration diagram for qsf::BinarySerializer:
Collaboration graph
[legend]

Classes

struct  DataBlockInfo
 

Public Types

enum  TokenMode { TOKEN_FLAG_NONE = 0, TOKEN_FLAG_TYPE = 1, TOKEN_FLAG_NAME = 2, TOKEN_ALL_FLAGS = 3 }
 

Public Member Functions

 BinarySerializer (std::istream &stream)
 Constructor: Open for reading, i.e. deserialization. More...
 
 BinarySerializer (std::ostream &stream, TokenMode tokenMode, uint16 formatVersion=1, const std::string &formatType="")
 Constructor: Open for writing, i.e. serialization. More...
 
virtual ~BinarySerializer ()
 Destructor. More...
 
bool isReading () const
 Return whether the serializer is currently reading/deserializing. More...
 
bool isWriting () const
 Return whether the serializer is currently writing/serializing. More...
 
std::istream & getInputStream () const
 Return input stream the serializer operates on. More...
 
std::ostream & getOutputStream () const
 Return input stream the serializer operates on. More...
 
template<typename T >
void serialize (T &value, const char *name=nullptr)
 Serialize or deserialize a value with optional name (for usage as additional security token) More...
 
template<typename T >
BinarySerializeroperator& (T &value)
 Short version of (de-)serialization by an operator. More...
 
template<typename TARGETTYPE , typename ORIGINALTYPE >
void serializeAs (ORIGINALTYPE &value, const char *name=nullptr)
 Serialize or deserialize a value as another data type. More...
 
template<typename T >
read (const char *name=nullptr)
 Deserialize a value with optional name (for usage as additional security token) More...
 
template<typename T >
void read (T &value, const char *name=nullptr)
 Deserialize a value with optional name (for usage as additional security token) More...
 
template<typename T >
void write (const T &value, const char *name=nullptr)
 Serialize a value with optional name (for usage as additional security token) More...
 
template<typename TARGETTYPE , typename ORIGINALTYPE >
void writeAs (const ORIGINALTYPE &value, const char *name=nullptr)
 Serialize a value with optional name (for usage as additional security token) More...
 
void serializeRawBlock (void *address, uint32 bytes)
 Serialize or deserialize a raw block of memory. More...
 
void serializeRawBlock (void *address, uint32 bytes, bool checkEndianness)
 Serialize or deserialize a raw block of memory. More...
 
void readRawBlock (void *address, uint32 bytes)
 Deserialize a raw block of memory. More...
 
void readRawBlock (void *address, uint32 bytes, bool checkEndianness)
 Deserialize a raw block of memory. More...
 
void writeRawBlock (const void *address, uint32 bytes)
 Serialize a raw block of memory. More...
 
void writeRawBlock (const void *address, uint32 bytes, bool checkEndianness)
 Serialize a raw block of memory. More...
 
void skip (uint32 bytes)
 Skip a block of memory when reading. More...
 
void beginDataBlock (DataBlockInfo &dataBlockInfo)
 Serialize or deserialize the begin of a data block. More...
 
void endDataBlock (DataBlockInfo &dataBlockInfo)
 Serialize or deserialize the end of the given data block. More...
 
void jumpToBeginOfDataBlock (DataBlockInfo &dataBlockInfo)
 Move the read position to the start of the given data block. More...
 
void jumpToEndOfDataBlock (DataBlockInfo &dataBlockInfo)
 Move the read position to the end of the given data block. More...
 
const std::string & getFormatType () const
 Return the stream format type. More...
 
uint16 getFormatVersion () const
 Return the stream format version. More...
 
uint8 getInternalVersion () const
 Return the internal stream format version. More...
 

Static Public Member Functions

template<int N, typename T >
static bool isVersionSupported (const T version, const T(&supportedVersions)[N])
 

Static Public Attributes

static const bool DEFAULT_IS_BIG_ENDIAN
 "true" if big endian is default endianness, i.e. byte order won't be reversed More...
 
static const uint32 FLAG_EXTENDED_HEADER
 
static const uint32 FLAG_HAS_FORMAT_TYPE
 
static const uint32 INTERNAL_VERSION_BITMASK
 
static const uint32 FORMAT_VERSION_BITMASK
 
static const uint8 INTERNAL_VERSION
 
static const uint8 INTERNAL_VERSION_READABLE []
 

Additional Inherited Members

- Protected Member Functions inherited from qsf::Serializer
 Serializer ()
 Default constructor. More...
 
virtual ~Serializer ()
 Destructor. More...
 

Detailed Description

Binary serializer class.

Member Enumeration Documentation

Enumerator
TOKEN_FLAG_NONE 
TOKEN_FLAG_TYPE 
TOKEN_FLAG_NAME 
TOKEN_ALL_FLAGS 

Constructor & Destructor Documentation

qsf::BinarySerializer::BinarySerializer ( std::istream &  stream)

Constructor: Open for reading, i.e. deserialization.

qsf::BinarySerializer::BinarySerializer ( std::ostream &  stream,
TokenMode  tokenMode,
uint16  formatVersion = 1,
const std::string &  formatType = "" 
)

Constructor: Open for writing, i.e. serialization.

virtual qsf::BinarySerializer::~BinarySerializer ( )
virtual

Destructor.

Member Function Documentation

void qsf::BinarySerializer::beginDataBlock ( DataBlockInfo dataBlockInfo)

Serialize or deserialize the begin of a data block.

void qsf::BinarySerializer::endDataBlock ( DataBlockInfo dataBlockInfo)

Serialize or deserialize the end of the given data block.

const std::string & qsf::BinarySerializer::getFormatType ( ) const
inline

Return the stream format type.

uint16 qsf::BinarySerializer::getFormatVersion ( ) const
inline

Return the stream format version.

std::istream& qsf::BinarySerializer::getInputStream ( ) const

Return input stream the serializer operates on.

Note
  • Throws an exception in case the serializer is not in read mode
uint8 qsf::BinarySerializer::getInternalVersion ( ) const
inline

Return the internal stream format version.

std::ostream& qsf::BinarySerializer::getOutputStream ( ) const

Return input stream the serializer operates on.

Note
  • Throws an exception in case the serializer is not in read mode
bool qsf::BinarySerializer::isReading ( ) const
inline

Return whether the serializer is currently reading/deserializing.

template<int N, typename T >
bool qsf::BinarySerializer::isVersionSupported ( const T  version,
const T(&)  supportedVersions[N] 
)
inlinestatic
bool qsf::BinarySerializer::isWriting ( ) const
inline

Return whether the serializer is currently writing/serializing.

void qsf::BinarySerializer::jumpToBeginOfDataBlock ( DataBlockInfo dataBlockInfo)

Move the read position to the start of the given data block.

void qsf::BinarySerializer::jumpToEndOfDataBlock ( DataBlockInfo dataBlockInfo)

Move the read position to the end of the given data block.

template<typename T >
BinarySerializer & qsf::BinarySerializer::operator& ( T &  value)

Short version of (de-)serialization by an operator.

template<typename T >
T qsf::BinarySerializer::read ( const char *  name = nullptr)

Deserialize a value with optional name (for usage as additional security token)

Todo:
  • TODO(fw): May be optimized internally
template<typename T >
void qsf::BinarySerializer::read ( T &  value,
const char *  name = nullptr 
)

Deserialize a value with optional name (for usage as additional security token)

Todo:
  • TODO(fw): May be optimized internally
void qsf::BinarySerializer::readRawBlock ( void *  address,
uint32  bytes 
)

Deserialize a raw block of memory.

void qsf::BinarySerializer::readRawBlock ( void *  address,
uint32  bytes,
bool  checkEndianness 
)

Deserialize a raw block of memory.

template<typename T >
void qsf::BinarySerializer::serialize ( T &  value,
const char *  name = nullptr 
)

Serialize or deserialize a value with optional name (for usage as additional security token)

template<typename TARGETTYPE , typename ORIGINALTYPE >
void qsf::BinarySerializer::serializeAs ( ORIGINALTYPE &  value,
const char *  name = nullptr 
)

Serialize or deserialize a value as another data type.

void qsf::BinarySerializer::serializeRawBlock ( void *  address,
uint32  bytes 
)

Serialize or deserialize a raw block of memory.

void qsf::BinarySerializer::serializeRawBlock ( void *  address,
uint32  bytes,
bool  checkEndianness 
)

Serialize or deserialize a raw block of memory.

void qsf::BinarySerializer::skip ( uint32  bytes)

Skip a block of memory when reading.

template<typename T >
void qsf::BinarySerializer::write ( const T &  value,
const char *  name = nullptr 
)

Serialize a value with optional name (for usage as additional security token)

Todo:
  • TODO(fw): May be optimized internally
template<typename TARGETTYPE , typename ORIGINALTYPE >
void qsf::BinarySerializer::writeAs ( const ORIGINALTYPE &  value,
const char *  name = nullptr 
)

Serialize a value with optional name (for usage as additional security token)

Todo:
  • TODO(fw): May be optimized internally
void qsf::BinarySerializer::writeRawBlock ( const void *  address,
uint32  bytes 
)

Serialize a raw block of memory.

void qsf::BinarySerializer::writeRawBlock ( const void *  address,
uint32  bytes,
bool  checkEndianness 
)

Serialize a raw block of memory.

Member Data Documentation

const bool qsf::BinarySerializer::DEFAULT_IS_BIG_ENDIAN
static

"true" if big endian is default endianness, i.e. byte order won't be reversed

const uint32 qsf::BinarySerializer::FLAG_EXTENDED_HEADER
static
const uint32 qsf::BinarySerializer::FLAG_HAS_FORMAT_TYPE
static
const uint32 qsf::BinarySerializer::FORMAT_VERSION_BITMASK
static
const uint8 qsf::BinarySerializer::INTERNAL_VERSION
static
const uint32 qsf::BinarySerializer::INTERNAL_VERSION_BITMASK
static
const uint8 qsf::BinarySerializer::INTERNAL_VERSION_READABLE[]
static

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