dataserialize.h File Reference

Classes

struct  IDENT_VOID
 
class  DESCRIBEFLAGS
 
class  DataSerializeInterface
 
class  DataSerializeWriterInterface
 
class  DataSerializeReaderInterface
 

Namespaces

 maxon
 

Macros

#define CONSTHASH(x)
 
#define PrepareDescribe(streamClass, className)
 
#define DescribeDefaults()
 
#define Describe(name, memberName, type, flags)
 
#define DescribeOther(name, elementName, type, flags)
 
#define DescribeLegacy(name)
 
#define DescribeHelper(name, memberName, type, flags)
 
#define DescribeIf(name, memberName, type, flags, mask, value)
 
#define DescribeHelperIf(name, memberName, type, flags, mask, value)
 
#define PrepareHelper(helperName, flags)
 
#define DescribeElse()
 
#define DescribeElseIf(mask, value)
 
#define DescribeEndIf()
 

Typedefs

using KeyValueConversionFunc = void(void *, Char *)
 
using CreateIoHelperFunc = ResultPtr< void >()
 
using DeleteIoHelperFunc = void(void *)
 
using ReadIoHelperFunc = Result< void >(DataSerializeInterface *, void *, void *, UInt)
 
using WriteIoHelperFunc = Result< void >(DataSerializeInterface *, void *, void *, UInt)
 
using WidthConversionFunc = Bool(void *source, void *dest)
 
using ReferenceSubstitutionFunction = Delegate< Result< const ObjectInterface * >(const ObjectInterface *input)>
 
using StreamSubstitutionFunction = Delegate< Result< ObjectRef >(ObjectRef input, const Id &compressorId)>
 

Enumerations

enum class  PREPAREHELPERFLAGS {
  NONE ,
  INITIALIZE_READ ,
  INITIALIZE_WRITE ,
  FINALIZE_READ ,
  FINALIZE_WRITE ,
  VALIDATE_STATE
}
 

Functions

 MAXON_DATATYPE (IDENT_VOID, "net.maxon.ident_void", MAXON_IMPLEMENTATION_MODULE("net.maxon.kernel"))
 
template<typename T >
ResultPtr< void > CreateHelper ()
 
template<typename T >
void DeleteHelper (void *helper)
 
template<typename MAINCLASS , typename HELPERCLASS >
Result< void > ReadHelper (DataSerializeInterface *ds, void *classPtr, void *helperPtr, UInt elementHash)
 
template<typename MAINCLASS , typename HELPERCLASS >
Result< void > WriteHelper (DataSerializeInterface *ds, void *classPtr, void *helperPtr, UInt elementHash)
 
template<typename T >
void ArrayConversionHelper (void *arrayPtr, Char *memBuffer)
 
template<typename T >
void SetConversionHelper (void *mapPtr, Char *memBuffer)
 
template<typename T >
void MapConversionHelper (void *mapPtr, Char *memBuffer)
 
DESCRIBEFLAGS operator| (DESCRIBEFLAGS a, DESCRIBEFLAGS b)
 
DESCRIBEFLAGS operator& (DESCRIBEFLAGS a, DESCRIBEFLAGS b)
 
DESCRIBEFLAGS operator~ (DESCRIBEFLAGS a)
 
DESCRIBEFLAGS & operator&= (DESCRIBEFLAGS &a, DESCRIBEFLAGS b)
 
enum maxon::PREPAREHELPERFLAGS MAXON_ENUM_FLAGS (PREPAREHELPERFLAGS)
 
 MAXON_DECLARATION (Class< DataSerializeRef >, DataSerializeBaseClass, "net.maxon.class.dataserializebase", MAXON_IMPLEMENTATION_MODULE("net.maxon.kernel"))
 
 MAXON_DECLARATION (Class< DataSerializeReaderRef >, DataSerializeReaderClass, "net.maxon.class.dataserializereader", MAXON_IMPLEMENTATION_MODULE("net.maxon.kernel"))
 
 MAXON_DECLARATION (Class< DataSerializeWriterRef >, DataSerializeWriterClass, "net.maxon.class.dataserializewriter", MAXON_IMPLEMENTATION_MODULE("net.maxon.kernel"))
 

