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

Namespace for the new faster CodecFactory/Decoder/Codec implementation. More...

Classes

class  ChildElements
 Iteratable container type for the given Element type in ElementAccessType::element_type. More...
 
class  Codec
 
class  CodecConstantInfo
 The constant info of a element. More...
 
class  CodecDefaultValueInfo
 The default value info of a element. More...
 
class  CodecElement
 A CodecElement to get and set values. More...
 
class  CodecElementAccess
 A element access type concept template to retrieve element information from the AccessType, get and set the element value. This class is to retrieve common information of the element, get and set the element value content. More...
 
class  CodecFactory
 
class  CodecIndex
 
class  CodecTypeInfo
 Description of the elements Type. More...
 
class  Decoder
 
class  DecoderElement
 A DecoderElement to get values. More...
 
class  DecoderElementAccess
 A element access type concept template to retrieve element information from the AccessType and get the element value. This class is to retrieve common information of the element and get the element value content. More...
 
class  ElementIterator
 The element iterator. More...
 
class  ElementIteratorConst
 The const element iterator. More...
 
struct  ElementLayout
 
struct  ElementLayoutBase
 
class  FactoryElement
 A FactoryElement. More...
 
class  FactoryElementAccess
 A factory element access type concept template to retrieve element information from the AccessType. This class is to retrieve common information of the element. More...
 
class  LeafCodecIndex
 The Leaf codec index is a small layout information index to access the decoders/codecs data very fast. There are following constraints: More...
 
struct  LeafLayout
 small leaf layout information to access codec data very fast. More...
 
struct  LeafValueGetter
 
struct  LeafValueSetter
 
struct  PositionWithAlignedTypeSize
 
struct  PositionWithTypeSize
 
struct  PositionWithUsedBitsTypeSize
 
class  StaticCodec
 
class  StaticDecoder
 
struct  ValueGetter
 
struct  ValueGetter< DecoderType, std::string >
 
struct  ValueGetterSelect
 
struct  ValueGetterSelect< DecoderType, ValueType, true >
 
struct  ValueSetter
 
struct  ValueSetter< CodecType, std::string >
 
struct  ValueSetterSelect
 
struct  ValueSetterSelect< CodecType, ValueType, true >
 

Typedefs

using Position = ddl::Position
 
using AccessEnumType = ddl::AccessEnumType
 This is the legacy Access Type for resolving enum names.
 

Enumerations

enum class  ElementType {
  cet_empty = a_util::variant::VariantType::VT_Empty , cet_bool = a_util::variant::VariantType::VT_Bool , cet_int8 = a_util::variant::VariantType::VT_Int8 , cet_uint8 = a_util::variant::VariantType::VT_UInt8 ,
  cet_int16 = a_util::variant::VariantType::VT_Int16 , cet_uint16 = a_util::variant::VariantType::VT_UInt16 , cet_int32 = a_util::variant::VariantType::VT_Int32 , cet_uint32 = a_util::variant::VariantType::VT_UInt32 ,
  cet_int64 = a_util::variant::VariantType::VT_Int64 , cet_uint64 = a_util::variant::VariantType::VT_UInt64 , cet_float = a_util::variant::VariantType::VT_Float , cet_double = a_util::variant::VariantType::VT_Double ,
  cet_sub_codec = cet_double + 1 , cet_user_type = cet_sub_codec + 1
}
 The element type of the value. More...
 
enum class  LeafDataRepresentation : uint8_t { deserialized = 0x00 , serialized = 0x01 , serialized_be = 0x03 , serialized_le = 0x01 }
 LeafLayout data representation flags. More...
 
enum class  LeafElementType : uint8_t {
  let_bool = static_cast<uint8_t>(ElementType::cet_bool) , let_int8 = static_cast<uint8_t>(ElementType::cet_int8) , let_uint8 , let_int16 ,
  let_uint16 , let_int32 , let_uint32 , let_int64 ,
  let_uint64 , let_float = static_cast<uint8_t>(ElementType::cet_float) , let_double = static_cast<uint8_t>(ElementType::cet_double)
}
 
enum class  TransformOption : uint32_t { by_memory = 0 , by_value = 1 }
 

Functions

template<typename T>
std::vector< CodecIndexgetCodecIndices (const T &decoder_or_factory)
 Retrieves all codec indices for the given codec of type T.
 
template<typename T>
std::vector< LeafCodecIndexgetLeafCodecIndices (const T &decoder_or_factory, ddl::DataRepresentation rep)
 Get the leaf indices object.
 
std::string toString (const CodecIndex &index)
 Converts the index to a string.
 
