ADTF  3.18.2
serialization_legacy.h
Go to the documentation of this file.
1 
15 #ifndef DDL_SERIALIZER_LEGACY_CLASS_HEADER
16 #define DDL_SERIALIZER_LEGACY_CLASS_HEADER
17 
18 #include <a_util/result.h>
20 
21 #include <assert.h>
22 
23 namespace ddl {
24 namespace serialization {
31 template <typename DECODER, typename ENCODER>
32 a_util::result::Result transform(const DECODER& decoder, ENCODER& encoder)
33 {
34  size_t element_count = decoder.getElementCount();
35  assert(element_count == encoder.getElementCount());
36  for (size_t element = 0; element < element_count; ++element) {
37  uint64_t buffer = 0;
38  a_util::result::Result result = decoder.getElementValue(element, &buffer);
39  if (!result) {
40  return result;
41  }
42 
43  result = encoder.setElementValue(element, &buffer);
44  if (!result) {
45  return result;
46  }
47  }
48 
49  return a_util::result::SUCCESS;
50 }
51 
62  bool zero = false);
63 
64 } // namespace serialization
65 } // namespace ddl
66 
67 #endif // DDL_SERIALIZER_LEGACY_CLASS_HEADER
Memory buffer class to encapsulate and manage raw contiguously memory.
Definition: memorybuffer.h:23
A common result class usable as return value throughout.
Decoder for dynamic structures defined by a DataDefinition definition.
Definition: codec_legacy.h:46
Definition of old Codec legacy header for old Codec API.
bool zero(void *dest, std::size_t dest_size, std::size_t bytes_to_zero)
Portable safe memzero.
a_util::result::Result transformToBuffer(const Decoder &decoder, a_util::memory::MemoryBuffer &buffer, bool zero=false)
Tranforms the data from a given decoder into the opposite data representation.
a_util::result::Result transform(const DECODER &decoder, ENCODER &encoder)
Copies all elements from a decoder to a codec.
Common include for component a_util::result.