ADTF  3.15.1
codec_iterator.h
Go to the documentation of this file.
1 
21 #ifndef DDL_CODEC_ITERATOR_CLASS_HEADER
22 #define DDL_CODEC_ITERATOR_CLASS_HEADER
23 
24 #include <a_util/variant.h>
25 #include <ddl/codec/codec_index.h>
26 
27 #include <functional>
28 
29 namespace ddl {
30 namespace codec {
31 
32 // forward declarations
33 template <typename ElementAccessType, typename ChildElementsType>
34 class FactoryElement;
35 template <typename ElementAccessType, typename ChildElementsType>
36 class DecoderElement;
37 template <typename ElementAccessType, typename ChildElementsType>
38 class CodecElement;
39 
47 template <typename ElementAccessType>
49 public:
50  using element_type = typename ElementAccessType::element_type;
52  using reference = value_type&;
53  using const_reference = const value_type&;
54  using pointer = value_type*;
55  using const_pointer = const value_type*;
56  using difference_type = int;
57  using iterator_category = std::forward_iterator_tag;
58 
62  ElementIterator() = delete;
68  ElementIterator(value_type&& element) : _element(std::move(element))
69  {
70  }
77  {
78  next();
79  return *this;
80  }
87  {
88  const auto old_index = _element.getIndex();
89  next();
90  return ElementIterator(old_index, _element.getAccess());
91  }
99  bool operator==(const ElementIterator& rhs) const
100  {
101  return _element.getIndex() == rhs._element.getIndex();
102  }
110  bool operator!=(const ElementIterator& rhs) const
111  {
112  return _element.getIndex() != rhs._element.getIndex();
113  }
120  {
121  return _element;
122  }
129  {
130  return &_element;
131  }
138  {
139  return _element;
140  }
147  {
148  return &_element;
149  }
150 
151 private:
152  void next()
153  {
154  _element.next();
155  }
156  element_type _element;
157 };
158 
166 template <typename ElementAccessType>
168 public:
169  using element_type = typename ElementAccessType::element_type;
170  using value_type = const element_type;
173  using difference_type = int;
174  using iterator_category = std::forward_iterator_tag;
175 
184  ElementIteratorConst(value_type&& element) : _element(std::move(element))
185  {
186  }
192  {
193  next();
194  return *this;
195  }
201  {
202  const auto old_index = _element.getIndex();
203  next();
204  return self_type(old_index, _element.getAccess());
205  }
206 
214  bool operator==(const ElementIteratorConst& rhs) const
215  {
216  return _element.getIndex() == rhs._element.getIndex();
217  }
225  bool operator!=(const ElementIteratorConst& rhs) const
226  {
227  return _element.getIndex() != rhs._element.getIndex();
228  }
235  {
236  return _element;
237  }
244  {
245  return &_element;
246  }
247 
248 private:
249  void next()
250  {
251  _element.next();
252  }
253  element_type _element;
254 };
255 
262 template <typename ElementAccessType>
264 public:
266  using access_type = typename ElementAccessType::access_type;
268  using element_type = typename ElementAccessType::element_type;
271 
275  friend element_type;
279  friend access_type;
292 
305  ChildElements(const ChildElements&) = delete;
314  ~ChildElements() = default;
315 
321  {
322  if (_child_element_count > 0) {
323  CodecIndex begin_index(_codec_base_index, {0, 0});
324  ElementAccessType::resolve(_access, begin_index);
325  size_t element_child_count = begin_index.getLayout().child_element_count;
327  std::move(begin_index), _child_element_count, element_child_count, _access));
328  }
329  else {
330  return const_iterator(element_type(CodecIndex(), 0, 0, _access));
331  }
332  }
333 
339  {
340  return cbegin();
341  }
347  {
348  if (_child_element_count > 0) {
349  return const_iterator(
350  element_type(CodecIndex(_codec_base_index, {_child_element_count, 0}),
351  _child_element_count,
352  0,
353  _access));
354  }
355  else {
356  return const_iterator(element_type(CodecIndex(), 0, 0, _access));
357  }
358  }
364  {
365  return cend();
366  }
372  {
373  if (_child_element_count > 0) {
374  CodecIndex begin_index(_codec_base_index, {0, 0});
375  ElementAccessType::resolve(_access, begin_index);
376  size_t element_child_count = begin_index.getLayout().child_element_count;
377  return iterator(element_type(
378  std::move(begin_index), _child_element_count, element_child_count, _access));
379  }
380  else {
381  return iterator(element_type(CodecIndex(), 0, 0, _access));
382  }
383  }
389  {
390  if (_child_element_count > 0) {
391  return iterator(element_type(CodecIndex(_codec_base_index, {_child_element_count, 0}),
392  _child_element_count,
393  0,
394  _access));
395  }
396  else {
397  return iterator(element_type(CodecIndex(), 0, 0, _access));
398  }
399  }
404  size_t size() const
405  {
406  return _child_element_count;
407  }
408 
409 private:
410  ChildElements(const CodecIndex& base_index, access_type& access)
411  : _codec_base_index(base_index),
412  _child_element_count(ElementAccessType::getChildCount(access, base_index)),
413  _access(access)
414  {
415  }
416 
417  ChildElements(const CodecIndex& base_index, size_t child_element_count, access_type& access)
418  : _codec_base_index(base_index), _child_element_count(child_element_count), _access(access)
419  {
420  }
421  void resetChildCount(size_t child_element_count)
422  {
423  _child_element_count = child_element_count;
424  }
425  void resetChildCount()
426  {
427  resetChildCount(ElementAccessType::getChildCount(_access, _codec_base_index));
428  }
429 
430  const CodecIndex& _codec_base_index;
431  size_t _child_element_count;
432  access_type& _access;
433 };
434 
442 template <typename AccessType>
444 public:
445  using access_type = AccessType;
448 
457  static element_type getElement(access_type& access, const std::string& full_element_name)
458  {
459  return access.getElement(full_element_name);
460  };
468  static element_type getElement(access_type& access, const CodecIndex& index)
469  {
470  return access.getElement(index);
471  };
479  static size_t getChildCount(access_type& access, const CodecIndex& index)
480  {
481  return access.getElementChildCount(index);
482  };
493  static std::string getFullName(access_type& access, const CodecIndex& index)
494  {
495  return access.getElementFullName(index);
496  };
507  static std::string getName(access_type& access, const CodecIndex& index)
508  {
509  return access.getElementName(index);
510  };
521  static std::string getBaseName(access_type& access, const CodecIndex& index)
522  {
523  return access.getElementBaseName(index);
524  };
525 
533  static void resolve(access_type& access, CodecIndex& index)
534  {
535  return access.resolve(index);
536  };
537 };
538 
547 template <typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
549 public:
551  using access_type = typename ElementAccessType::access_type;
552  using child_elements_type = ChildElementsType;
553  using iterator_type = typename child_elements_type::iterator;
555  using const_iterator_type = typename child_elements_type::const_iterator;
556 
572  friend access_type;
581 
585  FactoryElement() = delete;
591  : _codec_index(std::move(other._codec_index)),
592  _end_element_index(std::move(other._end_element_index)),
593  _child_elements(_codec_index, other._child_elements.size(), other._access),
594  _access(other._access)
595  {
596  }
603  {
604  _codec_index = std::move(other._codec_index);
605  _end_element_index = std::move(other._end_element_index);
606  _child_elements = child_elements_type(_codec_index, other._child_elements.size(), _access);
607  }
613  : _codec_index(other._codec_index),
614  _end_element_index(other._end_element_index),
615  _child_elements(_codec_index, other._child_elements.size(), other._access),
616  _access(other._access)
617  {
618  }
625  {
626  _codec_index = other._codec_index;
627  _end_element_index = other._end_element_index;
628  _child_elements = child_elements_type(_codec_index, other._child_elements.size(), _access);
629  }
630 
635  ~FactoryElement() = default;
640  const CodecIndex& getIndex() const
641  {
642  return _codec_index;
643  }
648  size_t getArraySize() const
649  {
650  return _codec_index.getLayout().array_size;
651  }
657  {
658  return _codec_index.getType();
659  }
667  std::string getFullName() const
668  {
669  return ElementAccessType::getFullName(_access, _codec_index);
670  }
678  std::string getName() const
679  {
680  return ElementAccessType::getName(_access, _codec_index);
681  }
689  std::string getBaseName() const
690  {
691  return ElementAccessType::getBaseName(_access, _codec_index);
692  }
698  bool isArray() const
699  {
700  return _codec_index.getLayout().array_size > 1;
701  }
707  bool hasChildren() const
708  {
709  return _child_elements.size() > 0;
710  }
717  {
718  return _child_elements;
719  }
725  self_type getChildElement(const std::string& name) const
726  {
727  auto full_name = getFullName();
728  full_name.append(".");
729  full_name.append(name);
730  return self_type(full_name, getAccess());
731  }
737  self_type getArrayElement(size_t array_pos = 0) const
738  {
739  return self_type(_codec_index.getIndexForArrayPos(array_pos), getAccess());
740  }
746  bool isValid() const
747  {
748  return _codec_index != CodecIndex();
749  }
750 
751 private:
752  FactoryElement(CodecIndex&& index,
753  size_t end_element_index,
754  size_t child_elements_count,
755  access_type& access)
756  : _codec_index(std::move(index)),
757  _end_element_index(end_element_index),
758  _child_elements(_codec_index, child_elements_count, access),
759  _access(access)
760  {
761  }
762  FactoryElement(CodecIndex&& index, size_t end_element_index, access_type& access)
763  : _codec_index(std::move(index)),
764  _end_element_index(end_element_index),
765  _child_elements(
766  _codec_index, ElementAccessType::getChildCount(access, _codec_index), access),
767  _access(access)
768  {
769  }
770  FactoryElement(const std::string& element_name, access_type& access)
771  : _codec_index(std::move(ElementAccessType::getElement(access, element_name)._codec_index)),
772  _end_element_index(CodecIndex::ElementIndex::_invalid_element_index),
773  _child_elements(_codec_index, access),
774  _access(access)
775  {
776  }
777 
778  FactoryElement(CodecIndex&& index, access_type& access)
779  : _codec_index(std::move(index)),
780  _end_element_index(CodecIndex::ElementIndex::_invalid_element_index),
781  _child_elements(_codec_index, access),
782  _access(access)
783  {
784  }
785  FactoryElement(access_type& access)
786  : _codec_index(CodecIndex()),
787  _end_element_index(CodecIndex::ElementIndex::_invalid_element_index),
788  _child_elements(_codec_index, 0, access),
789  _access(access)
790  {
791  }
792  void next()
793  {
794  auto break_increasing = false;
795  auto index_valid = false;
796  while (!break_increasing) {
797  ++_codec_index;
798  const auto element_index = _codec_index.back();
799  if (element_index.getIndex() != CodecIndex::ElementIndex::_invalid_element_index &&
800  element_index.getIndex() < _end_element_index) {
801  ElementAccessType::resolve(_access, _codec_index);
802  if (_codec_index.getLayout().array_size != 0) {
803  break_increasing = true;
804  index_valid = true;
805  }
806  }
807  else {
808  break_increasing = true;
809  }
810  }
811  if (index_valid) {
812  _child_elements.resetChildCount(_codec_index.getLayout().child_element_count);
813  }
814  }
815  access_type& getAccess() const
816  {
817  return _access;
818  }
819 
820  void resetIndex(CodecIndex&& codec_index)
821  {
822  _codec_index = std::move(codec_index);
823  _child_elements.resetChildCount();
824  }
825  CodecIndex _codec_index;
826  size_t _end_element_index;
827  child_elements_type _child_elements;
828  access_type& _access;
829 };
830 
839 template <typename AccessType>
840 class DecoderElementAccess : public FactoryElementAccess<AccessType> {
841 public:
842  using access_type = AccessType;
846 
855  static element_type getElement(access_type& access, const std::string& full_element_name)
856  {
857  return access.getElement(full_element_name);
858  };
866  static element_type getElement(access_type& access, const CodecIndex& index)
867  {
868  return access.getElement(index);
869  };
880  template <typename T>
881  static T getValue(access_type& access, const CodecIndex& index)
882  {
883  return access.template getElementValue<T>(index);
884  }
894  {
895  return access.getElementVariantValue(index);
896  };
905  static std::string getStringValue(access_type& access, const CodecIndex& index)
906  {
907  return access.getElementStringValue(index);
908  };
917  static void getRawValue(access_type& access,
918  const CodecIndex& index,
919  void* value,
920  size_t value_size)
921  {
922  access.getElementRawValue(index, value, value_size);
923  };
931  static const void* getAddress(access_type& access, const CodecIndex& index)
932  {
933  return access.getElementAddress(index);
934  };
935 };
936 
943 template <typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
944 class DecoderElement : public FactoryElement<ElementAccessType, ChildElementsType> {
945 public:
949  using access_type = typename ElementAccessType::access_type;
951  using iterator_type = typename child_elements_type::iterator;
953  using const_iterator_type = typename child_elements_type::const_iterator;
954 
970  friend access_type;
974  friend base_type;
979 
983  DecoderElement() = delete;
991  template <typename T>
992  T getValue() const
993  {
994  return ElementAccessType::template getValue<T>(base_type::getAccess(),
996  }
1002  {
1003  return ElementAccessType::getVariantValue(base_type::getAccess(), base_type::getIndex());
1004  };
1009  std::string getStringValue() const
1010  {
1011  return ElementAccessType::getStringValue(base_type::getAccess(), base_type::getIndex());
1012  };
1019  void getRawValue(void* value, size_t value_size) const
1020  {
1021  ElementAccessType::getRawValue(
1022  base_type::getAccess(), base_type::getIndex(), value, value_size);
1023  }
1028  const void* getAddress() const
1029  {
1030  return ElementAccessType::getAddress(base_type::getAccess(), base_type::getIndex());
1031  }
1037  self_type getChildElement(const std::string& name) const
1038  {
1039  auto full_name = base_type::getFullName();
1040  full_name.append(".");
1041  full_name.append(name);
1042  return self_type(full_name, base_type::getAccess());
1043  }
1049  self_type getArrayElement(size_t array_pos = 0) const
1050  {
1051  return self_type(base_type::getIndex().getIndexForArrayPos(array_pos),
1052  base_type::getAccess());
1053  }
1054 
1055 private:
1056  DecoderElement(CodecIndex&& index,
1057  size_t end_element_index,
1058  size_t child_elements_count,
1059  access_type& access)
1060  : base_type(std::move(index), end_element_index, child_elements_count, access)
1061  {
1062  }
1063  DecoderElement(CodecIndex&& index, size_t end_element_index, access_type& access)
1064  : base_type(std::move(index), end_element_index, access)
1065  {
1066  }
1067  DecoderElement(const std::string& element_name, access_type& access)
1068  : base_type(element_name, access)
1069  {
1070  }
1071  DecoderElement(CodecIndex&& index, access_type& access) : base_type(std::move(index), access)
1072  {
1073  }
1074  DecoderElement(access_type& access) : base_type(access)
1075  {
1076  }
1077  void next()
1078  {
1079  base_type::next();
1080  }
1081 };
1082 
1091 template <typename AccessType>
1092 class CodecElementAccess : public DecoderElementAccess<AccessType> {
1093 public:
1094  using access_type = AccessType;
1098 
1107  static element_type getElement(access_type& access, const std::string& full_element_name)
1108  {
1109  return access.getElement(full_element_name);
1110  };
1118  static element_type getElement(access_type& access, const CodecIndex& index)
1119  {
1120  return access.getElement(index);
1121  };
1133  template <typename T>
1134  static void setValue(access_type& access, const CodecIndex& index, const T& value)
1135  {
1136  access.template setElementValue<T>(index, value);
1137  }
1145  static void setVariantValue(access_type& access,
1146  const CodecIndex& index,
1147  const a_util::variant::Variant& value)
1148  {
1149  access.setElementVariantValue(index, value);
1150  };
1158  static void setStringValue(access_type& access,
1159  const CodecIndex& index,
1160  const std::string& value)
1161  {
1162  access.setElementStringValue(index, value);
1163  };
1172  static void setRawValue(access_type& access,
1173  const CodecIndex& index,
1174  const void* value,
1175  size_t value_size)
1176  {
1177  access.setElementRawValue(index, value, value_size);
1178  };
1186  static void* getAddress(access_type& access, const CodecIndex& index)
1187  {
1188  return access.getElementAddress(index);
1189  };
1190 };
1191 
1197 template <typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
1198 class CodecElement : public DecoderElement<ElementAccessType, ChildElementsType> {
1199 public:
1204  using access_type = typename ElementAccessType::access_type;
1207  using iterator_type = typename child_elements_type::iterator;
1209  using const_iterator_type = typename child_elements_type::const_iterator;
1210 
1226  friend access_type;
1230  friend base_type;
1238  CodecElement() = delete;
1248  template <typename T>
1249  void setValue(const T& value)
1250  {
1251  return ElementAccessType::template setValue<T>(
1252  base_type::getAccess(), base_type::getIndex(), value);
1253  }
1260  {
1261  return ElementAccessType::setVariantValue(
1262  base_type::getAccess(), base_type::getIndex(), value);
1263  };
1269  void setStringValue(const std::string& value)
1270  {
1271  return ElementAccessType::setStringValue(
1272  base_type::getAccess(), base_type::getIndex(), value);
1273  };
1280  void setRawValue(const void* value, size_t value_size)
1281  {
1282  return ElementAccessType::setRawValue(
1283  base_type::getAccess(), base_type::getIndex(), value, value_size);
1284  };
1285 
1292  void reset(bool zero_value_of_known_type = false)
1293  {
1294  const auto& layout = base_type::getIndex().getLayout();
1295  if (layout.constant_info->isConstant()) {
1296  return ElementAccessType::setVariantValue(base_type::getAccess(),
1298  layout.constant_info->getConstantValue());
1299  }
1300  else if (layout.default_value_info->hasDefaultValue()) {
1301  return ElementAccessType::setVariantValue(base_type::getAccess(),
1303  layout.default_value_info->getDefaultValue());
1304  }
1305  else {
1306  // we can only reset known types
1307  if (zero_value_of_known_type) {
1308  auto known_type = base_type::getType();
1309  if (known_type != ElementType::cet_empty &&
1310  known_type != ElementType::cet_sub_codec &&
1311  known_type != ElementType::cet_user_type) {
1312  uint64_t null_value = 0;
1313  return ElementAccessType::setRawValue(base_type::getAccess(),
1315  &null_value,
1316  sizeof(null_value));
1317  }
1318  }
1319  }
1320  }
1321 
1327  void* getAddress()
1328  {
1329  return ElementAccessType::getAddress(base_type::getAccess(), base_type::getIndex());
1330  }
1331 
1339  {
1340  return factory_base_type::_child_elements;
1341  }
1348  self_type getChildElement(const std::string& name) const
1349  {
1350  auto full_name = base_type::getFullName();
1351  full_name.append(".");
1352  full_name.append(name);
1353  return self_type(full_name, base_type::getAccess());
1354  }
1355 
1362  self_type getChildElement(const std::string& name)
1363  {
1364  auto full_name = base_type::getFullName();
1365  full_name.append(".");
1366  full_name.append(name);
1367  return self_type(full_name, base_type::getAccess());
1368  }
1374  self_type getArrayElement(size_t array_pos = 0) const
1375  {
1376  return self_type(base_type::getIndex().getIndexForArrayPos(array_pos),
1377  base_type::getAccess());
1378  }
1379 
1385  self_type getArrayElement(size_t array_pos = 0)
1386  {
1387  return self_type(base_type::getIndex().getIndexForArrayPos(array_pos),
1388  base_type::getAccess());
1389  }
1390 
1391 private:
1392  CodecElement(CodecIndex&& index,
1393  size_t end_element_index,
1394  size_t child_elements_count,
1395  access_type& access)
1396  : base_type(std::move(index), end_element_index, child_elements_count, access)
1397  {
1398  }
1399  CodecElement(CodecIndex&& index, size_t end_element_index, access_type& access)
1400  : base_type(std::move(index), end_element_index, access)
1401  {
1402  }
1403  CodecElement(const std::string& element_name, access_type& access)
1404  : base_type(element_name, access)
1405  {
1406  }
1407  CodecElement(CodecIndex&& index, access_type& access) : base_type(std::move(index), access)
1408  {
1409  }
1410  CodecElement(access_type& access) : base_type(access)
1411  {
1412  }
1413  void next()
1414  {
1415  base_type::next();
1416  }
1417 };
1418 
1456 template <typename ElementsType>
1458  ElementsType& elements,
1459  const std::function<void(std::conditional_t<std::is_const<ElementsType>::value,
1460  const typename ElementsType::element_type,
1461  typename ElementsType::element_type>&)>& func)
1462 {
1463  for (auto& element: elements) {
1464  if (element.hasChildren()) {
1465  if (element.isArray()) {
1466  for (size_t array_pos = 0; array_pos < element.getArraySize(); ++array_pos) {
1467  auto array_element = element.getArrayElement(array_pos);
1468  auto& children = array_element.getChildElements();
1469  forEachLeafElement(children, func);
1470  }
1471  }
1472  else {
1473  auto& children = element.getChildElements();
1474  forEachLeafElement(children, func);
1475  }
1476  }
1477  else {
1478  if (element.isArray()) {
1479  for (size_t array_pos = 0; array_pos < element.getArraySize(); ++array_pos) {
1480  auto array_element = element.getArrayElement(array_pos);
1481  func(array_element);
1482  }
1483  }
1484  else {
1485  func(element);
1486  }
1487  }
1488  }
1489 }
1490 
1535 template <typename ElementsType>
1537  ElementsType& elements,
1538  const std::function<void(std::conditional_t<std::is_const<ElementsType>::value,
1539  const typename ElementsType::element_type,
1540  typename ElementsType::element_type>&)>& func)
1541 {
1542  for (auto& element: elements) {
1543  func(element);
1544  if (element.hasChildren()) {
1545  auto& children = element.getChildElements();
1546  forEachElement(children, func);
1547  }
1548  }
1549 }
1550 
1551 } // namespace codec
1552 } // namespace ddl
1553 
1554 #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:204
Fast Access Index Type for the coders.
Definition: codec_index.h:138
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.
Common include for component a_util::variant.
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).
definition of the ddl namespace
size_t child_element_count
The child element count.
Definition: codec_index.h:106
size_t array_size
Array size of the element value.
Definition: codec_index.h:102