Dev Essential  1.6.3
Loading...
Searching...
No Matches
ddl::codec::Decoder Class Reference

#include <codec.h>

Inherits ddl::codec::StaticDecoder.

Inherited by ddl::codec::Codec.

Public Types

typedef DecoderElement< DecoderElementAccess< const Decoder > > Element
 
typedef ChildElements< DecoderElementAccess< const Decoder > > Elements
 
- Public Types inherited from ddl::codec::StaticDecoder
typedef DecoderElement< DecoderElementAccess< const StaticDecoder > > Element
 
typedef ChildElements< DecoderElementAccess< const StaticDecoder > > Elements
 

Public Member Functions

 Decoder ()
 
 Decoder (Decoder &&)
 
Decoderoperator= (Decoder &&)
 
 Decoder (const Decoder &)=delete
 
Decoderoperator= (const Decoder &)=delete
 
a_util::result::Result isValid () const override
 
Element getElement (const CodecIndex &codec_index) const
 
Element getElement (std::string_view full_path) const
 
Element getChildElement (const CodecIndex &parent_codec_index, std::string_view relative_path) const
 
const ElementsgetElements () const
 
size_t getBufferSize () const
 Gets the buffer size in bytes for the main structure.
 
size_t getBufferSize (DataRepresentation representation) const
 Gets the buffer size in bytes for the main structure.
 
Codec makeCodecFor (void *data, size_t data_size, DataRepresentation representation) const
 
- Public Member Functions inherited from ddl::codec::StaticDecoder
 ~StaticDecoder ()=default
 DTOR.
 
 StaticDecoder ()
 
 StaticDecoder (const StaticDecoder &)=delete
 
StaticDecoderoperator= (const StaticDecoder &)=delete
 
 StaticDecoder (StaticDecoder &&)
 
StaticDecoderoperator= (StaticDecoder &&)
 
Element getElement (const CodecIndex &codec_index) const
 
Element getElement (std::string_view full_path) const
 
Element getChildElement (const CodecIndex &parent_codec_index, std::string_view relative_path) const
 
const ElementsgetElements () const
 
size_t getElementChildCount (const CodecIndex &codec_index=CodecIndex()) const
 
std::string getElementFullName (const CodecIndex &codec_index) const
 Retrieves the full name of the element within its main structure.
 
std::string getElementName (const CodecIndex &codec_index) const
 Retrieves the name of the element within its structured element.
 
const std::string & getElementBaseName (const CodecIndex &codec_index) const
 Retrieves the base name of the element within its structured element.
 
template<typename T>
getElementValue (const CodecIndex &codec_index) const
 
template<typename T>
getElementValue (const LeafCodecIndex &leaf_codec_index) const
 
a_util::variant::Variant getElementVariantValue (const CodecIndex &codec_index) const
 
void getElementVariantValue (const CodecIndex &codec_index, a_util::variant::Variant &value) const
 
std::string getElementStringValue (const CodecIndex &codec_index) const
 
void getElementRawValue (const CodecIndex &index, void *value, size_t value_size) const
 
const void * getElementAddress (const CodecIndex &index) const
 
size_t getStaticBufferSize () const
 Gets the static buffer size in bytes for the main structure.
 
size_t getStaticBufferSize (DataRepresentation rep) const
 Gets the static buffer size in bytes for the main structure.
 
DataRepresentation getRepresentation () const
 
CodecIndex resolve (size_t leaf_index) const
 
CodecIndex resolve (size_t leaf_index, std::string &element_full_name) const
 
size_t getElementCount () const
 
a_util::result::Result getElement (size_t leaf_index, const ddl::StructElement *&legacy_struct_element) const
 
void resolve (CodecIndex &codec_index) const
 
const void * getData () const noexcept
 Get the current set data.
 
size_t getDataSize () const noexcept
 Get the current size (in bytes) of the data.
 

