cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Macros | Functions
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.This class allows to deserialize objects previously serialized using cmnSerializer. More...
 

Macros

#define _cmnDeSerializer_h
 

Functions

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

Detailed Description

Declaration of cmnDeSerializer and functions cmnDeSerializeRaw.

Macro Definition Documentation

#define _cmnDeSerializer_h

Function Documentation

template<class _elementType >
void cmnDeSerializeRaw ( std::istream &  inputStream,
_elementType &  data 
)
throw (std::runtime_error
)
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).

void cmnDeSerializeRaw ( std::istream &  inputStream,
std::string &  data 
)
throw (std::runtime_error
)
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).

template<class _elementType >
void cmnDeSerializeRaw ( std::istream &  inputStream,
std::vector< _elementType > &  data 
)
throw (std::runtime_error
)
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).

void cmnDeSerializeSizeRaw ( std::istream &  inputStream,
size_t &  data 
)
throw (std::runtime_error
)
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.