template<typename ElementsType>
void forEachLeafElement (ElementsType &elements, const std::function< void(std::conditional_t< std::is_const< ElementsType >::value, const typename ElementsType::element_type, typename ElementsType::element_type > &)> &func)
 Iterates ALL leaf elements within ALL array elements.
 
template<typename ElementsType>
void forEachElement (ElementsType &elements, const std::function< void(std::conditional_t< std::is_const< ElementsType >::value, const typename ElementsType::element_type, typename ElementsType::element_type > &)> &func)
 Iterates elements without array elements (also structures).
 
 _MAKE_RESULT (-3, ERR_AUTIL_UNEXPECTED)
 Creates an a_util error ERR_AUTIL_UNEXPECTED.
 
template<typename DECODER, typename ENCODER>
a_util::result::Result transform (const DECODER &decoder, ENCODER &encoder, const TransformOption transform_option)
 
template<typename DECODER, typename ENCODER>
a_util::result::Result transform (const DECODER &decoder, ENCODER &encoder)
 
a_util::result::Result transformToBuffer (const codec::Decoder &decoder, a_util::memory::MemoryBuffer &buffer, bool zero=false)
 

Detailed Description

Namespace for the new faster CodecFactory/Decoder/Codec implementation.

Typedef Documentation

◆ Position

Binary compatible reusing of structure for position of elements

Enumeration Type Documentation

◆ ElementType

enum class ddl::codec::ElementType
strong

The element type of the value.

Enumerator
cet_empty 

Variant type is empty.

cet_bool 

Variant type is bool.

cet_int8 

Variant type is std::int8_t.

cet_uint8 

Variant type is std::uint8_t.

cet_int16 

Variant type is std::int16_t.

cet_uint16 

Variant type is std::uint16_t.

cet_int32 

Variant type is std::int32_t.

cet_uint32 

Variant type is std::uint32_t.

cet_int64 

Variant type is std::int64_t.

cet_uint64 

Variant type is std::uint64_t.

cet_float 

Variant type is float.

cet_double 

Variant type is double.

cet_sub_codec 

type marks a subcodec/substructure with children

cet_user_type 

type marks a user defined type

◆ LeafDataRepresentation

enum class ddl::codec::LeafDataRepresentation : uint8_t
strong

LeafLayout data representation flags.

Enumerator
deserialized 

first bit is zero for deserialized data representation of the LeafCodecIndex::data_flags

serialized 

first bit is set for serialized data representation of the LeafCodecIndex::data_flags

serialized_be 

first and second bit is set for serialized data representation in big endianess of the LeafCodecIndex::data_flags

serialized_le 

first bit is set second bit is not set for serialized data representation in little endianess of the LeafCodecIndex::data_flags

◆ LeafElementType

enum class ddl::codec::LeafElementType : uint8_t
strong

Valid ElementTypes for the LeafLayout

Enumerator
let_bool 

LeafElementType type is bool.

let_int8 

LeafElementType type is std::int8_t.

let_uint8 

LeafElementType type is std::uint8_t.

let_int16 

LeafElementType type is std::int16_t.

let_uint16 

LeafElementType type is std::uint16_t.

let_int32 

LeafElementType type is std::int32_t.

let_uint32 

LeafElementType type is std::uint32_t.

let_int64 

LeafElementType type is std::int64_t.

let_uint64 

LeafElementType type is std::uint64_t.

let_float 

LeafElementType type is float.

let_double 

LeafElementType type is double.

◆ TransformOption

enum class ddl::codec::TransformOption : uint32_t
strong

The transform options for transform

Enumerator
by_memory 

Transform each element by memory.

by_value 

Transform each element by value.

Function Documentation

◆ forEachElement()

template<typename ElementsType>
void ddl::codec::forEachElement ( ElementsType & elements,
const std::function< void(std::conditional_t< std::is_const< ElementsType >::value, const typename ElementsType::element_type, typename ElementsType::element_type > &)> & func )

Iterates elements without array elements (also structures).

Usage:

//description contains a data description where "my_struct" is defined
struct my_sub_struct
{
uint32_t sub_element[3];
uint32_t sub_element_after;
}
struct my_struct
{
my_sub_struct element[2];
}
CodecFactory factory("my_struct", description);
forEachElement(factory.getElements(),
[](const auto& element) {
std::cout << element.getFullName() << std::endl;
std::cout << element.getName() << std::endl;
std::cout << element.getBaseName() << std::endl;
std::cout << element.getArraySize() << std::endl;
});
//following output:
//"element[0]"
//"element[0]"
//"element"
//"2"
//"element[0].sub_element[0]"
//"sub_element[0]"
//"sub_element"
//"3"
//"element[0].sub_element_after"
//"sub_element_after"
//"sub_element_after"
//"1"
void forEachElement(ElementsType &elements, const std::function< void(std::conditional_t< std::is_const< ElementsType >::value, const typename ElementsType::element_type, typename ElementsType::element_type > &)> &func)
Iterates elements without array elements (also structures).
Definition codec_iterator.h:1554
Template Parameters
ElementsTypeThe type of elements.
Parameters
elementsThe elements
funcThe function to call per leaf element
See also
CodecFactory::getElements, Codec::getElements, Decoder::getElements, StaticCodec::getElements, StaticDecoder::getElements