Protected Member Functions

 Decoder (std::shared_ptr< const StructAccess > codec_access, const void *data, size_t data_size, DataRepresentation representation)
 For internal use only.
 
 Decoder (const Decoder &decoder, const void *data, size_t data_size, DataRepresentation representation)
 For internal use only.
 
- Protected Member Functions inherited from ddl::codec::StaticDecoder
 StaticDecoder (std::shared_ptr< const StructAccess > codec_access, const void *data, size_t data_size, DataRepresentation representation)
 For internal use only.
 

Friends

class CodecFactory
 
class FactoryElementAccess< const Decoder >
 For internal use only.
 

Additional Inherited Members

- Protected Attributes inherited from ddl::codec::StaticDecoder
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.
 

Detailed Description

Decoder for dynamic structures defined by a DataDefinition definition.

Member Typedef Documentation

◆ Element

◆ Elements

Iterator container to iterate all elements of the decoder and get values.

See also
forEachLeafElement, forEachElement, ddl::codec::ChildElements, Decoder::Element

Constructor & Destructor Documentation

◆ Decoder() [1/3]

ddl::codec::Decoder::Decoder ( )

Default constructor.

◆ Decoder() [2/3]

ddl::codec::Decoder::Decoder ( Decoder && )

Move constructor.

◆ Decoder() [3/3]

ddl::codec::Decoder::Decoder ( const Decoder & )
delete

No copy constructor.

Member Function Documentation

◆ getBufferSize() [1/2]

size_t ddl::codec::Decoder::getBufferSize ( ) const

Gets the buffer size in bytes for the main structure.

Return values
size_tof the structure depending on the current representation (getRepresentation)

◆ getBufferSize() [2/2]

size_t ddl::codec::Decoder::getBufferSize ( DataRepresentation representation) const

Gets the buffer size in bytes for the main structure.

Parameters
[in]representationThe data representation for which the buffer size should be returned.
Returns
The size of the structure in the requested data representation.

◆ getChildElement()

Element ddl::codec::Decoder::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_indexThe parent codec index.
[in]relative_pathThe 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 Decoder.
Remarks
The element is only valid as long as the Decoder exists.
Exceptions
throwsstd::runtime_error if not found.

◆ getElement() [1/2]

Element ddl::codec::Decoder::getElement ( const CodecIndex & codec_index) const

Retrieves an element instance based on the codec index of that element.

Parameters
[in]codec_indexThe codec index.
Returns
The DecoderElement for the given codec index.
Remarks
The element is only valid as long as the factory exists.
Exceptions
throwsstd::runtime_error if not found.

◆ getElement() [2/2]

Element ddl::codec::Decoder::getElement ( std::string_view full_path) const

Retrieves an element instance based on the full name of the element.

Parameters
[in]full_pathThe 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.
Remarks
The element is only valid as long as the factory exists.
Exceptions
throwsstd::runtime_error if not found.

◆ getElements()

const Elements & ddl::codec::Decoder::getElements ( ) const

Retrieves the elements of the decoder to get element information and get values.

Returns
Elements The elements iterator container.
See also
forEachLeafElement, forEachElement, Decoder::Element, CodecIndex

◆ isValid()

a_util::result::Result ddl::codec::Decoder::isValid ( ) const
overridevirtual

Returns
Whether or not the decoder is valid.
Return values
ERR_INVALID_ARGThe passed data is not large enough.

Reimplemented from ddl::codec::StaticDecoder.

◆ makeCodecFor()

Codec ddl::codec::Decoder::makeCodecFor ( void * data,
size_t data_size,
DataRepresentation representation ) const

Create a new codec with the current dynamic structure layout for a new data buffer.

Parameters
[in]dataThe pointer to the new raw data.
[in]data_sizeThe size of the new raw data.
[in]representationThe representation that the data should be encoded in.
Returns
A codec.

◆ operator=() [1/2]

Decoder & ddl::codec::Decoder::operator= ( const Decoder & )
delete

No copy assignment operator.

◆ operator=() [2/2]

Decoder & ddl::codec::Decoder::operator= ( Decoder && )

Move assignment operator.


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