Dev Essential
Loading...
Searching...
No Matches
ddl::dd::StructElementAccess Class Reference

Class to access and obtain the byte position and other information of a instance of this element within a struct (see StructTypeAccess). More...

#include <dd_struct_access.h>

Public Types

typedef StructArrayElementAccessIterator const_iterator
 this is the const iterator type definition for the array elements of this element access.
 

Public Member Functions

 StructElementAccess ()=delete
 deleted CTOR
 
 StructElementAccess (StructElementAccess &&) noexcept
 Default move CTOR.
 
StructElementAccessoperator= (StructElementAccess &&) noexcept
 Default move assignment.
 
 StructElementAccess (const StructElementAccess &)
 Default copy CTOR.
 
StructElementAccessoperator= (const StructElementAccess &)
 Default copy assignment.
 
 StructElementAccess (std::nullptr_t)
 empty element access. This kind of element access will be returned, if i.e. StructTypeAccess::getElementByPath can not find the given path.
 
 ~StructElementAccess ()
 DTOR.
 
 operator bool () const
 Retrieve if the StructElementAccess is valid or not!
 
TypeOfType getTypeOfType () const
 Get the Type Of the type. Retrieves the information of the elements type.
 
std::string getName () const
 
std::shared_ptr< const datamodel::StructTypegetStructType () const
 Gets the Struct Type if the element is dependent on a structtype.
 
std::shared_ptr< const datamodel::EnumTypegetEnumType () const
 Gets the Enum Type if the element is dependent on a enumtype.
 
std::shared_ptr< const datamodel::DataTypegetDataType () const
 Gets the Data Type if the element is dependent on a datatype.
 
StructTypeAccess getStructTypeAccess (size_t array_pos=0) const
 Get the Struct Type Access if the element depends on a structtype. All byte positions within the returned StructTypeAccess are relativ to the elements StructTypeAccess parent.
 
bool isStruct () const
 Determines if the element is an struct type.
 
bool isLeaf () const
 Determines if the element is a leaf type (no struct, no array).
 
bool isArray () const
 Determines if the element is an array type.
 
size_t getArraySize () const
 Retrieves the array size if the element is an static array type.
 
StructElementAccess getArrayElement (size_t array_pos=0) const
 Retrieves an element with byte and bit offsets for the given array position.
 
const datamodel::StructType::ElementgetElement () const
 Get the Element Information which is also part of the data definition.
 
bool isDynamic () const
 Retieve information if this element is a dynamic array.
 
bool isAfterDynamic () const
 The element is on a byte position after a dynamic element, the byte position can not be calculated until it is instanciated.
 
OptionalSize getArrayPos () const
 Get the Array Pos, if this element was retrieved via StructTypeAccess::getElementByPath and the operator[].
 
size_t getDeserializedBytePos (size_t array_pos=0) const
 Get the Deserialized Byte Pos relative to the first byte position of the struct obtained by dd::DataDefinition::getStructTypeAccess.
 
size_t getDeserializedByteSize () const
 Get the Byte size (depends on alignments, ddlversion and arraysize)
 
size_t getDeserializedTypeByteSize () const
 Get the Serialized Type Byte size.
 
size_t getDeserializedTypeAlignedByteSize () const
 Get the Serialized Type Byte size aligned.
 
size_t getSerializedBytePos (size_t array_pos=0) const
 Get SerializedBytePos obtained by dd::DataDefinition::getStructTypeAccess.
 
size_t getSerializedBitOffset (size_t array_pos=0) const
 Get SerializedBitOffset.
 
size_t getSerializedBitSize () const
 Get the serialized Bit size of the value.
 
size_t getSerializedTypeBitSize () const
 Get the serialized bit size of one element.
 
bool hasValidElementCount () const
 
const std::string & getValidElementCount () const
 
const_iterator cbegin () const
 Get the begin const iterator to the array elements of this element access.
 
const_iterator cend () const
 Get the end const iterator to the array elements of this element access.
 
const_iterator begin () const
 Get the begin const iterator to the array elements of this element access.
 
const_iterator end () const
 Get the end const iterator to the array elements of this element access.
 

Friends

class StructTypeAccess
 
class StructElementAccessIterator
 
class StructArrayElementAccessIterator
 

Detailed Description

Class to access and obtain the byte position and other information of a instance of this element within a struct (see StructTypeAccess).

Consider getLeafLayout functionality to retrieve a leaf layout structure for this element if it is a leaf element. This enables fast access to the content with ddl::codec::ValueSetter::setLeafValue, ddl::codec::ValueGetter::getLeafValue on a memory buffer.

