ADTF  3.18.2
structure< void >

This is used to create a structure type independently. More...

Inheritance diagram for structure< void >:
[legend]

Public Member Functions

 structure (const std::string &strName, size_t nAlignment=0)
 Initializes the structure. More...
 
size_t GetSize () const override
 
size_t GetAlignment () const override
 
template<typename ArithmeticType >
std::enable_if< std::is_arithmetic< ArithmeticType >::value, structure >::type & Add (const std::string &strName, size_t nArrayCount=1, size_t nAlignment=0, int32_t nBytePosition=-1, bool bLittleEndian=true)
 Adds a new member of arithmetic type (POD) More...
 
structureAdd (const std::string &strName, const cEnumerationType &oTypeDefinition, size_t nArrayCount=1, size_t nAlignment=0, int32_t nBytePosition=-1, bool bLittleEndian=true)
 Adds a new member of an enumeration type. More...
 
structureAdd (const std::string &strName, const cStructureType &oTypeDefinition, size_t nArrayCount=1, size_t nAlignment=0, int32_t nBytePosition=-1, bool bLittleEndian=true)
 Adds a new member of a structure type. More...
 
- Public Member Functions inherited from cStructureType
 cStructureType (const std::string &strName, size_t nSize, size_t nAlignment)
 Initializes the structure type. More...
 
 cStructureType (const cStructureType &oOther)
 
std::string GetName () const override
 
const std::vector< member > & GetMembers () const
 
std::pair< std::string, std::string > GetAsStringPair () const
 Legacy conversion to a pair of (first) md_struct and (second)md_description. More...
 
 operator std::pair< std::string, std::string > () const
 Legacy conversion operator to a pair of (first) md_struct and (second)md_description. More...
 

Private Member Functions

void Add (const std::string &strName, size_t nArrayCount, size_t nAlignment, int32_t nBytePosition, bool bLittleEndian, const std::shared_ptr< cType > &oTypeDefinition)
 
size_t Align (size_t nOffset, size_t nAlignment) const
 
void AlignOffset (size_t nAlignment)
 

Private Attributes

size_t m_nCurrentOffset = 0
 
size_t m_nCurrentSerializedOffset = 0
 
size_t m_nMaxAlignment = 1
 

Additional Inherited Members

- Protected Member Functions inherited from cStructureType
void Add (member &&sNewMember)
 Adds a new member to the structure. More...
 

Detailed Description

This is used to create a structure type independently.

Example Usage

auto oSubType = structure<>("tSub")
.Add<uint8_t>("nValue1")
.Add<uint8_t>("nValue2");
auto oParentType = structure<tParent>("tParent")
.Add<uint32_t>("nSomething", &tParent::nSomething)
.Add("sSub", oSubType);
std::enable_if< std::is_arithmetic< ArithmeticType >::value, structure >::type & Add(const std::string &strName, size_t nArrayCount=1, size_t nAlignment=0, int32_t nBytePosition=-1, bool bLittleEndian=true)
Adds a new member of arithmetic type (POD)

Definition at line 462 of file type_reflection_legacy.h.

Constructor & Destructor Documentation

◆ structure()

structure ( const std::string &  strName,
size_t  nAlignment = 0 
)

Initializes the structure.

Parameters
[in]strNameThe name
[in]nAlignmentThe alignment. 0 => Alignment will be calculated from the members.

Member Function Documentation

◆ Add() [1/3]

structure& Add ( const std::string &  strName,
const cEnumerationType oTypeDefinition,
size_t  nArrayCount = 1,
size_t  nAlignment = 0,
int32_t  nBytePosition = -1,
bool  bLittleEndian = true 
)

Adds a new member of an enumeration type.

Parameters
[in]strNameThe name of the member.
[in]oTypeDefinitionThe enumeration type definition.
[in]nArrayCountThe array size of the member.
[in]nAlignmentThe Alignment of the member. 0 => alignment is taken from the type.
[in]nBytePositionThe byte position in the serialized representation.
[in]bLittleEndianWhether the value in the serialized representation is little endian or not.
Returns
A reference to the structure.

◆ Add() [2/3]

structure& Add ( const std::string &  strName,
const cStructureType oTypeDefinition,
size_t  nArrayCount = 1,
size_t  nAlignment = 0,
int32_t  nBytePosition = -1,
bool  bLittleEndian = true 
)

Adds a new member of a structure type.

Parameters
[in]strNameThe name of the member.
[in]oTypeDefinitionThe structure type definition.
[in]nArrayCountThe array size of the member.
[in]nAlignmentThe Alignment of the member. 0 => alignment is taken from the type.
[in]nBytePositionThe byte position in the serialized representation.
[in]bLittleEndianWhether the value in the serialized representation is little endian or not.
Returns
A reference to the structure.

◆ Add() [3/3]

std::enable_if<std::is_arithmetic<ArithmeticType>::value, structure>::type& Add ( const std::string &  strName,
size_t  nArrayCount = 1,
size_t  nAlignment = 0,
int32_t  nBytePosition = -1,
bool  bLittleEndian = true 
)
inline

Adds a new member of arithmetic type (POD)

Parameters
[in]strNameThe name of the member.
[in]nArrayCountThe array size of the member.
[in]nAlignmentThe Alignment of the member. 0 => alignment is taken from the type.
[in]nBytePositionThe byte position in the serialized representation.
[in]bLittleEndianWhether the value in the serialized representation is little endian or not.
Returns
A reference to the structure.

Definition at line 487 of file type_reflection_legacy.h.

References structure< T >::Add().

◆ GetAlignment()

size_t GetAlignment ( ) const
overridevirtual
Returns
The default alignment of the type.

Reimplemented from cStructureType.

◆ GetSize()

size_t GetSize ( ) const
overridevirtual
Returns
The size of the type.

Reimplemented from cStructureType.