cisst-saw
Loading...
Searching...
No Matches
cmnDeSerializer.h File Reference

Declaration of cmnDeSerializer and functions cmnDeSerializeRaw. More...

#include <cisstCommon/cmnPortability.h>
#include <cisstCommon/cmnTypeTraits.h>
#include <cisstCommon/cmnGenericObject.h>
#include <cisstCommon/cmnClassRegister.h>
#include <cisstCommon/cmnThrow.h>
#include <cisstCommon/cmnAssert.h>
#include <string>
#include <fstream>
#include <map>
#include <cstddef>
#include <cisstCommon/cmnExport.h>

Go to the source code of this file.

Classes

class  cmnDeSerializeRawImpl< _elementType, bool >
class  cmnDeSerializeRawImpl< _elementType, true >
class  cmnDeSerializer
 De-serialization utility class. More...

Macros

#define _cmnDeSerializer_h

Functions

template<class _elementType>
void cmnDeSerializeRaw (std::istream &inputStream, _elementType &data) CISST_THROW(std
void cmnDeSerializeSizeRaw (std::istream &inputStream, size_t &data) CISST_THROW(std
void cmnDeSerializeRaw (std::istream &inputStream, std::string &data) CISST_THROW(std
template<class _elementType>
void cmnDeSerializeRaw (std::istream &inputStream, std::vector< _elementType > &data) CISST_THROW(std

Detailed Description

Declaration of cmnDeSerializer and functions cmnDeSerializeRaw.

Macro Definition Documentation

◆ _cmnDeSerializer_h

#define _cmnDeSerializer_h

Function Documentation

◆ cmnDeSerializeRaw() [1/3]

template<class _elementType>
void cmnDeSerializeRaw ( std::istream & inputStream,
_elementType & data )
inline

De-serialization helper function for a basic type. If the type is derived from cmnGenericObject, it just calls the DeSerializeRaw member function. Otherwise, it performs a cast to char pointer (char *) using reinterpret_cast and then replaces the data with the result of read from the input stream. If the read operation fails, an exception is thrown (std::runtime_error).

◆ cmnDeSerializeRaw() [2/3]

void cmnDeSerializeRaw ( std::istream & inputStream,
std::string & data )
inline

De-serialization helper function for an STL string. This function first de-serializes the string size, resize the string and then replaces its content with the result of read from the input stream. If the read operation fails, an exception is thrown (std::runtime_error).

◆ cmnDeSerializeRaw() [3/3]

template<class _elementType>
void cmnDeSerializeRaw ( std::istream & inputStream,
std::vector< _elementType > & data )
inline

De-serialization helper function for an STL vector. This function first de-serializes the vector size, resizes the vector and then alls cmnDeSerializeRaw for each element of the vector. This assumes that cmnDeSerializeRaw is defined for the element type. If the read operation fails, an exception is thrown (std::runtime_error).

◆ cmnDeSerializeSizeRaw()

void cmnDeSerializeSizeRaw ( std::istream & inputStream,
size_t & data )
inline

De-serialization helper function for STL size object. This function converts a serialized size (unsigned long long int) to the host size_t object. This operation is required for all size_t as the writer/reader can be both 32 bits or 64 bits programs.

This function should be use to implement the DeSerializeRaw method of classes derived from cmnGenericObject.