Variables

static const UInt INITIALIZEHASH
 
static const UInt FINALIZEHASH
 
static const UInt VALIDATEHASH
 
 NONE
 
 INITIALIZE_READ
 
 INITIALIZE_WRITE
 
 FINALIZE_READ
 
 FINALIZE_WRITE
 
 VALIDATE_STATE
 

Macro Definition Documentation

◆ CONSTHASH

#define CONSTHASH (   x)

Expression to calculate the hash code of a member name during compile time.

◆ PrepareDescribe

#define PrepareDescribe (   streamClass,
  className 
)

Starts a description within DescribeIO. This can only be done once and must happen before any Describe calls are made.

Parameters
[in]streamClassThe stream class which has been passed to DescribeIO.
[in]classNameThe name of the current class.
Returns
OK on success.

◆ DescribeDefaults

#define DescribeDefaults ( )

Registers a class to support a later default value comparison. Must be used after PrepareDescribe. Declares a variable 'defaults' which then can be filled with the defaults to compare to.

◆ Describe

#define Describe (   name,
  memberName,
  type,
  flags 
)

Describes a class member for I/O operations within DescribeIO. It requires a previous call to PrepareDescribe. io_overview_describeio

Parameters
[in]nameThe clear-text name of an element in the file format. It can be arbitrarily chosen, but usually matches the respective member name. Once it has been used in files the identifier needs to stay the same to remain compatible (unless some conversion code is added). The name must only contain (latin) alphanumeric characters or '_' and it must not start with a numeric character. 'name' must be permanently available (and not only during the time of this call).
[in]memberNameThe name of the class member that will be described.
[in]typeThe DataType of the class member. While this could be automatically determined, this manual specification is necessary so that a change to a member type doesn't go unnoticed and damages the file integrity.
[in]flagsOne of the following: DESCRIBEFLAGS::TYPE_SET, DESCRIBEFLAGS::TYPE_MAP, DESCRIBEFLAGS::TYPE_ARRAY, DESCRIBEFLAGS::TYPE_UNIQUEREF, DESCRIBEFLAGS::TYPE_WEAKREF, DESCRIBEFLAGS::NONE. It can be combined with DESCRIBEFLAGS::DONT_WRITE, DESCRIBEFLAGS::ACTION_BEFORE_WRITE and DESCRIBEFLAGS::ACTION_AFTER_READ.
Returns
OK on success.

◆ DescribeOther

#define DescribeOther (   name,
  elementName,
  type,
  flags 
)

Describes a class member for I/O operations within DescribeIO. It requires a previous call to PrepareDescribe. Other than Describe this define allows to cast to a different DataType before the description is made. Here an example:

const auto& map = static_cast<MYCLASS*>(nullptr)->_vertices.GetMap().GetMap();
DescribeOther("_vertices", map, MAXON_MACROARG_TYPE(Tuple<MeshValue, MeshPair>), DESCRIBEFLAGS::TYPE_MAP) iferr_return;
#define DescribeOther(name, elementName, type, flags)
Definition: dataserialize.h:317
#define iferr_return
Definition: resultbase.h:1524

It is important that &map is equal to the offset within the described class. This is achieved by casting nullptr to MYCLASS*.

Parameters
[in]nameThe clear-text name of an element in the file format. It can be arbitrarily chosen, but usually matches the respective member name. Once it has been used in files the identifier needs to stay the same to remain compatible (unless some conversion code is added). The name must only contain (latin) alphanumeric characters or '_' and it must not start with a numeric character. 'name' must be permanently available (and not only during the time of this call).
[in]elementNameThe element that will be described.
[in]typeThe DataType of the class member. While this could be automatically determined, this manual specification is necessary so that a change to a member type doesn't go unnoticed and damages the file integrity.
[in]flagsOne of the following: DESCRIBEFLAGS::TYPE_SET, DESCRIBEFLAGS::TYPE_MAP, DESCRIBEFLAGS::TYPE_ARRAY, DESCRIBEFLAGS::TYPE_UNIQUEREF, DESCRIBEFLAGS::TYPE_WEAKREF, DESCRIBEFLAGS::NONE. It can be combined with DESCRIBEFLAGS::DONT_WRITE, DESCRIBEFLAGS::ACTION_BEFORE_WRITE and DESCRIBEFLAGS::ACTION_AFTER_READ.
Returns
OK on success.

◆ DescribeLegacy

#define DescribeLegacy (   name)

Describes a legacy element that is no longer needed within DescribeIO. It requires a previous call to PrepareDescribe. While generally no extra code is necessary to skip no longer needed elements this call makes sure that no warnings will show up if such an old element is found in a file.

Parameters
[in]nameThe clear-text name of an element in the file format. 'name' must be permanently available (and not only during the time of this call).
Returns
OK on success.

◆ DescribeHelper

#define DescribeHelper (   name,
  memberName,
  type,
  flags 
)

Describes a class member for I/O operations within DescribeIO. It requires a previous call to PrepareDescribe and PrepareHelper. Other than Describe this describes a member of the helper class. io_overview_helper

Parameters
[in]nameThe clear-text name of an element in the file format. It can be arbitrarily chosen, but usually matches the respective member name. Once it has been used in files the identifier needs to stay the same to remain compatible (unless some conversion code is added). The name must only contain (latin) alphanumeric characters or '_' and it must not start with a numeric character. 'name' must be permanently available (and not only during the time of this call).
[in]memberNameThe name of the member in the I/O helper class that will be described.
[in]typeThe DataType of the class member. While this could be automatically determined, this manual specification is necessary so that a change to a member type doesn't go unnoticed and damages the file integrity.
[in]flagsOne of the following: DESCRIBEFLAGS::TYPE_SET, DESCRIBEFLAGS::TYPE_MAP, DESCRIBEFLAGS::TYPE_ARRAY, DESCRIBEFLAGS::TYPE_UNIQUEREF, DESCRIBEFLAGS::TYPE_WEAKREF, DESCRIBEFLAGS::NONE. It can be combined with DESCRIBEFLAGS::DONT_WRITE, DESCRIBEFLAGS::ACTION_BEFORE_WRITE and DESCRIBEFLAGS::ACTION_AFTER_READ.
Returns
OK on success.

◆ DescribeIf

#define DescribeIf (   name,
  memberName,
  type,
  flags,
  mask,
  value 
)

Describes a class member with condition for I/O operations within DescribeIO. It requires a previous call to PrepareDescribe. Compared to Describe it additionally introduces a condition for following class members. Every DescribeIf must be paired with exactly one DescribeEndIf. io_overview_conditions

Parameters
[in]nameThe clear-text name of an element in the file format. It can be arbitrarily chosen, but usually matches the respective member name. Once it has been used in files the identifier needs to stay the same to remain compatible (unless some conversion code is added). The name must only contain (latin) alphanumeric characters or '_' and it must not start with a numeric character. 'name' must be permanently available (and not only during the time of this call).
[in]memberNameThe name of the class member that will be described.
[in]typeThe DataType of the class member. While this could be automatically determined, this manual specification is necessary so that a change to a member type doesn't go unnoticed and damages the file integrity.
[in]flagsOne of the following: DESCRIBEFLAGS::TYPE_SET, DESCRIBEFLAGS::TYPE_MAP, DESCRIBEFLAGS::TYPE_ARRAY, DESCRIBEFLAGS::TYPE_UNIQUEREF, DESCRIBEFLAGS::TYPE_WEAKREF, DESCRIBEFLAGS::NONE. It can be combined with DESCRIBEFLAGS::DONT_WRITE, DESCRIBEFLAGS::ACTION_BEFORE_WRITE and DESCRIBEFLAGS::ACTION_AFTER_READ.
[in]maskThe 64-bit unsigned comparison mask.
[in]valueThe 64-bit comparison value. The condition is met if (read_or_written_value & mask) == value.
Returns
OK on success.