Constructor & Destructor Documentation

◆ StructElementAccess()

ddl::dd::StructElementAccess::StructElementAccess ( std::nullptr_t )

empty element access. This kind of element access will be returned, if i.e. StructTypeAccess::getElementByPath can not find the given path.

See also
operator bool()

Member Function Documentation

◆ begin()

const_iterator ddl::dd::StructElementAccess::begin ( ) const

Get the begin const iterator to the array elements of this element access.

Returns
const_iterator the begin const iterator to the array elements of this element access.

◆ cbegin()

const_iterator ddl::dd::StructElementAccess::cbegin ( ) const

Get the begin const iterator to the array elements of this element access.

Returns
const_iterator the begin const iterator to the array elements of this element access.

◆ cend()

const_iterator ddl::dd::StructElementAccess::cend ( ) const

Get the end const iterator to the array elements of this element access.

Returns
const_iterator the end const iterator to the array elements of this element access.

◆ end()

const_iterator ddl::dd::StructElementAccess::end ( ) const

Get the end const iterator to the array elements of this element access.

Returns
const_iterator the end const iterator to the array elements of this element access.

◆ getArrayElement()

StructElementAccess ddl::dd::StructElementAccess::getArrayElement ( size_t array_pos = 0) const

Retrieves an element with byte and bit offsets for the given array position.

Parameters
array_posthe array position to retrieve the element access for (default is 0)
Remarks
The array position must be valid (less than array size).
Returns
Retrieves an array element access of the given array position.

◆ getArrayPos()

OptionalSize ddl::dd::StructElementAccess::getArrayPos ( ) const

Get the Array Pos, if this element was retrieved via StructTypeAccess::getElementByPath and the operator[].

Returns
valid OptionalSize if it was a array position
invalid OptionalSize if it was not a array position or the array position was not valid.

◆ getArraySize()

size_t ddl::dd::StructElementAccess::getArraySize ( ) const

Retrieves the array size if the element is an static array type.

Return values
0if it is an dynamic array type
1or above if it is an static array type or a single element (array size = 1)

◆ getDataType()

std::shared_ptr< const datamodel::DataType > ddl::dd::StructElementAccess::getDataType ( ) const

Gets the Data Type if the element is dependent on a datatype.

Returns
std::shared_ptr<const datamodel::DataType> with a valid datatype if type of element is a datatype
std::shared_ptr<const datamodel::DataType>() (empty) if element does not depend on a datatype

◆ getDeserializedBytePos()

size_t ddl::dd::StructElementAccess::getDeserializedBytePos ( size_t array_pos = 0) const

Get the Deserialized Byte Pos relative to the first byte position of the struct obtained by dd::DataDefinition::getStructTypeAccess.

Returns
valid size with a byte position
0 if is after a dynamic content, the byte pos can only be determined with a ddl::codec::Decoder or ddl::codec::Codec

◆ getDeserializedByteSize()

size_t ddl::dd::StructElementAccess::getDeserializedByteSize ( ) const

Get the Byte size (depends on alignments, ddlversion and arraysize)

Returns
valid size with a byte size
0 if it is a dynamic content (static part only)

◆ getDeserializedTypeAlignedByteSize()

size_t ddl::dd::StructElementAccess::getDeserializedTypeAlignedByteSize ( ) const

Get the Serialized Type Byte size aligned.

Returns
aligned size with a byte size static part only!

◆ getDeserializedTypeByteSize()

size_t ddl::dd::StructElementAccess::getDeserializedTypeByteSize ( ) const

Get the Serialized Type Byte size.

Returns
size with a byte size (static part only)!

◆ getElement()

const datamodel::StructType::Element & ddl::dd::StructElementAccess::getElement ( ) const

Get the Element Information which is also part of the data definition.

Returns
const datamodel::StructType::Element&

◆ getEnumType()

std::shared_ptr< const datamodel::EnumType > ddl::dd::StructElementAccess::getEnumType ( ) const

Gets the Enum Type if the element is dependent on a enumtype.

Returns
std::shared_ptr<const datamodel::EnumType> with a valid enumtype if type of element is a enumtype
std::shared_ptr<const datamodel::EnumType>() (empty) if element does not depend on a enumtype

◆ getName()

std::string ddl::dd::StructElementAccess::getName ( ) const

Retrieves the name of the element. if the element is part of an array, the name contains also the array position.

◆ getSerializedBitOffset()

size_t ddl::dd::StructElementAccess::getSerializedBitOffset ( size_t array_pos = 0) const

Get SerializedBitOffset.

