#include <static_codec.h>
Inherited by ddl::codec::Decoder, and ddl::codec::StaticCodec.
|
|
| StaticDecoder (std::shared_ptr< const StructAccess > codec_access, const void *data, size_t data_size, DataRepresentation representation) |
| | For internal use only.
|
| |
|
|
std::shared_ptr< const StructAccess > | _codec_access |
| | For internal use only.
|
| |
|
const void * | _data = nullptr |
| | For internal use only.
|
| |
|
size_t | _data_size = 0 |
| | For internal use only.
|
| |
|
const ddl::codec::ElementAccessor * | _element_accessor |
| | For internal use only.
|
| |
Decoder for static structures defined by a DataDefinition definition.
◆ Element
◆ Elements
◆ StaticDecoder() [1/3]
| ddl::codec::StaticDecoder::StaticDecoder |
( |
| ) |
|
◆ StaticDecoder() [2/3]
| ddl::codec::StaticDecoder::StaticDecoder |
( |
const StaticDecoder & | | ) |
|
|
delete |
◆ StaticDecoder() [3/3]
◆ getChildElement()
| Element ddl::codec::StaticDecoder::getChildElement |
( |
const CodecIndex & | parent_codec_index, |
|
|
std::string_view | relative_path ) const |
Retrieves an element instance based on the child name of the element.
- Parameters
-
| [in] | parent_codec_index | The parent codec index. |
| [in] | relative_path | The child name of the element in point notation (i.e. "child_element[4].element_value"). |
By using an empty string the deserialized decoding information within CodecIndex will retrieve the same codec index as it is before.
- Returns
- The child Codec Index of the StaticDecoder.
- Exceptions
-
| throws | std::runtime_error if not found. |
◆ getData()
| const void * ddl::codec::StaticDecoder::getData |
( |
| ) |
const |
|
noexcept |
Get the current set data.
- Returns
- const void* The data pointer
◆ getDataSize()
| size_t ddl::codec::StaticDecoder::getDataSize |
( |
| ) |
const |
|
noexcept |
Get the current size (in bytes) of the data.
- Returns
- size_t
◆ getElement() [1/3]
| Element ddl::codec::StaticDecoder::getElement |
( |
const CodecIndex & | codec_index | ) |
const |
Retrieves an element instance based on the codec index of that element.
- Parameters
-
| [in] | codec_index | The codec index. |
- Returns
- The Codec Index of the DecoderElement.
- Exceptions
-
| throws | std::runtime_error if not found. |
◆ getElement() [2/3]
Returns the StructElement of the element with given leaf index.
- Parameters
-
| [in] | leaf_index | The leaf index of the element. |
| [out] | legacy_struct_element | the struct element legacy description. |
- Returns
- The amount of static elements contained in the handled structure.
◆ getElement() [3/3]
| Element ddl::codec::StaticDecoder::getElement |
( |
std::string_view | full_path | ) |
const |
Retrieves an element instance based on the full name of the element.
- Parameters
-
| [in] | full_path | The full name of the element in point notation (i.e. "element1.child_element[4].element_value"). |
By using an empty string the deserialized decoding information within CodecIndex will retrieve the buffers first address and whole buffersize. By refering an array without dedicated array index position the deserialized decoding information within CodecIndex will be set to the arrays first address and the whole array size. By refering an structured value (not a leaf value) the deserialized decoding information within CodecIndex will be set to the structs first address and the whole struct size.
- Returns
- The Codec Index of the DecoderElement.
- Exceptions
-
| throws | std::runtime_error if not found. |
◆ getElementAddress()
| const void * ddl::codec::StaticDecoder::getElementAddress |
( |
const CodecIndex & | index | ) |
const |
- Parameters
-
| [in] | index | The index of the element. |
- Returns
- A pointer to the element or nullptr in case of an error.
◆ getElementBaseName()
| const std::string & ddl::codec::StaticDecoder::getElementBaseName |
( |
const CodecIndex & | codec_index | ) |
const |
Retrieves the base name of the element within its structured element.
If the element is an array you get the elements base name representation : "element_name" for each array element. If the element is not an array you get the elements name representation is also the base name representation: "element_name" .
- Parameters
-
| [in] | codec_index | The codec index of the element. |
- Returns
- The base name of the element.
- Exceptions
-
| throws | std::runtime_error if not found. |
◆ getElementChildCount()
| size_t ddl::codec::StaticDecoder::getElementChildCount |
( |
const CodecIndex & | codec_index = CodecIndex() | ) |
const |
Retrieves the amount of child elements for the given codec index.
- Parameters
-
| [in] | codec_index | The codec index of the element. |
- Return values
-
| 0 | has no children. May be a leaf element. |
| >0 | has children. May be a structured element. |
- Exceptions
-
| throws | std::runtime_error if not found. |
◆ getElementCount()
| size_t ddl::codec::StaticDecoder::getElementCount |
( |
| ) |
const |
is the leaf count
- Returns
- The amount of leaf elements contained in the data structure.
◆ getElementFullName()
| std::string ddl::codec::StaticDecoder::getElementFullName |
( |
const CodecIndex & | codec_index | ) |
const |
Retrieves the full name of the element within its main structure.
If the element is an array you get the elements array name representation: "main_element.element_name[0]" or main_element.element_name[1] ... etc. If the element is not an array you get the elements name representation: "main_element.element_name".
- Parameters
-
| [in] | codec_index | The codec index of the element. |
- Returns
- The full name of the element in array representation depending on array size.
- Exceptions
-
| throws | std::runtime_error if not found. |
◆ getElementName()
| std::string ddl::codec::StaticDecoder::getElementName |
( |
const CodecIndex & | codec_index | ) |
const |
Retrieves the name of the element within its structured element.
If the element is an array you get the elements array name representation: "element_name[0]" or element_name[1] ... etc. If the element is not an array you get the elements name representation: "element_name".
- Parameters
-
| [in] | codec_index | The codec index of the element. |
- Returns
- The name of the element in array representation depending on array size.
- Exceptions
-
| throws | std::runtime_error if not found. |
◆ getElementRawValue()
| void ddl::codec::StaticDecoder::getElementRawValue |
( |
const CodecIndex & | index, |
|
|
void * | value, |
|
|
size_t | value_size ) const |
Returns the current value of the given element as a variant.
- Parameters
-
| [in] | index | The index of the element. |
| [out] | value | The will be set to the current value. |
| [in] | value_size | Size of the memory in value (if set to 0: unsafe usage of value without size check) |
- Exceptions
-
| throws | std::runtime_error if not found. |
◆ getElements()
| const Elements & ddl::codec::StaticDecoder::getElements |
( |
| ) |
const |
◆ getElementStringValue()
| std::string ddl::codec::StaticDecoder::getElementStringValue |
( |
const CodecIndex & | codec_index | ) |
const |
Returns the current value of the given element as a string. If this element is a enum type the enum types element name will be set.
- Parameters
-
| [in] | codec_index | The index of the element. |
- Returns
- std::string String to return the current value to, if enum, enum value name will be set.
- Exceptions
-
| throws | std::runtime_error if not found. |
◆ getElementValue() [1/2]
template<typename T>
| T ddl::codec::StaticDecoder::getElementValue |
( |
const CodecIndex & | codec_index | ) |
const |
|
inline |
Returns the current value of the given element as a T if supported.
- Parameters
-
| [in] | codec_index | The index of the element. |
- Template Parameters
-
| T | The type of the value to retrieve. |
- Returns
- Returns the current value as T if supported.
- Exceptions
-
| throws | std::runtime_error if not found. |
◆ getElementValue() [2/2]
template<typename T>
| T ddl::codec::StaticDecoder::getElementValue |
( |
const LeafCodecIndex & | leaf_codec_index | ) |
const |
|
inline |
Returns the current value of the given element as a T if supported.
- Parameters
-
| [in] | leaf_codec_index | The small leaf codec index of the element. |
- Template Parameters
-
| T | The type of the value to retrieve. |
- Returns
- Returns the current value as T if supported.
- Exceptions
-
| std::runtime_error | if there is no valid conversion or the given leaf_codec_index is invalid |
◆ getElementVariantValue() [1/2]
Returns the current value of the given element as a variant.
- Parameters
-
| [in] | codec_index | The index of the element. |
- Returns
- a_util::variant::Variant Variant to return the current value to, type will be set.
- Exceptions
-
| throws | std::runtime_error if not found. |
◆ getElementVariantValue() [2/2]
Returns the current value of the given element as a variant.
- Parameters
-
| [in] | codec_index | The index of the element. |
| [out] | value | Variant to return the current value to, type will be set. |
- Exceptions
-
| throws | std::runtime_error if not found. |
◆ getRepresentation()
Returns the current data representation the decoder decodes from.
- Returns
- The data representation which this decoder handles.
◆ getStaticBufferSize() [1/2]
| size_t ddl::codec::StaticDecoder::getStaticBufferSize |
( |
| ) |
const |
Gets the static buffer size in bytes for the main structure.
- Returns
- The size in bytes of the structure in the current data representation (getRepresentation).
◆ getStaticBufferSize() [2/2]
Gets the static buffer size in bytes for the main structure.
- Parameters
-
| [in] | rep | The data representation for which the buffer size should be returned. |
- Returns
- The size in bytes of the structure in the requested data representation.
◆ isValid()
- Returns
- Whether or not the decoder is valid.
- Return values
-
| ERR_INVALID_ARG | The passed data is not large enough. |
Reimplemented in ddl::codec::Decoder.
◆ operator=() [1/2]
◆ operator=() [2/2]
Move assignment operator.
◆ resolve() [1/3]
| void ddl::codec::StaticDecoder::resolve |
( |
CodecIndex & | codec_index | ) |
const |
The codec index will be resolved for fast access (layout will be set)
- Parameters
-
| [in] | codec_index | The codec index to resolve. |
- Exceptions
-
| throws | std::runtime_error if not found. |
◆ resolve() [2/3]
| CodecIndex ddl::codec::StaticDecoder::resolve |
( |
size_t | leaf_index | ) |
const |
- Parameters
-
| [in] | leaf_index | The leaf index of the element. |
- Returns
- The Codec Index of the element.
- Exceptions
-
| throws | std::runtime_error if not found. |
◆ resolve() [3/3]
| CodecIndex ddl::codec::StaticDecoder::resolve |
( |
size_t | leaf_index, |
|
|
std::string & | element_full_name ) const |
- Parameters
-
| [in] | leaf_index | The leaf index of the element. |
| [in,out] | element_full_name | the element full name to retrieve. |
- Returns
- The Codec Index of the element.
- Exceptions
-
| throws | std::runtime_error if not found. |
The documentation for this class was generated from the following file: