26#ifndef _cmnSerializer_h
27#define _cmnSerializer_h
44template <
class _elementType,
bool>
50 outputStream.write(
reinterpret_cast<const char *
>(&data),
sizeof(_elementType));
51 if (outputStream.fail()) {
52 cmnThrow(
"cmnSerializeRaw(_elementType): Error occured with std::ostream::write");
58template <
class _elementType>
64 data.SerializeRaw(outputStream);
75template <
class _elementType>
76inline void cmnSerializeRaw(std::ostream & outputStream,
const _elementType & data)
80 impl::SerializeRaw(outputStream, data);
94 unsigned long long int dataToSend = data;
107 const std::string::size_type
size = data.size();
109 outputStream.write(data.c_str(),
size *
sizeof(std::string::value_type));
110 if (outputStream.fail()) {
111 cmnThrow(
"cmnSerializeRaw(std::string): Error occured with std::ostream::write");
122template <
class _elementType>
123inline void cmnSerializeRaw(std::ostream & outputStream,
const std::vector<_elementType> & data)
126 const typename std::vector<_elementType>::size_type
size = data.size();
128 for (
size_t i = 0; i <
size; i++) {
130 if (outputStream.fail()) {
131 cmnThrow(
"cmnSerializeRaw(std::vector<_elementType>): Error occured with std::ostream::write");
238 std::ostream & OutputStream;
241 typedef std::list<const cmnClassServicesBase *> ServicesContainerType;
242 typedef ServicesContainerType::const_iterator const_iterator;
243 typedef ServicesContainerType::iterator iterator;
245 ServicesContainerType ServicesContainer;
Base class for class services.
Definition cmnClassServicesBase.h:46
Base class for high level objects.
Definition cmnGenericObject.h:53
static void SerializeRaw(std::ostream &outputStream, const _elementType &data) CISST_THROW(std
Definition cmnSerializer.h:62
Definition cmnSerializer.h:46
static void SerializeRaw(std::ostream &outputStream, const _elementType &data) CISST_THROW(std
Definition cmnSerializer.h:48
Serialization utility class.
Definition cmnSerializer.h:162
void Serialize(const cmnGenericObject &object, const bool serializeObject=true)
unsigned long long int TypeId
Definition cmnSerializer.h:170
void SerializeServices(const cmnClassServicesBase *servicesPointer)
cmnSerializer(std::ostream &outputStream)
bool ServicesSerialized(const cmnClassServicesBase *servicesPointer) const
Class register definitions and log macros.
#define CMN_DECLARE_SERVICES_INSTANTIATION(className)
Definition cmnClassRegisterMacros.h:199
const int CMN_NO_DYNAMIC_CREATION
Definition cmnClassRegisterMacros.h:325
Macros to export the symbols of cisstCommon (in a Dll).
#define CISST_EXPORT
Definition cmnExportMacros.h:50
Defines cmnGenericObject.
#define CMN_LOG_ALLOW_DEFAULT
Definition cmnLogLoD.h:76
Portability across compilers and operating systems tools.
#define CISST_THROW(exceptionParameter)
Somewhat portable compilation warning message. This works with very recent versions of gcc (4....
Definition cmnPortability.h:559
void cmnSerializeRaw(std::ostream &outputStream, const _elementType &data) CISST_THROW(std
Definition cmnSerializer.h:76
void cmnSerializeSizeRaw(std::ostream &outputStream, const size_t &data) CISST_THROW(std
Definition cmnSerializer.h:91
Declaration of the template function cmnThrow.
Declaration of the class cmnTypeTraits.
void cmnThrow(const _exceptionType &except, cmnLogLevel lod=CMN_LOG_LEVEL_INIT_ERROR)
Definition cmnThrow.h:76
size_type size(void) const
Definition vctDynamicConstMatrixBase.h:228