Returns
valid bit offset pos
0 if is after a dynamic content, the bit offset pos can only be determined with a ddl::codec::Decoder or ddl::codec::Codec

◆ getSerializedBitSize()

size_t ddl::dd::StructElementAccess::getSerializedBitSize ( ) const

Get the serialized Bit size of the value.

Returns
valid bit size with (static part only)
0 if it is or after a dynamic content

◆ getSerializedBytePos()

size_t ddl::dd::StructElementAccess::getSerializedBytePos ( size_t array_pos = 0) const

Get SerializedBytePos obtained by dd::DataDefinition::getStructTypeAccess.

Returns
valid byte pos
0 if is after a dynamic content, the byte pos can only be determined with a ddl::codec::Decoder or ddl::codec::Codec

◆ getSerializedTypeBitSize()

size_t ddl::dd::StructElementAccess::getSerializedTypeBitSize ( ) const

Get the serialized bit size of one element.

Returns
valid bit size (static part only)

◆ getStructType()

std::shared_ptr< const datamodel::StructType > ddl::dd::StructElementAccess::getStructType ( ) const

Gets the Struct Type if the element is dependent on a structtype.

Returns
std::shared_ptr<const datamodel::StructType> with a valid structtype if type of element is a structtype
std::shared_ptr<const datamodel::StructType>() (empty) if element does not depend on a structtype

◆ getStructTypeAccess()

StructTypeAccess ddl::dd::StructElementAccess::getStructTypeAccess ( size_t array_pos = 0) const

Get the Struct Type Access if the element depends on a structtype. All byte positions within the returned StructTypeAccess are relativ to the elements StructTypeAccess parent.

Parameters
array_posthe array position to retrieve the struct type access for (default is 0) an array_pos of static_cast<size_t>(-1) can be used to retrieve an StructTypeAccess, where all offsets are reset to 0.
Remarks
Usually the array_pos is not needed by using the StructTypeElementIterator or forEachStructElementAccess helper function.
Usually the array_pos is not needed by using the StructTypeElementIterator or forEachStructElementAccess helper function.
Returns
StructTypeAccess of the struct can also retrieved by getStructType.
See also
getStructType
getLeafLayout

◆ getTypeOfType()

TypeOfType ddl::dd::StructElementAccess::getTypeOfType ( ) const

Get the Type Of the type. Retrieves the information of the elements type.

Return values
TypeOfType

◆ getValidElementCount()

const std::string & ddl::dd::StructElementAccess::getValidElementCount ( ) const

Retrieves the name of the valid element count (if not applicable, an empty string is returned)

Returns
const std::string& name of the valid element count

◆ hasValidElementCount()

bool ddl::dd::StructElementAccess::hasValidElementCount ( ) const

Determines if the element has a valid element count (not dynamic)

Returns
true has valid element count

◆ isAfterDynamic()

bool ddl::dd::StructElementAccess::isAfterDynamic ( ) const

The element is on a byte position after a dynamic element, the byte position can not be calculated until it is instanciated.

Return values
truethe element is after a dynamic content.
falsethe element is not after dynamic content
See also
isDynamic

◆ isArray()

bool ddl::dd::StructElementAccess::isArray ( ) const

Determines if the element is an array type.

Returns
true is an static array type return false is not an array type or it is a dynamic array type

◆ isDynamic()

bool ddl::dd::StructElementAccess::isDynamic ( ) const

Retieve information if this element is a dynamic array.

Return values
truethe element is dynamic or it contains dynamic content.
falsethe element is not dynamic.

◆ isLeaf()

bool ddl::dd::StructElementAccess::isLeaf ( ) const

Determines if the element is a leaf type (no struct, no array).

Returns
true is a leaf return false is not a leaf

◆ isStruct()

bool ddl::dd::StructElementAccess::isStruct ( ) const

Determines if the element is an struct type.

Returns
true is an static struct type return false is not an struct type

◆ operator bool()

ddl::dd::StructElementAccess::operator bool ( ) const

Retrieve if the StructElementAccess is valid or not!

Remarks
Any call except DTOR or move assigned on an invalid StructElementAccess is undefined behavior!
Return values
trueis valid
falseis not valid

◆ operator=() [1/2]

StructElementAccess & ddl::dd::StructElementAccess::operator= ( const StructElementAccess & )

Default copy assignment.

Returns
StructElementAccess& reference

◆ operator=() [2/2]

StructElementAccess & ddl::dd::StructElementAccess::operator= ( StructElementAccess && )
noexcept

Default move assignment.

Returns
StructElementAccess& reference

The documentation for this class was generated from the following file: