Emergency 2017 Dokumentation  v3.0.1
qsf::BinarySerializer Class Reference

Binary serializer class. More...

#include <BinarySerializer.h>

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.

Definition at line 35 of file BinarySerializer.h.

Member Enumeration Documentation

Enumerator
TOKEN_FLAG_NONE 
TOKEN_FLAG_TYPE 
TOKEN_FLAG_NAME 
TOKEN_ALL_FLAGS 

Definition at line 54 of file BinarySerializer.h.

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.

Definition at line 125 of file BinarySerializer-inl.h.

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

Return the stream format version.

Definition at line 130 of file BinarySerializer-inl.h.

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.

Definition at line 135 of file BinarySerializer-inl.h.

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.

Definition at line 41 of file BinarySerializer-inl.h.

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

Definition at line 21 of file BinarySerializer-inl.h.

bool qsf::BinarySerializer::isWriting ( ) const
inline

Return whether the serializer is currently writing/serializing.

Definition at line 46 of file BinarySerializer-inl.h.

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.

Definition at line 66 of file BinarySerializer-inl.h.

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

Definition at line 95 of file BinarySerializer-inl.h.

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

Definition at line 104 of file BinarySerializer-inl.h.

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)

Definition at line 52 of file BinarySerializer-inl.h.

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

Serialize or deserialize a value as another data type.

Definition at line 73 of file BinarySerializer-inl.h.

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

Definition at line 111 of file BinarySerializer-inl.h.

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

Definition at line 118 of file BinarySerializer-inl.h.

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

Definition at line 43 of file BinarySerializer.h.

const uint32 qsf::BinarySerializer::FLAG_EXTENDED_HEADER
static

Definition at line 45 of file BinarySerializer.h.

const uint32 qsf::BinarySerializer::FLAG_HAS_FORMAT_TYPE
static

Definition at line 46 of file BinarySerializer.h.

const uint32 qsf::BinarySerializer::FORMAT_VERSION_BITMASK
static

Definition at line 49 of file BinarySerializer.h.

const uint8 qsf::BinarySerializer::INTERNAL_VERSION
static

Definition at line 51 of file BinarySerializer.h.

const uint32 qsf::BinarySerializer::INTERNAL_VERSION_BITMASK
static

Definition at line 48 of file BinarySerializer.h.

const uint8 qsf::BinarySerializer::INTERNAL_VERSION_READABLE[]
static

Definition at line 52 of file BinarySerializer.h.


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