47 #ifndef _MIRA_BINARYSERIALIZER_H_ 48 #define _MIRA_BINARYSERIALIZER_H_ 70 #define BINARY_VERSION_MARKER 65432u 73 #define CHECK_FORCE_SERIALIZE_BINARY_VERSION 101 template <
typename BinaryStream>
116 void reassign(
typename BinaryStream::streambuffer_pointer buffer) { mStream = buffer; }
120 BinaryStream&
stream() {
return mStream; }
123 BinaryStream mStream;
127 template <
typename BinaryStream,
bool Buffered>
153 template <
typename BinaryStream>
164 :
Base(buffer), mBufferStream(&mBuffer) {}
184 mBufferStream.seekp(0);
256 template <
typename Derived>
266 template <
typename T>
273 return this->
template version<void>(
version);
276 template <
typename T>
283 template <
typename T>
284 void write(
const T* data, std::size_t count) {
285 this->
This()->write(data,count);
294 template <
typename T>
297 return this->
This()->template hasCodec<T>();
299 return this->
This()->hasCodec<T>();
310 template <
typename T>
314 return this->
This()->template
codec(obj);
316 return this->
This()->codec(obj);
323 template <
typename BinaryStream, u
int8 BinaryFormatVersion,
bool Buffered>
338 template <
typename BinaryStream, u
int8 BinaryFormatVersion,
bool Buffered,
typename StreamType>
343 template <
typename Serializer,
typename StreamType>
359 StreamType& stream) {
return NULL; }
362 template <
typename T>
364 serializer.
atomic(version);
371 template <
typename BinaryStream,
bool Buffered,
typename StreamType>
380 template <
typename T>
387 template <
typename BinaryStream,
bool Buffered,
typename StreamType>
396 template <
typename T>
400 stream << getSerializerFormatVersion();
405 template <
typename BinaryStream,
bool Buffered,
typename StreamType>
424 typedef std::tuple<typename StreamType::pos_type, bool, const char*>
ReflectState;
431 template <
typename T>
434 #ifdef CHECK_FORCE_SERIALIZE_BINARY_VERSION 437 MIRA_LOG(
NOTICE) <<
"BinarySerializer: Forced serializing as binary " 438 <<
"format version " << v <<
".";
443 typename Serializer::SimpleStreamType::buffer_type buffer;
446 stream.write(buffer.data(), buffer.size());
451 typename Serializer::SimpleStreamType::buffer_type buffer;
454 stream.write(buffer.data(), buffer.size());
458 if (v != getSerializerFormatVersion()) {
459 MIRA_THROW(XIO,
"BinarySerializer: Unhandled binary format, expected version " 460 << (
int)this->getSerializerFormatVersion() <<
", requested " << (
int)v <<
".");
468 stream << getSerializerFormatVersion();
480 ReflectState prevState = std::make_tuple(mVersionPos, mVersionSet, mContext);
482 mVersionPos = stream.tellp();
483 if (mVersionPos ==
typename StreamType::pos_type(-1))
484 MIRA_THROW(XIO,
"Failed querying stream position. The stream type does not seem to support repositioning. " 485 "Please use a buffered serializer (BufferedBinaryStreamSerializer).");
498 template <
typename T>
502 MIRA_THROW(XIO,
"BinarySerializer: version() called repeatedly by serialization of type '" 503 << typeName<T>() <<
"'. Context = '" << (mContext ? mContext :
"") <<
"'.");
505 std::size_t pos = stream.tellp();
506 stream.seekp(mVersionPos);
507 serializer.
atomic(version);
517 mVersionPos = std::get<0>(prev);
518 mVersionSet = std::get<1>(prev);
519 mContext = std::get<2>(prev);
523 typename StreamType::pos_type mVersionPos;
525 const char* mContext;
530 template <
typename BinaryStream, u
int8 BinaryFormatVersion,
bool Buffered = false>
531 class ConcreteBinarySerializer :
public BinarySerializer<ConcreteBinarySerializer<BinaryStream,
534 public BinarySerializerMixin,
535 public StreamAccessMixin<BinaryStream, Buffered>,
536 public SerializerFormatMixin<BinaryStream, BinaryFormatVersion, Buffered,
537 typename StreamAccessMixin<BinaryStream, Buffered>::StreamType>
539 typedef BinarySerializer<ConcreteBinarySerializer<BinaryStream, BinaryFormatVersion, Buffered> > Base;
540 typedef StreamAccessMixin<BinaryStream, Buffered> StreamAccess;
541 typedef SerializerFormatMixin<BinaryStream, BinaryFormatVersion, Buffered,
597 template <
typename T>
598 void serialize(
const T& value,
bool enableTypeCheck =
true)
600 #ifdef CHECK_FORCE_SERIALIZE_BINARY_VERSION 601 if (!Format::writeFormatVersion(value, enableTypeCheck, this->
stream()))
604 Format::writeFormatVersion(value, enableTypeCheck, this->
stream());
607 if(enableTypeCheck) {
608 std::string fulltypename = typeName<T>();
616 template <
typename T>
618 version = this->
template queryDesiredClassVersion<T>(
version,
false);
619 this->
template writeVersion<T>(
version, *
this, this->
stream());
625 return this->
template version<void>(
version);
630 template <
typename T>
632 version = this->
template queryDesiredClassVersion<T>(
version,
true);
633 this->
template writeVersion<T>(
version, *
this, this->
stream());
648 typename Format::ReflectState
preReflect(
const char* context =
"")
651 return Format::insertVersionPlaceholder(context, *
this, this->
stream());
656 Format::restoreVersionPtr(prev);
672 this->
stream() << referencedObjectID;
710 static const std::string context =
"invokeOverwrite " + typeName<T>();
711 typename Format::ReflectState prevState =
preReflect(context.c_str());
726 static const std::string context =
"invokeOverwrite PlainArray<" + typeName<T>() +
">";
727 typename Format::ReflectState prevState =
preReflect(context.c_str());
737 const char* buffer =
reinterpret_cast<const char*
>(array.data);
738 this->
stream().write(buffer, array.getSizeInBytes());
746 template <
typename T>
747 void write(
const T* data, std::size_t count) {
748 this->
stream().write(reinterpret_cast<const char*>(data),count*
sizeof(T));
769 auto p = mCodecs.insert(std::make_pair(
type,
codec));
771 MIRA_THROW(XLogical,
"A codec for the same type exists already");
780 auto it = mCodecs.find(
type);
781 if(it==mCodecs.end())
784 if(it->second!=
codec)
795 template <
typename T>
797 return mCodecs.count(typeId<T>())!=0;
807 template <
typename T>
813 auto it = mCodecs.find(typeId<T>());
814 if(it!=mCodecs.end()) {
817 s =
codec->getFourcc();
833 this->
stream() << encodedData;
848 std::map<TypeId, BinarySerializerCodecPtr> mCodecs;
927 template <
typename Derived>
934 template <
typename T>
936 return this->This()->template version<T>(version);
941 return this->
template version<void>(version);
944 template <
typename T>
951 template <
typename T>
952 void read(T* data, std::size_t count) {
953 this->This()->read(data,count);
962 template <
typename T>
965 return this->This()->template hasCodec<T>();
967 return this->This()->hasCodec<T>();
977 template <
typename T>
981 return this->This()->template codec(obj);
983 return this->This()->codec(obj);
990 template <
typename BinaryStream, u
int8 BinaryFormatVersion>
996 template <
typename BinaryStream, u
int8 BinaryVersionFormat>
1001 template <
typename Deserializer,
typename BinaryStream>
1016 template <
typename T>
1030 template <
typename BinaryStream>
1039 template <
typename T>
1043 template <
typename BinaryStream>
1052 template <
typename T>
1059 MIRA_THROW(XIO,
"Failed to read binary format version number from binary stream: " 1060 "Reading from stream failed, e.g. empty or non-existent file.");
1063 MIRA_THROW(XIO,
"Failed to read binary format version number from binary stream: " 1064 "Expected marker not found, data invalid for binary format version 1.");
1069 if (v != getSerializerFormatVersion())
1070 MIRA_THROW(XIO,
"BinaryDeserializer: Unhandled binary format, expected version " 1071 << (
int)getSerializerFormatVersion() <<
", found " << (
int)v <<
".");
1077 template <
typename BinaryStream>
1088 typename BinaryStream::pos_type pos = stream.tellg();
1098 MIRA_THROW(XIO,
"Failed to read binary format version number from binary stream: " 1099 "Reading from stream failed, e.g. empty or non-existent file.");
1101 if (pos ==
typename BinaryStream::pos_type(-1))
1102 MIRA_THROW(XIO,
"Requiring fallback to legacy deserializer, but failing to query (and set) stream position. " 1103 "The stream type does not seem to support repositioning. " 1104 "You may try using a legacy deserializer directly, avoiding the need for setting the stream read position.");
1121 typedef std::tuple<serialization::VersionType, bool, const char*, bool>
ReflectState;
1126 mUncheckedVersion(0), mUncheckedContext(NULL) {}
1132 template <
typename T>
1136 #ifdef CHECK_FORCE_SERIALIZE_BINARY_VERSION 1139 MIRA_LOG(
NOTICE) <<
"BinaryDeserializer: Forced deserializing as binary " 1140 <<
"format version " << vf <<
".";
1143 getDataFormatVersion(stream);
1147 v = getDataFormatVersion(stream);
1150 if (v < getSerializerFormatVersion()) {
1153 MIRA_LOG(
NOTICE) <<
"BinaryDeserializer: Found outdated binary format, version " 1154 << (int)v <<
". Using legacy deserializer.";
1161 stream.seekg(v0.streamPosition());
1168 stream.seekg(v1.streamPosition());
1172 if (v != getSerializerFormatVersion()) {
1173 MIRA_THROW(XIO,
"BinaryDeserializer: Unhandled binary format, expected version " 1174 << (
int)getSerializerFormatVersion() <<
", found " << (
int)v <<
".");
1189 if ((mVersion > 0) && !mVersionChecked && (mUncheckedVersion == 0)) {
1190 mUncheckedVersion = mVersion;
1191 mUncheckedContext = mContext;
1192 prevState = std::make_tuple(mVersion, mVersionChecked, mContext,
true);
1194 prevState = std::make_tuple(mVersion, mVersionChecked, mContext,
false);
1195 deserializer.
atomic(mVersion);
1196 mVersionChecked =
false;
1204 template <
typename T>
1211 mVersionChecked =
true;
1220 if ((mVersion > 0) && !mVersionChecked)
1221 MIRA_THROW(XIO,
"Tried to deserialize versioned binary data (version " << (
int)mVersion <<
1222 ") into unversioned type. Context = '" << (mContext ? mContext :
"") <<
"'.");
1223 mVersion = std::get<0>(prev);
1224 mVersionChecked = std::get<1>(prev);
1225 mContext = std::get<2>(prev);
1226 if (std::get<3>(prev)) {
1227 mUncheckedVersion = 0;
1232 if (mUncheckedVersion > 0) {
1233 os <<
" While trying to deserialize versioned binary data (version " << (int)mUncheckedVersion <<
1234 ") into type that is unversioned or not checking version before critical read. " <<
1235 "Context = '" << (mUncheckedContext ? mUncheckedContext :
"") <<
"'.";
1236 }
else if ((mVersion > 0) && !mVersionChecked) {
1237 os <<
" While trying to deserialize versioned binary data (version " << (int)mVersion <<
1238 ") into type that is unversioned or not checking version before critical read. " <<
1239 "Context = '" << (mContext ? mContext :
"") <<
"'.";
1245 bool mVersionChecked;
1246 const char* mContext;
1249 const char* mUncheckedContext;
1254 template <
typename BinaryStream, u
int8 BinaryFormatVersion>
1255 class ConcreteBinaryDeserializer :
public BinaryDeserializer<ConcreteBinaryDeserializer<BinaryStream,
1256 BinaryFormatVersion> >,
1257 public BinarySerializerMixin,
1258 public DeserializerFormatMixin<BinaryStream, BinaryFormatVersion>
1260 typedef BinaryDeserializer<ConcreteBinaryDeserializer<BinaryStream, BinaryFormatVersion> > Base;
1261 typedef DeserializerFormatMixin<BinaryStream, BinaryFormatVersion> Format;
1270 typedef std::map<TypeId, BinarySerializerCodecPtr>
CodecsMap;
1290 : mStream(buffer) {}
1308 mStream(stream, pos) {}
1317 void reassign(
typename BinaryStream::streambuffer_pointer buffer) {
1339 template <
typename T>
1340 void deserialize(T& value,
bool enableTypeCheck =
true,
bool recursive =
false)
1342 if (!recursive && !Format::checkFormatVersion(value, enableTypeCheck, mStream))
1345 if(enableTypeCheck) {
1346 std::string fulltypename;
1351 MIRA_THROW(XBadCast,
"Failed reading type from binary data while " <<
1352 "deserializing into a variable of type '" << typeName<T>() <<
"'");
1355 if(fulltypename != typeName<T>())
1356 MIRA_THROW(XBadCast,
"Cannot deserialize the type '" << fulltypename <<
1357 "' into a variable of type '" << typeName<T>() <<
"'");
1365 template <
typename T>
1368 if (
version > expectedVersion)
1369 MIRA_THROW(XIO,
"Trying to deserialize binary data of a newer version (" << (
int)
version <<
1370 ") of type " << typeName<T>() <<
" into an older version (" << (
int)expectedVersion <<
").");
1376 return version<void>(expectedVersion);
1381 template <
typename T>
1383 return this->
template getVersion<T>(*this);
1386 template<
typename T>
1392 if(mStream.fail()) {
1393 std::stringstream ss;
1394 ss <<
"Failed to read member of type '" << typeName<T>()
1395 <<
"' from binary stream at stream position " <<
streamPosition() <<
".";
1397 Format::reportVersionChecked(ss);
1403 typename Format::ReflectState
preReflect(
const char* context =
"")
1405 return Format::readVersion(context, *
this);
1410 Format::restoreVersion(prev);
1431 template<
typename T>
1436 uint8 pointerType8U;
1437 mStream >> pointerType8U;
1452 pointer = this->
template resolveReference<T>(ref);
1464 mStream >> mClassType;
1476 template<
typename T>
1480 static const std::string context =
"invokeOverwrite " + typeName<T>();
1481 typename Format::ReflectState prevState =
preReflect(context.c_str());
1494 template<
typename T>
1498 static const std::string context =
"invokeOverwrite PlainArray<" + typeName<T>() +
">";
1499 typename Format::ReflectState prevState =
preReflect(context.c_str());
1510 char* buffer =
reinterpret_cast<char*
>(array.data);
1511 mStream.read(buffer, array.getSizeInBytes());
1520 template <
typename T>
1521 void read(T* data, std::size_t count) {
1522 mStream.read(reinterpret_cast<char*>(data),count*
sizeof(T));
1532 template <
typename T>
1544 template <
typename T>
1557 auto it = mCodecs.find(typeId<T>());
1558 if(it==mCodecs.end() || it->second->getFourcc()!=s) {
1560 codec = BinarySerializerCodec::createCodec<T>(s);
1562 mCodecs[typeId<T>()] =
codec;
1566 assert(
codec->getFourcc()==s);
1567 assert(
codec->getSupportedTypeId()==typeId<T>());
1571 mStream >> encodedData;
1574 codec->decode(encodedData, obj);
1592 BinaryStream mStream;
1593 std::string mClassType;
ConcreteBinarySerializer< BinaryBufferOstream, 2 > BinaryBufferSerializer
Typedef for BinarySerializer based on a Buffer.
Definition: BinarySerializer.h:858
boost::mpl::bool_< false > useHumanReadableIDs
Definition: BinarySerializer.h:553
ConcreteBinaryDeserializer< BinaryBufferIstream, 2 > BinaryBufferDeserializer
Typedef for BinaryDeserializer based on a Buffer.
Definition: BinarySerializer.h:1603
ConcreteBinaryDeserializer< BinaryStlIstream, 2 > BinaryStreamDeserializer
Typedef for BinaryDeserializer based on a stl stream.
Definition: BinarySerializer.h:1612
Format::ReflectState ReflectState
Definition: BinarySerializer.h:556
Base::AcceptDesiredVersion AcceptDesiredVersion
Definition: BinarySerializer.h:628
Definition: BinarySerializer.h:324
MIRA_DEPRECATED("Please call as version<MyType>(v) or version(v, this)", VersionType version(VersionType version))
Definition: BinarySerializer.h:271
Base::AcceptDesiredVersion AcceptDesiredVersion
Definition: BinarySerializer.h:1379
Typedefs for OS independent basic data types.
MIRA_DEPRECATED("Please call as version<MyType>(v) or version(v, this)", VersionType version(VersionType expectedVersion))
Definition: BinarySerializer.h:1374
ConcreteBinarySerializer(BinaryStream &stream)
Create a new binary serializer and assign it to the specified binary output stream.
Definition: BinarySerializer.h:581
bool codec(T &obj)
Decodes the specified object from the serialized data.
Definition: BinarySerializer.h:1545
void pointer(T *&pointer)
Overwrites Deserializer::pointer.
Definition: BinarySerializer.h:1432
void invokeOverwrite(serialization::PlainArray< T > &array)
Specialized for Array to implement an optimized variant for deserializing an array, if possible (i.e.
Definition: BinarySerializer.h:1495
Format::ReflectState ReflectState
Definition: BinarySerializer.h:1273
void invokeOverwrite(T &object)
The actual invoke implementation, that may also be overwritten in derived classes to add additional f...
Definition: AbstractReflector.h:271
Contains the Serializer template, a base class for all serializers.
void pointer(T *&pointer)
Definition: Deserializer.h:157
void deserialize(const std::string &name, T &value)
Deserializes the specified object value with the given name.
Definition: Deserializer.h:133
StreamAccessMixin(typename BinaryStream::streambuffer_pointer buffer)
Definition: BinarySerializer.h:137
VersionType version(VersionType version, AcceptDesiredVersion, const T *caller=NULL)
Definition: BinarySerializer.h:277
Definition: BinarySerializer.h:88
ConcreteBinaryDeserializer(typename BinaryStream::streambuffer_pointer buffer)
Create a new binary deserializer based on the specified stream buffer object.
Definition: BinarySerializer.h:1289
VersionType version(VersionType version, const T *caller=NULL)
Definition: BinarySerializer.h:267
typename ReflectorInterface< ConcreteBinarySerializer< mira::BinaryOstream, BinaryFormatVersion, false > >::AcceptDesiredVersion AcceptDesiredVersion
Definition: AbstractReflector.h:195
Type trait that indicates whether a type can be serialized bitwise by just copying the data buffer...
Definition: IsBitwiseSerializable.h:70
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
Definition: BinarySerializer.h:91
void member(const char *name, T &member, const char *comment, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Definition: RecursiveMemberReflector.h:862
Serializer that uses BinaryOstream to serialize the objects in binary format.
Definition: BinarySerializer.h:254
static int forcedDeserializeVersion()
Returns either the version number from value of environment variable 'MIRA_FORCE_DESERIALIZE_VERSION'...
Definition: Deserializer.h:118
Is a special reflector that is used for serialization.
Definition: Serializer.h:126
void flushBuffer()
Flush stream buffer (write to underlying stream), nothing to do for unbuffered access.
Definition: BinarySerializer.h:146
~StreamAccessMixin()
Definition: BinarySerializer.h:168
#define MIRA_LOG(level)
Use this macro to log data.
Definition: LoggingCore.h:529
bool hasCodec() const
Returns true, of there is a codec for the specified type T.
Definition: BinarySerializer.h:796
Definition: BinarySerializer.h:90
#define BINARY_VERSION_MARKER
Definition: BinarySerializer.h:70
void pointerWithoutClassType()
Definition: BinarySerializer.h:681
void write(const T *data, std::size_t count)
Definition: BinarySerializer.h:747
void invokeOverwrite(serialization::PlainArray< T > &array)
Specialized for PlainArray to implement an optimized variant for serializing array, if possible (i.e.
Definition: BinarySerializer.h:724
Definition: BinarySerializer.h:991
Direct stream access.
Definition: BinarySerializer.h:128
StreamAccessMixin(BinaryStream &stream)
Definition: BinarySerializer.h:140
Definition: BinarySerializer.h:89
Used by BinarySerializer and BinaryDeserializer.
Definition: BinarySerializer.h:79
boost::mpl::bool_< false > useHumanReadableIDs
Definition: BinarySerializer.h:1267
Get compiler and platform independent typenames.
ConcreteBinarySerializer< BinaryStlOstream, 0 > BinaryStreamSerializerLegacy
Definition: BinarySerializer.h:868
Base for buffered/unbuffered stream access.
Definition: BinarySerializer.h:102
void serialize(const std::string &name, const T &value, const std::string &comment="")
Serializes the specified object value under the given name.
Definition: Serializer.h:204
StreamAccessMixinBase(typename BinaryStream::streambuffer_pointer buffer)
Definition: BinarySerializer.h:105
serialization::VersionType VersionType
Definition: BinarySerializer.h:263
uint8 VersionType
Definition: ReflectorInterface.h:72
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:82
void reassign(typename BinaryStream::streambuffer_pointer buffer)
Reassigns the specified stream buffer to this deserializer.
Definition: BinarySerializer.h:1317
void serialize(const T &value, bool enableTypeCheck=true)
Provides a special serialize interface for the BinarySerializer.
Definition: BinarySerializer.h:598
bool codec(const T &obj)
Encodes the specified object containing the data using a matching codec.
Definition: BinarySerializer.h:311
BinaryBufferOstream SimpleStreamType
Definition: BinarySerializer.h:546
ConcreteBinaryDeserializer< BinaryBufferIstream, 0 > BinaryBufferDeserializerLegacy
Definition: BinarySerializer.h:1605
ConcreteBinaryDeserializer< BinaryStlIstream, 1 > BinaryStreamDeserializerLegacyMarked
Definition: BinarySerializer.h:1613
void pointerReference(int referencedObjectID)
Definition: BinarySerializer.h:670
Derived * This()
"Curiously recurring template pattern" (CRTP).
Definition: AbstractReflector.h:246
Format::requireReflectBarriers requireReflectBarriers
Definition: BinarySerializer.h:1272
bool hasCodec() const
Supported for compatibility with BinarySerializer in a common reflect method.
Definition: BinarySerializer.h:1533
Format::VersionType VersionType
Definition: BinarySerializer.h:1363
void registerCodec(BinarySerializerCodecPtr codec)
Registers the specified codec instance in this binary serializer.
Definition: BinarySerializer.h:764
ConcreteBinaryDeserializer< BinaryStlIstream, 0 > BinaryStreamDeserializerLegacy
Definition: BinarySerializer.h:1614
bool hasCodec() const
Returns true, of there is a codec for the specified type T.
Definition: BinarySerializer.h:295
A four-character code that is used to identify data formats and codecs.
Definition: BinarySerializerCodec.h:121
Deserializer that uses BinaryIstream to deserialize the objects from binary format.
Definition: BinarySerializer.h:928
Provides type trait that indicates whether a type can be serialized bitwise.
PropertyHint type(const std::string &t)
Sets the attribute "type" to the specified value.
Definition: PropertyHint.h:295
Format::ReflectState preReflect(const char *context="")
Definition: BinarySerializer.h:648
Contains base class for all deserializers.
const CodecsMap & getCodecs() const
Return the map of currently known codecs.
Definition: BinarySerializer.h:1581
void invokeOverwrite(T &object)
Definition: BinarySerializer.h:708
BinaryBufferOstream & stream()
Get access to the read/write stream, returns reference to buffer stream (overriding the base class' s...
Definition: BinarySerializer.h:177
VersionType version(VersionType expectedVersion, const T *object=NULL)
Definition: BinarySerializer.h:1366
Tag class used as parameter to ReflectorInterface::version() etc.
Definition: ReflectorInterface.h:80
Base class for codecs for BinarySerializer and BinaryDeserializer.
void write(const T *data, std::size_t count)
Definition: BinarySerializer.h:284
ConcreteBinaryDeserializer< BinaryBufferIstream, 1 > BinaryBufferDeserializerLegacyMarked
Definition: BinarySerializer.h:1604
void read(T *data, std::size_t count)
Definition: BinarySerializer.h:1521
ConcreteBinarySerializer(typename BinaryStream::streambuffer_pointer buffer)
Create a new binary serializer based on the specified stream buffer object.
Definition: BinarySerializer.h:571
serialization::AcceptDesiredVersion AcceptDesiredVersion
Definition: BinarySerializer.h:264
void pointerNull()
Definition: BinarySerializer.h:703
VersionType version(VersionType version, AcceptDesiredVersion, const T *caller=NULL)
Definition: BinarySerializer.h:945
typename ReflectorInterface< ConcreteBinarySerializer< mira::BinaryOstream, BinaryFormatVersion, false > >::VersionType VersionType
Definition: AbstractReflector.h:165
int TypeId
The type of the integral TypeId, that can be retrieved by typeId<T>()
Definition: TypeId.h:64
ConcreteBinarySerializer< BinaryStlOstream, 2, true > BufferedBinaryStreamSerializer
Definition: BinarySerializer.h:867
StreamAccessMixin(BinaryStream &stream)
Definition: BinarySerializer.h:166
ConcreteBinaryDeserializer(BinaryStream &stream, typename BinaryStream::pos_type pos)
Create a new binary deserializer and read the data from the specified binary stream, starting at the specified position.
Definition: BinarySerializer.h:1307
void setCodecs(const CodecsMap &codecs)
Set the map of known codecs.
Definition: BinarySerializer.h:1586
VersionType version(VersionType version, const T *caller=NULL)
Definition: BinarySerializer.h:617
ConcreteBinarySerializer< BinaryBufferOstream, 0 > BinaryBufferSerializerLegacy
Definition: BinarySerializer.h:859
VersionType version(VersionType version, const T *caller=NULL)
Definition: BinarySerializer.h:935
static int forcedSerializeVersion()
Returns either the version number from value of environment variable 'MIRA_FORCE_SERIALIZE_VERSION', or -1 (= do not force a version).
Definition: Serializer.h:145
StreamAccessMixin(typename BinaryStream::streambuffer_pointer buffer)
Definition: BinarySerializer.h:163
void flushBuffer()
Flush buffer stream to underlying stream.
Definition: BinarySerializer.h:180
bool hasCodec() const
Returns true, of there is a codec for the specified type T.
Definition: BinarySerializer.h:963
Contains the BinaryIStream and BinaryOStream classes for fast and efficient streaming of binary data...
Format::ReflectState preReflect(const char *context="")
Definition: BinarySerializer.h:1403
BinaryStream::pos_type streamPosition()
Definition: BinarySerializer.h:1321
void atomic(T &member)
Definition: BinarySerializer.h:1387
BinaryStream StreamType
The type of stream the serializer writes to (the actual output stream here)
Definition: BinarySerializer.h:134
void postReflect(const typename Format::ReflectState &prev)
Definition: BinarySerializer.h:654
void deserialize(T &value, bool enableTypeCheck=true, bool recursive=false)
Provides a special deserialize interface for the BinaryDeserializer.
Definition: BinarySerializer.h:1340
void pointerWithClassType(const std::string &type)
Definition: BinarySerializer.h:693
bool codec(T &obj)
Decodes the specified object from the serialized data.
Definition: BinarySerializer.h:978
VersionType version(VersionType expectedVersion, AcceptDesiredVersion, const T *object=NULL)
Definition: BinarySerializer.h:1382
Definition: BinarySerializer.h:257
Format::VersionType VersionType
Definition: BinarySerializer.h:614
ConcreteBinaryDeserializer(BinaryStream &stream)
Create a new binary deserializer and read the data from the specified binary stream.
Definition: BinarySerializer.h:1298
BinarySerializerTag Tag
Definition: BinarySerializer.h:260
ConcreteBinarySerializer< BinaryStlOstream, 2 > BinaryStreamSerializer
Typedef for BinarySerializer based on STL streams.
Definition: BinarySerializer.h:866
Format::requireReflectBarriers requireReflectBarriers
Definition: BinarySerializer.h:555
serialization::VersionType VersionType
Definition: BinarySerializer.h:931
void read(T *data, std::size_t count)
Definition: BinarySerializer.h:952
BinaryStream & stream()
Get access to the read/write stream (direct reference to underlying stream).
Definition: BinarySerializer.h:120
BinaryBufferOstream StreamType
The type of stream the serializer writes to (the buffer stream here).
Definition: BinarySerializer.h:160
std::string pointerClassType()
Definition: BinarySerializer.h:1471
static Fourcc null()
Returns the 'NULL' fourcc.
Definition: BinarySerializerCodec.h:142
void postReflect(const typename Format::ReflectState &prev)
Definition: BinarySerializer.h:1408
MIRA_DEPRECATED("Please call as version<MyType>(v) or version(v, this)", VersionType version(VersionType version))
Definition: BinarySerializer.h:623
serialization::AcceptDesiredVersion AcceptDesiredVersion
Definition: BinarySerializer.h:932
PointerType
Pointer type that is stored as 1-byte marker before storing the pointer.
Definition: BinarySerializer.h:86
char fourcc[4]
Definition: BinarySerializerCodec.h:165
void reassign(typename BinaryStream::streambuffer_pointer buffer)
Reassigns the specified stream buffer to this (serializer).
Definition: BinarySerializer.h:116
void atomic(T &member)
Is called if the member is an atomic type (int, float, etc).
Definition: RecursiveMemberReflector.h:268
MIRA_DEPRECATED("Please call as version<MyType>(v) or version(v, this)", VersionType version(VersionType version))
Definition: BinarySerializer.h:939
void atomic(T &member)
Definition: BinarySerializer.h:641
void unregisterCodec(BinarySerializerCodecPtr codec)
Removes a previously registered codec.
Definition: BinarySerializer.h:775
void invokeOverwrite(T &object)
Definition: BinarySerializer.h:1477
Definition: LoggingCore.h:77
Is a special reflector that is used for deserialization.
Definition: Deserializer.h:99
bool codec(const T &obj)
Encodes the specified object containing the data using a matching codec.
Definition: BinarySerializer.h:808
std::map< TypeId, BinarySerializerCodecPtr > CodecsMap
A map of binary serialization codecs.
Definition: BinarySerializer.h:1270
boost::shared_ptr< BinarySerializerCodec > BinarySerializerCodecPtr
Shared pointer of BinarySerializerCodec.
Definition: BinarySerializerCodec.h:64
VersionType version(VersionType version, AcceptDesiredVersion, const T *caller=NULL)
Definition: BinarySerializer.h:631
StreamAccessMixinBase(BinaryStream &stream)
Definition: BinarySerializer.h:108