15 #ifndef DDL_SERIALIZER_CLASS_HEADER
16 #define DDL_SERIALIZER_CLASS_HEADER
19 #include <ddl/codec/codec.h>
56 template <
typename DECODER,
typename ENCODER>
61 size_t current_element_count = 0;
62 std::function<void(
const typename DECODER::Element& element)> transform_value;
64 transform_value = std::function<void(const typename DECODER::Element& element)>(
65 [¤t_element_count, &encoder](
const typename DECODER::Element& element) {
66 uint64_t value_pointer = {};
68 element.getRawValue(&value_pointer,
sizeof(value_pointer));
69 encoder.setElementRawValue(encoder.resolve(current_element_count++),
71 sizeof(value_pointer));
75 transform_value = std::function<void(const typename DECODER::Element& element)>(
76 [¤t_element_count, &encoder](
const typename DECODER::Element& element) {
77 encoder.setElementVariantValue(encoder.resolve(current_element_count++),
78 element.getVariantValue());
83 std::string(
"Invalid transform_option given: " +
89 [&transform_value, &encoder](
const auto& element) { transform_value(element); });
91 catch (
const std::exception& oException) {
105 template <
typename DECODER,
typename ENCODER>
Memory buffer class to encapsulate and manage raw contiguously memory.
A common result class usable as return value throughout.
Decoder for dynamic structures defined by a DataDefinition definition.
#define RETURN_ERROR_DESCRIPTION(_errcode,...)
Return an a_util::result::Result object with detailed error information.
cString to_string(const tResult &i_oResult, eResultFormatFlags i_eFormatFlags=eResultFormatFlags::RFF_DisableNone, const tChar *i_strFormat=nullptr)
Copy all information of an assigned result object to a (formatted) string.
bool zero(void *dest, std::size_t dest_size, std::size_t bytes_to_zero)
Portable safe memzero.
a_util::result::Result 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...
_MAKE_RESULT(-3, ERR_AUTIL_UNEXPECTED)
Creates an a_util error ERR_AUTIL_UNEXPECTED.
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.
a_util::result::Result 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.
TransformOption
The transform options for transform.
@ by_value
Transform each element by value.
@ by_memory
Transform each element by memory.
definition of the ddl namespace
Implementation of the ADTF default media description.
Utility for the Neutrino gcc5 compiler which has really no std::to_string implementation!
Common include for component a_util::result.