28 #ifndef _cmnSerializer_h
29 #define _cmnSerializer_h
46 template <
class _elementType,
bool>
50 static void SerializeRaw(std::ostream & outputStream,
const _elementType & data)
throw (std::runtime_error)
52 outputStream.write(reinterpret_cast<const char *>(&data),
sizeof(_elementType));
53 if (outputStream.fail()) {
54 cmnThrow(
"cmnSerializeRaw(_elementType): Error occured with std::ostream::write");
60 template <
class _elementType>
64 static void SerializeRaw(std::ostream & outputStream,
const _elementType & data)
throw (std::runtime_error)
66 data.SerializeRaw(outputStream);
77 template <
class _elementType>
78 inline void cmnSerializeRaw(std::ostream & outputStream,
const _elementType & data)
79 throw (std::runtime_error)
82 impl::SerializeRaw(outputStream, data);
94 throw (std::runtime_error)
96 unsigned long long int dataToSend = data;
107 throw (std::runtime_error)
111 outputStream.write(data.c_str(), size *
sizeof(std::string::value_type));
112 if (outputStream.fail()) {
113 cmnThrow(
"cmnSerializeRaw(std::string): Error occured with std::ostream::write");
124 template <
class _elementType>
125 inline void cmnSerializeRaw(std::ostream & outputStream,
const std::vector<_elementType> & data)
126 throw (std::runtime_error)
130 for (
size_t i = 0; i < size; i++) {
132 if (outputStream.fail()) {
133 cmnThrow(
"cmnSerializeRaw(std::vector<_elementType>): Error occured with std::ostream::write");
209 void Serialize(
const cmnGenericObject &
object,
const bool serializeObject =
true);
240 std::ostream & OutputStream;
243 typedef std::list<const cmnClassServicesBase *> ServicesContainerType;
244 typedef ServicesContainerType::const_iterator const_iterator;
245 typedef ServicesContainerType::iterator iterator;
247 ServicesContainerType ServicesContainer;
255 #endif // _cmnSerialize_h
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
static void SerializeRaw(std::ostream &outputStream, const _elementType &data)
Definition: cmnSerializer.h:64
Portability across compilers and operating systems tools.
void cmnSerializeSizeRaw(std::ostream &outputStream, const size_t &data)
Definition: cmnSerializer.h:93
size_t size_type
Definition: vctContainerTraits.h:35
Base class for high level objects.
Definition: cmnGenericObject.h:51
Class register definitions and log macros.
Serialization utility class.This class allows to serialize objects of different types (all derived fr...
Definition: cmnSerializer.h:164
static void SerializeRaw(std::ostream &outputStream, const _elementType &data)
Definition: cmnSerializer.h:50
Macros to export the symbols of cisstCommon (in a Dll).
Declaration of the class cmnTypeTraits.
Defines cmnGenericObject.
Definition: cmnSerializer.h:47
void cmnSerializeRaw(std::ostream &outputStream, const _elementType &data)
Definition: cmnSerializer.h:78
#define CMN_DECLARE_SERVICES(hasDynamicCreation, lod)
Definition: cmnClassRegisterMacros.h:116
#define cmnThrow(a)
Definition: MinimalCmn.h:4
unsigned long long int TypeId
Definition: cmnSerializer.h:172
Base class for class services.
Definition: cmnClassServicesBase.h:45
Declaration of the template function cmnThrow.
const int CMN_NO_DYNAMIC_CREATION
Definition: cmnClassRegisterMacros.h:328
#define CMN_DECLARE_SERVICES_INSTANTIATION(className)
Definition: cmnClassRegisterMacros.h:202
#define CMN_LOG_ALLOW_DEFAULT
Definition: cmnLogLoD.h:76