ADTF  3.18.2
codec_iterator.h
Go to the documentation of this file.
1 
15 #ifndef DDL_CODEC_ITERATOR_CLASS_HEADER
16 #define DDL_CODEC_ITERATOR_CLASS_HEADER
17 
18 #include <a_util/variant.h>
19 #include <ddl/codec/codec_index.h>
20 
21 #include <functional>
22 
23 namespace ddl {
24 namespace codec {
25 
26 // forward declarations
27 template <typename ElementAccessType, typename ChildElementsType>
28 class FactoryElement;
29 template <typename ElementAccessType, typename ChildElementsType>
30 class DecoderElement;
31 template <typename ElementAccessType, typename ChildElementsType>
32 class CodecElement;
33 
41 template <typename ElementAccessType>
43 public:
44  using element_type = typename ElementAccessType::element_type;
46  using reference = value_type&;
47  using const_reference = const value_type&;
48  using pointer = value_type*;
49  using const_pointer = const value_type*;
50  using difference_type = int;
51  using iterator_category = std::forward_iterator_tag;
52 
56  ElementIterator() = delete;
62  ElementIterator(value_type&& element) : _element(std::move(element))
63  {
64  }
71  {
72  next();
73  return *this;
74  }
81  {
82  const auto old_index = _element.getIndex();
83  next();
84  return ElementIterator(old_index, _element.getAccess());
85  }
93  bool operator==(const ElementIterator& rhs) const
94  {
95  return _element.getIndex() == rhs._element.getIndex();
96  }
104  bool operator!=(const ElementIterator& rhs) const
105  {
106  return _element.getIndex() != rhs._element.getIndex();
107  }
114  {
115  return _element;
116  }
123  {
124  return &_element;
125  }
132  {
133  return _element;
134  }
141  {
142  return &_element;
143  }
144 
145 private:
146  void next()
147  {
148  _element.next();
149  }
150  element_type _element;
151 };
152 
160 template <typename ElementAccessType>
162 public:
163  using element_type = typename ElementAccessType::element_type;
164  using value_type = const element_type;
167  using difference_type = int;
168  using iterator_category = std::forward_iterator_tag;
169 
178  ElementIteratorConst(value_type&& element) : _element(std::move(element))
179  {
180  }
186  {
187  next();
188  return *this;
189  }
195  {
196  const auto old_index = _element.getIndex();
197  next();
198  return self_type(old_index, _element.getAccess());
199  }
200 
208  bool operator==(const ElementIteratorConst& rhs) const
209  {
210  return _element.getIndex() == rhs._element.getIndex();
211  }
219  bool operator!=(const ElementIteratorConst& rhs) const
220  {
221  return _element.getIndex() != rhs._element.getIndex();
222  }
229  {
230  return _element;
231  }
238  {
239  return &_element;
240  }
241 
242 private:
243  void next()
244  {
245  _element.next();
246  }
247  element_type _element;
248 };
249 
256 template <typename ElementAccessType>
258 public:
260  using access_type = typename ElementAccessType::access_type;
262  using element_type = typename ElementAccessType::element_type;
265 
269  friend element_type;
273  friend access_type;
286 
299  ChildElements(const ChildElements&) = delete;
308  ~ChildElements() = default;
309 
315  {
316  if (_child_element_count > 0) {
317  CodecIndex begin_index(_codec_base_index, {0, 0});
318  ElementAccessType::resolve(_access, begin_index);
319  size_t element_child_count = begin_index.getLayout().child_element_count;
321  std::move(begin_index), _child_element_count, element_child_count, _access));
322  }
323  else {
324  return const_iterator(element_type(CodecIndex(), 0, 0, _access));
325  }
326  }
327 
333  {
334  return cbegin();
335  }
341  {
342  if (_child_element_count > 0) {
343  return const_iterator(
344  element_type(CodecIndex(_codec_base_index, {_child_element_count, 0}),
345  _child_element_count,
346  0,
347  _access));
348  }
349  else {
350  return const_iterator(element_type(CodecIndex(), 0, 0, _access));
351  }
352  }
358  {
359  return cend();
360  }
366  {
367  if (_child_element_count > 0) {
368  CodecIndex begin_index(_codec_base_index, {0, 0});
369  ElementAccessType::resolve(_access, begin_index);
370  size_t element_child_count = begin_index.getLayout().child_element_count;
371  return iterator(element_type(
372  std::move(begin_index), _child_element_count, element_child_count, _access));
373  }
374  else {
375  return iterator(element_type(CodecIndex(), 0, 0, _access));
376  }
377  }
383  {
384  if (_child_element_count > 0) {
385  return iterator(element_type(CodecIndex(_codec_base_index, {_child_element_count, 0}),
386  _child_element_count,
387  0,
388  _access));
389  }
390  else {
391  return iterator(element_type(CodecIndex(), 0, 0, _access));
392  }
393  }
398  size_t size() const
399  {
400  return _child_element_count;
401  }
402 
403 private:
404  ChildElements(const CodecIndex& base_index, access_type& access)
405  : _codec_base_index(base_index),
406  _child_element_count(ElementAccessType::getChildCount(access, base_index)),
407  _access(access)
408  {
409  }
410 
411  ChildElements(const CodecIndex& base_index, size_t child_element_count, access_type& access)
412  : _codec_base_index(base_index), _child_element_count(child_element_count), _access(access)
413  {
414  }
415  void resetChildCount(size_t child_element_count)
416  {
417  _child_element_count = child_element_count;
418  }
419  void resetChildCount()
420  {
421  resetChildCount(ElementAccessType::getChildCount(_access, _codec_base_index));
422  }
423 
424  const CodecIndex& _codec_base_index;
425  size_t _child_element_count;
426  access_type& _access;
427 };
428 
436 template <typename AccessType>
438 public:
439  using access_type = AccessType;
442 
451  static element_type getElement(access_type& access, const std::string& full_element_name)
452  {
453  return access.getElement(full_element_name);
454  };
462  static element_type getElement(access_type& access, const CodecIndex& index)
463  {
464  return access.getElement(index);
465  };
473  static size_t getChildCount(access_type& access, const CodecIndex& index)
474  {
475  return access.getElementChildCount(index);
476  };
487  static std::string getFullName(access_type& access, const CodecIndex& index)
488  {
489  return access.getElementFullName(index);
490  };
501  static std::string getName(access_type& access, const CodecIndex& index)
502  {
503  return access.getElementName(index);
504  };
515  static std::string getBaseName(access_type& access, const CodecIndex& index)
516  {
517  return access.getElementBaseName(index);
518  };
519 
527  static void resolve(access_type& access, CodecIndex& index)
528  {
529  return access.resolve(index);
530  };
531 };
532 
541 template <typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
543 public:
545  using access_type = typename ElementAccessType::access_type;
546  using child_elements_type = ChildElementsType;
547  using iterator_type = typename child_elements_type::iterator;
549  using const_iterator_type = typename child_elements_type::const_iterator;
550 
566  friend access_type;
575 
579  FactoryElement() = delete;
585  : _codec_index(std::move(other._codec_index)),
586  _end_element_index(std::move(other._end_element_index)),
587  _child_elements(_codec_index, other._child_elements.size(), other._access),
588  _access(other._access)
589  {
590  }
597  {
598  _codec_index = std::move(other._codec_index);
599  _end_element_index = std::move(other._end_element_index);
600  _child_elements = child_elements_type(_codec_index, other._child_elements.size(), _access);
601  }
607  : _codec_index(other._codec_index),
608  _end_element_index(other._end_element_index),
609  _child_elements(_codec_index, other._child_elements.size(), other._access),
610  _access(other._access)
611  {
612  }
619  {
620  _codec_index = other._codec_index;
621  _end_element_index = other._end_element_index;
622  _child_elements = child_elements_type(_codec_index, other._child_elements.size(), _access);
623  }
624 
629  ~FactoryElement() = default;
634  const CodecIndex& getIndex() const
635  {
636  return _codec_index;
637  }
642  size_t getArraySize() const
643  {
644  return _codec_index.getLayout().array_size;
645  }
651  {
652  return _codec_index.getType();
653  }
661  std::string getFullName() const
662  {
663  return ElementAccessType::getFullName(_access, _codec_index);
664  }
672  std::string getName() const
673  {
674  return ElementAccessType::getName(_access, _codec_index);
675  }
683  std::string getBaseName() const
684  {
685  return ElementAccessType::getBaseName(_access, _codec_index);
686  }
692  bool isArray() const
693  {
694  return _codec_index.getLayout().array_size > 1;
695  }
701  bool hasChildren() const
702  {
703  return _child_elements.size() > 0;
704  }
711  {
712  return _child_elements;
713  }
719  self_type getChildElement(const std::string& name) const
720  {
721  auto full_name = getFullName();
722  full_name.append(".");
723  full_name.append(name);
724  return self_type(full_name, getAccess());
725  }
731  self_type getArrayElement(size_t array_pos = 0) const
732  {
733  return self_type(_codec_index.getIndexForArrayPos(array_pos), getAccess());
734  }
740  bool isValid() const
741  {
742  return _codec_index != CodecIndex();
743  }
744 
745 private:
746  FactoryElement(CodecIndex&& index,
747  size_t end_element_index,
748  size_t child_elements_count,
749  access_type& access)
750  : _codec_index(std::move(index)),
751  _end_element_index(end_element_index),
752  _child_elements(_codec_index, child_elements_count, access),
753  _access(access)
754  {
755  }
756  FactoryElement(CodecIndex&& index, size_t end_element_index, access_type& access)
757  : _codec_index(std::move(index)),
758  _end_element_index(end_element_index),
759  _child_elements(
760  _codec_index, ElementAccessType::getChildCount(access, _codec_index), access),
761  _access(access)
762  {
763  }
764  FactoryElement(const std::string& element_name, access_type& access)
765  : _codec_index(std::move(ElementAccessType::getElement(access, element_name)._codec_index)),
766  _end_element_index(CodecIndex::ElementIndex::_invalid_element_index),
767  _child_elements(_codec_index, access),
768  _access(access)
769  {
770  }
771 
772  FactoryElement(CodecIndex&& index, access_type& access)
773  : _codec_index(std::move(index)),
774  _end_element_index(CodecIndex::ElementIndex::_invalid_element_index),
775  _child_elements(_codec_index, access),
776  _access(access)
777  {
778  }
779  FactoryElement(access_type& access)
780  : _codec_index(CodecIndex()),
781  _end_element_index(CodecIndex::ElementIndex::_invalid_element_index),
782  _child_elements(_codec_index, 0, access),
783  _access(access)
784  {
785  }
786  void next()
787  {
788  auto break_increasing = false;
789  auto index_valid = false;
790  while (!break_increasing) {
791  ++_codec_index;
792  const auto element_index = _codec_index.back();
793  if (element_index.getIndex() != CodecIndex::ElementIndex::_invalid_element_index &&
794  element_index.getIndex() < _end_element_index) {
795  ElementAccessType::resolve(_access, _codec_index);
796  if (_codec_index.getLayout().array_size != 0) {
797  break_increasing = true;
798  index_valid = true;
799  }
800  }
801  else {
802  break_increasing = true;
803  }
804  }
805  if (index_valid) {
806  _child_elements.resetChildCount(_codec_index.getLayout().child_element_count);
807  }
808  }
809  access_type& getAccess() const
810  {
811  return _access;
812  }
813 
814  void resetIndex(CodecIndex&& codec_index)
815  {
816  _codec_index = std::move(codec_index);
817  _child_elements.resetChildCount();
818  }
819  CodecIndex _codec_index;
820  size_t _end_element_index;
821  child_elements_type _child_elements;
822  access_type& _access;
823 };
824 
833 template <typename AccessType>
834 class DecoderElementAccess : public FactoryElementAccess<AccessType> {
835 public:
836  using access_type = AccessType;
840 
849  static element_type getElement(access_type& access, const std::string& full_element_name)
850  {
851  return access.getElement(full_element_name);
852  };
860  static element_type getElement(access_type& access, const CodecIndex& index)
861  {
862  return access.getElement(index);
863  };
874  template <typename T>
875  static T getValue(access_type& access, const CodecIndex& index)
876  {
877  return access.template getElementValue<T>(index);
878  }
888  {
889  return access.getElementVariantValue(index);
890  };
899  static std::string getStringValue(access_type& access, const CodecIndex& index)
900  {
901  return access.getElementStringValue(index);
902  };
911  static void getRawValue(access_type& access,
912  const CodecIndex& index,
913  void* value,
914  size_t value_size)
915  {
916  access.getElementRawValue(index, value, value_size);
917  };
925  static const void* getAddress(access_type& access, const CodecIndex& index)
926  {
927  return access.getElementAddress(index);
928  };
929 };
930 
937 template <typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
938 class DecoderElement : public FactoryElement<ElementAccessType, ChildElementsType> {
939 public:
943  using access_type = typename ElementAccessType::access_type;
945  using iterator_type = typename child_elements_type::iterator;
947  using const_iterator_type = typename child_elements_type::const_iterator;
948 
964  friend access_type;
968  friend base_type;
973 
977  DecoderElement() = delete;
985  template <typename T>
986  T getValue() const
987  {
988  return ElementAccessType::template getValue<T>(base_type::getAccess(),
990  }
996  {
997  return ElementAccessType::getVariantValue(base_type::getAccess(), base_type::getIndex());
998  };
1003  std::string getStringValue() const
1004  {
1005  return ElementAccessType::getStringValue(base_type::getAccess(), base_type::getIndex());
1006  };
1013  void getRawValue(void* value, size_t value_size) const
1014  {
1015  ElementAccessType::getRawValue(
1016  base_type::getAccess(), base_type::getIndex(), value, value_size);
1017  }
1022  const void* getAddress() const
1023  {
1024  return ElementAccessType::getAddress(base_type::getAccess(), base_type::getIndex());
1025  }
1031  self_type getChildElement(const std::string& name) const
1032  {
1033  auto full_name = base_type::getFullName();
1034  full_name.append(".");
1035  full_name.append(name);
1036  return self_type(full_name, base_type::getAccess());
1037  }
1043  self_type getArrayElement(size_t array_pos = 0) const
1044  {
1045  return self_type(base_type::getIndex().getIndexForArrayPos(array_pos),
1046  base_type::getAccess());
1047  }
1048 
1049 private:
1050  DecoderElement(CodecIndex&& index,
1051  size_t end_element_index,
1052  size_t child_elements_count,
1053  access_type& access)
1054  : base_type(std::move(index), end_element_index, child_elements_count, access)
1055  {
1056  }
1057  DecoderElement(CodecIndex&& index, size_t end_element_index, access_type& access)
1058  : base_type(std::move(index), end_element_index, access)
1059  {
1060  }
1061  DecoderElement(const std::string& element_name, access_type& access)
1062  : base_type(element_name, access)
1063  {
1064  }
1065  DecoderElement(CodecIndex&& index, access_type& access) : base_type(std::move(index), access)
1066  {
1067  }
1068  DecoderElement(access_type& access) : base_type(access)
1069  {
1070  }
1071  void next()
1072  {
1073  base_type::next();
1074  }
1075 };
1076 
1085 template <typename AccessType>
1086 class CodecElementAccess : public DecoderElementAccess<AccessType> {
1087 public:
1088  using access_type = AccessType;
1092 
1101  static element_type getElement(access_type& access, const std::string& full_element_name)
1102  {
1103  return access.getElement(full_element_name);
1104  };
1112  static element_type getElement(access_type& access, const CodecIndex& index)
1113  {
1114  return access.getElement(index);
1115  };
1126  template <typename T>
1127  static void setValue(access_type& access, const CodecIndex& index, const T& value)
1128  {
1129  access.template setElementValue<T>(index, value);
1130  }
1138  static void setVariantValue(access_type& access,
1139  const CodecIndex& index,
1140  const a_util::variant::Variant& value)
1141  {
1142  access.setElementVariantValue(index, value);
1143  };
1151  static void setStringValue(access_type& access,
1152  const CodecIndex& index,
1153  const std::string& value)
1154  {
1155  access.setElementStringValue(index, value);
1156  };
1165  static void setRawValue(access_type& access,
1166  const CodecIndex& index,
1167  const void* value,
1168  size_t value_size)
1169  {
1170  access.setElementRawValue(index, value, value_size);
1171  };
1179  static void* getAddress(access_type& access, const CodecIndex& index)
1180  {
1181  return access.getElementAddress(index);
1182  };
1183 };
1184 
1190 template <typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
1191 class CodecElement : public DecoderElement<ElementAccessType, ChildElementsType> {
1192 public:
1197  using access_type = typename ElementAccessType::access_type;
1200  using iterator_type = typename child_elements_type::iterator;
1202  using const_iterator_type = typename child_elements_type::const_iterator;
1203 
1219  friend access_type;
1223  friend base_type;
1231  CodecElement() = delete;
1240  template <typename T>
1241  void setValue(const T& value)
1242  {
1243  return ElementAccessType::template setValue<T>(
1244  base_type::getAccess(), base_type::getIndex(), value);
1245  }
1252  {
1253  return ElementAccessType::setVariantValue(
1254  base_type::getAccess(), base_type::getIndex(), value);
1255  };
1261  void setStringValue(const std::string& value)
1262  {
1263  return ElementAccessType::setStringValue(
1264  base_type::getAccess(), base_type::getIndex(), value);
1265  };
1272  void setRawValue(const void* value, size_t value_size)
1273  {
1274  return ElementAccessType::setRawValue(
1275  base_type::getAccess(), base_type::getIndex(), value, value_size);
1276  };
1277 
1284  void reset(bool zero_value_of_known_type = false)
1285  {
1286  const auto& layout = base_type::getIndex().getLayout();
1287  if (layout.constant_info->isConstant()) {
1288  return ElementAccessType::setVariantValue(base_type::getAccess(),
1290  layout.constant_info->getConstantValue());
1291  }
1292  else if (layout.default_value_info->hasDefaultValue()) {
1293  return ElementAccessType::setVariantValue(base_type::getAccess(),
1295  layout.default_value_info->getDefaultValue());
1296  }
1297  else {
1298  // we can only reset known types
1299  if (zero_value_of_known_type) {
1300  auto known_type = base_type::getType();
1301  if (known_type != ElementType::cet_empty &&
1302  known_type != ElementType::cet_sub_codec &&
1303  known_type != ElementType::cet_user_type) {
1304  uint64_t null_value = 0;
1305  return ElementAccessType::setRawValue(base_type::getAccess(),
1307  &null_value,
1308  sizeof(null_value));
1309  }
1310  }
1311  }
1312  }
1313 
1319  void* getAddress()
1320  {
1321  return ElementAccessType::getAddress(base_type::getAccess(), base_type::getIndex());
1322  }
1323 
1331  {
1332  return factory_base_type::_child_elements;
1333  }
1340  self_type getChildElement(const std::string& name) const
1341  {
1342  auto full_name = base_type::getFullName();
1343  full_name.append(".");
1344  full_name.append(name);
1345  return self_type(full_name, base_type::getAccess());
1346  }
1347 
1354  self_type getChildElement(const std::string& name)
1355  {
1356  auto full_name = base_type::getFullName();
1357  full_name.append(".");
1358  full_name.append(name);
1359  return self_type(full_name, base_type::getAccess());
1360  }
1366  self_type getArrayElement(size_t array_pos = 0) const
1367  {
1368  return self_type(base_type::getIndex().getIndexForArrayPos(array_pos),
1369  base_type::getAccess());
1370  }
1371 
1377  self_type getArrayElement(size_t array_pos = 0)
1378  {
1379  return self_type(base_type::getIndex().getIndexForArrayPos(array_pos),
1380  base_type::getAccess());
1381  }
1382 
1383 private:
1384  CodecElement(CodecIndex&& index,
1385  size_t end_element_index,
1386  size_t child_elements_count,
1387  access_type& access)
1388  : base_type(std::move(index), end_element_index, child_elements_count, access)
1389  {
1390  }
1391  CodecElement(CodecIndex&& index, size_t end_element_index, access_type& access)
1392  : base_type(std::move(index), end_element_index, access)
1393  {
1394  }
1395  CodecElement(const std::string& element_name, access_type& access)
1396  : base_type(element_name, access)
1397  {
1398  }
1399  CodecElement(CodecIndex&& index, access_type& access) : base_type(std::move(index), access)
1400  {
1401  }
1402  CodecElement(access_type& access) : base_type(access)
1403  {
1404  }
1405  void next()
1406  {
1407  base_type::next();
1408  }
1409 };
1410 
1448 template <typename ElementsType>
1450  ElementsType& elements,
1451  const std::function<void(std::conditional_t<std::is_const<ElementsType>::value,
1452  const typename ElementsType::element_type,
1453  typename ElementsType::element_type>&)>& func)
1454 {
1455  for (auto& element: elements) {
1456  if (element.hasChildren()) {
1457  if (element.isArray()) {
1458  for (size_t array_pos = 0; array_pos < element.getArraySize(); ++array_pos) {
1459  auto array_element = element.getArrayElement(array_pos);
1460  auto& children = array_element.getChildElements();
1461  forEachLeafElement(children, func);
1462  }
1463  }
1464  else {
1465  auto& children = element.getChildElements();
1466  forEachLeafElement(children, func);
1467  }
1468  }
1469  else {
1470  if (element.isArray()) {
1471  for (size_t array_pos = 0; array_pos < element.getArraySize(); ++array_pos) {
1472  auto array_element = element.getArrayElement(array_pos);
1473  func(array_element);
1474  }
1475  }
1476  else {
1477  func(element);
1478  }
1479  }
1480  }
1481 }
1482 
1527 template <typename ElementsType>
1529  ElementsType& elements,
1530  const std::function<void(std::conditional_t<std::is_const<ElementsType>::value,
1531  const typename ElementsType::element_type,
1532  typename ElementsType::element_type>&)>& func)
1533 {
1534  for (auto& element: elements) {
1535  func(element);
1536  if (element.hasChildren()) {
1537  auto& children = element.getChildElements();
1538  forEachElement(children, func);
1539  }
1540  }
1541 }
1542 
1543 } // namespace codec
1544 } // namespace ddl
1545 
1546 #endif // DDL_CODEC_ITERATOR_CLASS_HEADER
Iteratable container type for the given Element type in ElementAccessType::element_type.
typename ElementAccessType::element_type element_type
The supported element type (from ElementAccessType::element_type)
~ChildElements()=default
DTOR.
size_t size() const
Size of the container (child count)
ChildElements & operator=(ChildElements &&)=default
move operator
const_iterator begin() const
begin
ElementIterator< ElementAccessType > iterator
iterator type
ElementIteratorConst< ElementAccessType > const_iterator
const iterator type
const_iterator cbegin() const
cbegin
friend element_type
friend declaration for element type
ChildElements(ChildElements &&)=default
move CTOR
const_iterator cend() const
cend
friend access_type
friend declaration for access type
const_iterator end() const
end
ChildElements & operator=(const ChildElements &)=delete
no copy operator
typename ElementAccessType::access_type access_type
The supported access type (from ElementAccessType::access_type)
ChildElements(const ChildElements &)=delete
no copy CTOR
A element access type concept template to retrieve element information from the AccessType,...
static element_type getElement(access_type &access, const std::string &full_element_name)
Get a element object for the given full_element_name.
static element_type getElement(access_type &access, const CodecIndex &index)
Get a element object for the given index.
static void setStringValue(access_type &access, const CodecIndex &index, const std::string &value)
Sets the value from value as string.
static void setValue(access_type &access, const CodecIndex &index, const T &value)
Sets the value from value of type T.
static void * getAddress(access_type &access, const CodecIndex &index)
Get the address (with write access)
static void setRawValue(access_type &access, const CodecIndex &index, const void *value, size_t value_size)
Set the value by copying from a value buffer.
static void setVariantValue(access_type &access, const CodecIndex &index, const a_util::variant::Variant &value)
Sets the value from value as variant.
A CodecElement to get and set values.
void * getAddress()
Get the address (with writing access)
self_type getChildElement(const std::string &name) const
Get a dedicated ChildElement by name.
CodecElement()=delete
CTOR.
self_type getArrayElement(size_t array_pos=0)
Get the array element of the given array_pos.
child_elements_type & getChildElements()
Gets an reference to the child elements.
CodecElement< ElementAccessType, ChildElementsType > self_type
self type
void reset(bool zero_value_of_known_type=false)
Reset the elements value to their default values, constant values defined in the data definition or z...
void setValue(const T &value)
Sets the value from value of type T.
friend const_iterator_type
friend declaration for const_iterator_type
self_type getChildElement(const std::string &name)
Get a dedicated ChildElement by name.
void setRawValue(const void *value, size_t value_size)
Set the value by copying from a value buffer.
void setVariantValue(const a_util::variant::Variant &value)
Sets the value from value as variant.
friend access_type
friend declaration for access_type
DecoderElement< ElementAccessType, ChildElementsType > base_type
base type
friend base_type
friend declaration for base_type
friend factory_base_type
friend declaration for factory_base_type
void setStringValue(const std::string &value)
Sets the value from value as string.
friend child_elements_type
friend declaration for child_elements_type
self_type getArrayElement(size_t array_pos=0) const
Get the array element of the given array_pos.
typename ElementAccessType::access_type access_type
access type from the concept
friend iterator_type
friend declaration for iterator_type
static constexpr size_t _invalid_element_index
Invalid element index.
Definition: codec_index.h:198
Fast Access Index Type for the coders.
Definition: codec_index.h:132
ElementType getType() const
Get the elements type if CodecIndex is valid.
size_t size() const
Gets the Size of the codec index in element index count for generic programming.
const ElementLayout & getLayout() const
Get the Layout.
A element access type concept template to retrieve element information from the AccessType and get th...
static std::string getStringValue(access_type &access, const CodecIndex &index)
Get the value as type string.
static T getValue(access_type &access, const CodecIndex &index)
Get the value as type T.
static a_util::variant::Variant getVariantValue(access_type &access, const CodecIndex &index)
Get the value as variant.
static element_type getElement(access_type &access, const std::string &full_element_name)
Get a element object for the given full_element_name.
static element_type getElement(access_type &access, const CodecIndex &index)
Get a element object for the given index.
static void getRawValue(access_type &access, const CodecIndex &index, void *value, size_t value_size)
Get the value by copy to the given value buffer.
static const void * getAddress(access_type &access, const CodecIndex &index)
Get the address of the element.
A DecoderElement to get values.
std::string getStringValue() const
Get the value as string.
FactoryElement< ElementAccessType, ChildElementsType > base_type
base type
self_type getChildElement(const std::string &name) const
Get the child element with the given name.
typename child_elements_type::const_iterator const_iterator_type
allowed const iterator type
T getValue() const
Get the value as type T.
friend const_iterator_type
friend declaration for const_iterator_type
void getRawValue(void *value, size_t value_size) const
Get the as copy to the value buffer.
DecoderElement< ElementAccessType, ChildElementsType > self_type
self type
typename child_elements_type::iterator iterator_type
allowed iterator type
a_util::variant::Variant getVariantValue() const
Get the value as variant.
typename base_type::child_elements_type child_elements_type
allowed container type
friend access_type
friend declaration for access_type
DecoderElement()=delete
CTOR.
friend base_type
friend declaration for base_type
const void * getAddress() const
Get the address of the element.
friend child_elements_type
friend declaration for child_elements_type
self_type getArrayElement(size_t array_pos=0) const
Get the array element of the given array_pos.
typename ElementAccessType::access_type access_type
access type from concept template
friend iterator_type
friend declaration for iterator_type
The const element iterator.
ElementIteratorConst & operator++()
increasing operator to the next position.
int difference_type
difference value type
typename ElementAccessType::element_type element_type
The element type in use.
const_pointer operator->() const
pointer access (check for end!)
value_type & const_reference
const reference value type
bool operator!=(const ElementIteratorConst &rhs) const
checks for not equality (does not refer the same element!)
bool operator==(const ElementIteratorConst &rhs) const
checks for equality (refering the same element!)
std::forward_iterator_tag iterator_category
iterator type
value_type * const_pointer
pointer to const data value type
const element_type value_type
const value type of the iterator
ElementIteratorConst()=delete
default CTOR
ElementIteratorConst(value_type &&element)
CTOR for one element.
const_reference operator*() const
defering access (check for end!)
ElementIteratorConst operator++(int)
iterator increasing.
The element iterator.
int difference_type
difference value type
typename ElementAccessType::element_type element_type
The element type in use.
const_pointer operator->() const
pointer access (check for end!)
pointer operator->()
pointer access (check for end!)
reference operator*()
defering access (check for end!)
value_type * pointer
Pointer type.
ElementIterator & operator++()
increasing operator to the next position.
std::forward_iterator_tag iterator_category
iterator type
value_type & reference
Reference value type.
const value_type * const_pointer
pointer to const data value type
bool operator==(const ElementIterator &rhs) const
checks for equality (refering the same element!)
const value_type & const_reference
const reference value type
ElementIterator operator++(int)
iterator increasing.
element_type value_type
Value type of the iterator.
bool operator!=(const ElementIterator &rhs) const
checks for not equality (does not refer the same element!)
const_reference operator*() const
defering access (check for end!)
ElementIterator()=delete
default CTOR
ElementIterator(value_type &&element)
CTOR for one element.
A factory element access type concept template to retrieve element information from the AccessType.
static size_t getChildCount(access_type &access, const CodecIndex &index)
Get the Child Count.
static std::string getName(access_type &access, const CodecIndex &index)
Get the name of the element within its level structure.
static std::string getFullName(access_type &access, const CodecIndex &index)
Get the full name of the element within its main structure.
static void resolve(access_type &access, CodecIndex &index)
Resolves the given CodecIndex and set the layout information.
AccessType access_type
The access type (CodecFactory, Codec, Decoder, etc.)
static element_type getElement(access_type &access, const std::string &full_element_name)
Get a element object for the given full_element_name.
static element_type getElement(access_type &access, const CodecIndex &index)
Get a element object for the given index.
static std::string getBaseName(access_type &access, const CodecIndex &index)
Get the name of the element within its level structure.
std::string getBaseName() const
Get the base name of the element.
FactoryElement(const FactoryElement &other)
copy CTOR
FactoryElement(FactoryElement &&other)
move CTOR
std::string getFullName() const
Get the full name of the element.
self_type getChildElement(const std::string &name) const
Get the child element with the given name.
bool isValid() const
Get validation indormation.
FactoryElement()=delete
no CTOR
typename child_elements_type::const_iterator const_iterator_type
allowed const iterator type
friend const_iterator_type
friend declaration for child_elements_type
~FactoryElement()=default
DTOR.
ChildElementsType child_elements_type
allowed container type
std::string getName() const
Get the name of the element If the element is an array you get the elements array name representation...
typename child_elements_type::iterator iterator_type
allowed iterator type
ddl::codec::ElementType getType() const
Get the type of the element.
const child_elements_type & getChildElements() const
Get the ChildElements.
FactoryElement & operator=(FactoryElement &&other)
copy assignment operator
FactoryElement< ElementAccessType, ChildElementsType > self_type
self type
friend access_type
friend declaration for access_type
bool hasChildren() const
Get children information.
size_t getArraySize() const
Get the array size.
const CodecIndex & getIndex() const
Get the codec index of the element.
friend child_elements_type
friend declaration for child_elements_type
FactoryElement & operator=(const FactoryElement &other)
move assignment operator
self_type getArrayElement(size_t array_pos=0) const
Get the array element of the given array_pos.
bool isArray() const
Get array information.
typename ElementAccessType::access_type access_type
access type
friend iterator_type
friend declaration for iterator_type
Implementation of the CodecIndex.
ElementType
The element type of the value.
@ cet_sub_codec
type marks a subcodec/substructure with children
@ cet_empty
Variant type is empty.
@ cet_user_type
type marks a user defined type
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.
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).
size_t child_element_count
The child element count.
Definition: codec_index.h:100
size_t array_size
Array size of the element value.
Definition: codec_index.h:96
Common include for component a_util::variant.