◆ DescribeHelperIf

#define DescribeHelperIf (   name,
  memberName,
  type,
  flags,
  mask,
  value 
)

Describes a class member with condition for I/O operations within DescribeIO. It requires a previous call to PrepareDescribe and PrepareHelper. Other than DescribeIf this describes a member of the helper class. It additionally introduces a condition for following class members. Every DescribeHelperIf must be paired with exactly one DescribeEndIf. io_overview_conditions io_overview_helper

Parameters
[in]nameThe clear-text name of an element in the file format. It can be arbitrarily chosen, but usually matches the respective member name. Once it has been used in files the identifier needs to stay the same to remain compatible (unless some conversion code is added). The name must only contain (latin) alphanumeric characters or '_' and it must not start with a numeric character. 'name' must be permanently available (and not only during the time of this call).
[in]memberNameThe name of the class member that will be described.
[in]typeThe DataType of the class member. While this could be automatically determined, this manual specification is necessary so that a change to a member type doesn't go unnoticed and damages the file integrity.
[in]flagsOne of the following: DESCRIBEFLAGS::TYPE_SET, DESCRIBEFLAGS::TYPE_MAP, DESCRIBEFLAGS::TYPE_ARRAY, DESCRIBEFLAGS::TYPE_UNIQUEREF, DESCRIBEFLAGS::TYPE_WEAKREF, DESCRIBEFLAGS::NONE. It can be combined with DESCRIBEFLAGS::DONT_WRITE, DESCRIBEFLAGS::ACTION_BEFORE_WRITE and DESCRIBEFLAGS::ACTION_AFTER_READ.
[in]maskThe 64-bit unsigned comparison mask.
[in]valueThe 64-bit comparison value. The condition is met if (read_or_written_value & mask) == value.
Returns
OK on success.

◆ PrepareHelper

#define PrepareHelper (   helperName,
  flags 
)

Declares and initializes an I/O helper class within DescribeIO. This can only be done once within DescribeIO and must happen before DescribeHelper or DescribeHelperIf are used. io_overview_helper

Parameters
[in]helperNameThe name of the helper class.
[in]flagsPREPAREHELPERFLAGS.
Returns
OK on success.

◆ DescribeElse

#define DescribeElse ( )

Describes an else condition within DescribeIO. It requires a previous (and matching) call to DescribeIf or DescribeHelperIf. io_overview_conditions

Returns
OK on success.

◆ DescribeElseIf

#define DescribeElseIf (   mask,
  value 
)

Describes an else if condition within DescribeIO. It requires a previous (and matching) call to DescribeIf or DescribeHelperIf. The calculation of the condition is based on the read or written value from DescribeIf/DescribeHelperIf. io_overview_conditions

Parameters
[in]maskThe 64-bit unsigned comparison mask.
[in]valueThe 64-bit comparison value. The condition is met if (read_or_written_value & mask) == value.
Returns
OK on success.

◆ DescribeEndIf

#define DescribeEndIf ( )

Describes the end if an if condition within DescribeIO. It requires a previous (and matching) call to DescribeIf or DescribeHelperIf. io_overview_conditions

Returns
OK on success.

Variable Documentation

◆ NONE

NONE

◆ INITIALIZE_READ

INITIALIZE_READ

The helper's ReadAction will get a call with INITIALIZEHASH before the class has been read.

◆ INITIALIZE_WRITE

INITIALIZE_WRITE

The helper's WriteAction will get a call with INITIALIZEHASH before the class has been written.

◆ FINALIZE_READ

FINALIZE_READ

The helper's ReadAction will get a call with FINALIZEHASH after the class has been read.

◆ FINALIZE_WRITE

FINALIZE_WRITE

The helper's WriteAction will get a call with FINALIZEHASH after the class has been written.

◆ VALIDATE_STATE

VALIDATE_STATE

The helper's ReadAction will get a call after all input operations are finished. Objects that interact with others can then update necessary information.