◆ forEachLeafElement()

template<typename ElementsType>
void ddl::codec::forEachLeafElement ( ElementsType & elements,
const std::function< void(std::conditional_t< std::is_const< ElementsType >::value, const typename ElementsType::element_type, typename ElementsType::element_type > &)> & func )

Iterates ALL leaf elements within ALL array elements.

Usage:

//description contains a data description where "my_struct" is defined
struct my_sub_struct
{
uint32_t sub_element[3];
uint32_t sub_element_after;
}
struct my_struct
{
my_sub_struct element[2];
}
CodecFactory factory("my_struct", strDescription);
forEachLeafElement(factory.getElements(),
[](const auto& element) {
std::cout << element.getFullName() << std::endl;
});
//following output:
//"element[0].sub_element[0]"
//"element[0].sub_element[1]"
//"element[0].sub_element[2]"
//"element[0].sub_element_after"
//"element[1].sub_element[0]"
//"element[1].sub_element[1]"
//"element[1].sub_element[2]"
//"element[1].sub_element_after"
void forEachLeafElement(ElementsType &elements, const std::function< void(std::conditional_t< std::is_const< ElementsType >::value, const typename ElementsType::element_type, typename ElementsType::element_type > &)> &func)
Iterates ALL leaf elements within ALL array elements.
Definition codec_iterator.h:1475
Template Parameters
ElementsTypeThe type of elements.
Parameters
elementsThe elements
funcThe function to call per leaf element
See also
CodecFactory::getElements, Codec::getElements, Decoder::getElements, StaticCodec::getElements, StaticDecoder::getElements

◆ getCodecIndices()

template<typename T>
std::vector< CodecIndex > ddl::codec::getCodecIndices ( const T & decoder_or_factory)

Retrieves all codec indices for the given codec of type T.

Template Parameters
TThe codec type or factory.
Parameters
[in]decoder_or_factorythe codec or factory of type T
Returns
std::vector<CodecIndex> the codec indices

◆ getLeafCodecIndices()

template<typename T>
std::vector< LeafCodecIndex > ddl::codec::getLeafCodecIndices ( const T & decoder_or_factory,
ddl::DataRepresentation rep )

Get the leaf indices object.

Template Parameters
TThe type of the decoder or factory to retrieve all leaf indices from.
Parameters
decoder_or_factoryThe decoder or factory to retrieve all indices from.
repThe data representation to extract the leaf codec index for
Returns
std::vector<LeafCodecIndex>
See also
LeafCodecIndex

◆ toString()

std::string ddl::codec::toString ( const CodecIndex & index)

Converts the index to a string.

Parameters
indexthe index to convert
Returns
std::string

◆ transform() [1/2]

template<typename DECODER, typename ENCODER>
a_util::result::Result ddl::codec::transform ( const DECODER & decoder,
ENCODER & encoder )

Copies all elements memory content from decoder elements to codec elements. The encoders element count must be at least decoders element count or greater, otherwise it fails with an error result.

Remarks
This transfrom is there for lagacy reason and uses TransformOption::by_memory by default.
Parameters
[in]decoderThe source decoder.
[out]encoderThe destination codec.
Returns
Standard result.

◆ transform() [2/2]

template<typename DECODER, typename ENCODER>
a_util::result::Result ddl::codec::transform ( const DECODER & decoder,
ENCODER & encoder,
const TransformOption transform_option )

Copies all elements memory content from decoder elements to codec elements The encoders element count must be at least decoders element count or greater, otherwise it fails with an error result.

Parameters
[in]decoderThe source decoder.
[out]encoderThe destination codec.
[in]transform_optionuse TransformOption::by_memory for values with same type only. use TransformOption::by_value for transform different types.
Returns
Standard result.

◆ transformToBuffer()

a_util::result::Result ddl::codec::transformToBuffer ( const codec::Decoder & decoder,
a_util::memory::MemoryBuffer & buffer,
bool zero = false )

Tranforms the data from a given decoder into the opposite data representation. Allocates the buffer accordingly.

Parameters
[in]decoderThe source decoder.
[out]bufferThe destination buffer object.
[in]zeroWhether or not to memzero the buffer before writing the elements to it.
Returns
Standard result.