ADTF
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
codec_iterator.h
Go to the documentation of this file.
1
14
15#ifndef DDL_CODEC_ITERATOR_CLASS_HEADER
16#define DDL_CODEC_ITERATOR_CLASS_HEADER
17
18#include <a_util/variant.h>
20
21#include <functional>
22
23namespace ddl {
24namespace codec {
25
26// forward declarations
27template <typename ElementAccessType, typename ChildElementsType>
28class FactoryElement;
29template <typename ElementAccessType, typename ChildElementsType>
30class DecoderElement;
31template <typename ElementAccessType, typename ChildElementsType>
32class CodecElement;
33
41template <typename ElementAccessType>
43public:
44 using element_type = typename ElementAccessType::element_type;
47 using const_reference = const 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 }
65
71 {
72 next();
73 return *this;
74 }
75
81 {
82 const auto old_index = _element.getIndex();
83 next();
84 return ElementIterator(old_index, _element.getAccess());
85 }
86
93 bool operator==(const ElementIterator& rhs) const
94 {
95 return _element.getIndex() == rhs._element.getIndex();
96 }
97
104 bool operator!=(const ElementIterator& rhs) const
105 {
106 return _element.getIndex() != rhs._element.getIndex();
107 }
108
114 {
115 return _element;
116 }
117
123 {
124 return &_element;
125 }
126
132 {
133 return _element;
134 }
135
141 {
142 return &_element;
143 }
144
145private:
146 void next()
147 {
148 _element.next();
149 }
150 element_type _element;
151};
152
160template <typename ElementAccessType>
162public:
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 }
181
186 {
187 next();
188 return *this;
189 }
190
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 }
212
219 bool operator!=(const ElementIteratorConst& rhs) const
220 {
221 return _element.getIndex() != rhs._element.getIndex();
222 }
223
229 {
230 return _element;
231 }
232
238 {
239 return &_element;
240 }
241
242private:
243 void next()
244 {
245 _element.next();
246 }
247 element_type _element;
248};
249
256template <typename ElementAccessType>
258public:
260 using access_type = typename ElementAccessType::access_type;
262 using element_type = typename ElementAccessType::element_type;
265
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, CodecIndex::ElementIndex::_invalid_array_pos});
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 }
336
341 {
342 if (_child_element_count > 0) {
343 return const_iterator(
344 element_type(CodecIndex(_codec_base_index, {_child_element_count, CodecIndex::ElementIndex::_invalid_array_pos}),
345 _child_element_count,
346 0,
347 _access));
348 }
349 else {
350 return const_iterator(element_type(CodecIndex(), 0, 0, _access));
351 }
352 }
353
358 {
359 return cend();
360 }
361
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 }
378
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 }
394
398 size_t size() const
399 {
400 return _child_element_count;
401 }
402
403private:
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
436template <typename AccessType>
438public:
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 };
455
462 static element_type getElement(access_type& access, const CodecIndex& index)
463 {
464 return access.getElement(index);
465 };
466
473 static size_t getChildCount(access_type& access, const CodecIndex& index)
474 {
475 return access.getElementChildCount(index);
476 };
477
487 static std::string getFullName(access_type& access, const CodecIndex& index)
488 {
489 return access.getElementFullName(index);
490 };
491
501 static std::string getName(access_type& access, const CodecIndex& index)
502 {
503 return access.getElementName(index);
504 };
505
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
541template <typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
543public:
545 using access_type = typename ElementAccessType::access_type;
546 using child_elements_type = ChildElementsType;
550
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 }
591
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 }
602
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 }
613
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 }
638
642 size_t getArraySize() const
643 {
644 return _codec_index.getLayout().array_size;
645 }
646
651 {
652 return _codec_index.getType();
653 }
654
661 std::string getFullName() const
662 {
663 return ElementAccessType::getFullName(_access, _codec_index);
664 }
665
672 std::string getName() const
673 {
674 return ElementAccessType::getName(_access, _codec_index);
675 }
676
683 std::string getBaseName() const
684 {
685 return ElementAccessType::getBaseName(_access, _codec_index);
686 }
687
692 bool isArray() const
693 {
694 return _codec_index.getLayout().array_size > 1;
695 }
696
701 bool hasChildren() const
702 {
703 return _child_elements.size() > 0;
704 }
705
711 {
712 return _child_elements;
713 }
714
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 }
726
731 self_type getArrayElement(size_t array_pos = 0) const
732 {
733 return self_type(_codec_index.getIndexForArrayPos(array_pos), getAccess());
734 }
735
740 bool isValid() const
741 {
742 return _codec_index != CodecIndex();
743 }
744
745private:
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 }
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
833template <typename AccessType>
834class DecoderElementAccess : public FactoryElementAccess<AccessType> {
835public:
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 };
853
860 static element_type getElement(access_type& access, const CodecIndex& index)
861 {
862 return access.getElement(index);
863 };
864
874 template <typename T>
875 static T getValue(access_type& access, const CodecIndex& index)
876 {
877 return access.template getElementValue<T>(index);
878 }
879
888 {
889 return access.getElementVariantValue(index);
890 };
891
899 static std::string getStringValue(access_type& access, const CodecIndex& index)
900 {
901 return access.getElementStringValue(index);
902 };
903
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 };
918
925 static const void* getAddress(access_type& access, const CodecIndex& index)
926 {
927 return access.getElementAddress(index);
928 };
929};
930
937template <typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
938class DecoderElement : public FactoryElement<ElementAccessType, ChildElementsType> {
939public:
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
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 }
991
996 {
997 return ElementAccessType::getVariantValue(base_type::getAccess(), base_type::getIndex());
998 };
999
1003 std::string getStringValue() const
1004 {
1005 return ElementAccessType::getStringValue(base_type::getAccess(), base_type::getIndex());
1006 };
1007
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 }
1018
1022 const void* getAddress() const
1023 {
1024 return ElementAccessType::getAddress(base_type::getAccess(), base_type::getIndex());
1025 }
1026
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 }
1038
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
1049private:
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
1085template <typename AccessType>
1086class CodecElementAccess : public DecoderElementAccess<AccessType> {
1087public:
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 };
1105
1112 static element_type getElement(access_type& access, const CodecIndex& index)
1113 {
1114 return access.getElement(index);
1115 };
1116
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 }
1131
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 };
1144
1151 static void setStringValue(access_type& access,
1152 const CodecIndex& index,
1153 const std::string& value)
1154 {
1155 access.setElementStringValue(index, value);
1156 };
1157
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 };
1172
1179 static void* getAddress(access_type& access, const CodecIndex& index)
1180 {
1181 return access.getElementAddress(index);
1182 };
1183};
1184
1190template <typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
1191class CodecElement : public DecoderElement<ElementAccessType, ChildElementsType> {
1192public:
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
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 }
1246
1252 {
1253 return ElementAccessType::setVariantValue(
1254 base_type::getAccess(), base_type::getIndex(), value);
1255 };
1256
1261 void setStringValue(const std::string& value)
1262 {
1263 return ElementAccessType::setStringValue(
1264 base_type::getAccess(), base_type::getIndex(), value);
1265 };
1266
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
1320 {
1321 return ElementAccessType::getAddress(base_type::getAccess(), base_type::getIndex());
1322 }
1323
1331 {
1332 return factory_base_type::_child_elements;
1333 }
1334
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 }
1361
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
1383private:
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
1448template <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
1527template <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
typename DecoderElementAccess< const Decoder >::element_type element_type
ChildElements & operator=(ChildElements &&)=default
move operator
~ChildElements()=default
DTOR.
size_t size() const
Size of the container (child count)
const_iterator begin() const
begin
ElementIterator< DecoderElementAccess< const Decoder > > iterator
ElementIteratorConst< DecoderElementAccess< const Decoder > > const_iterator
const_iterator cbegin() const
cbegin
ChildElements(ChildElements &&)=default
move CTOR
ChildElements & operator=(const ChildElements &)=delete
no copy operator
const_iterator cend() const
cend
const_iterator end() const
end
typename DecoderElementAccess< const Decoder >::access_type access_type
ChildElements(const ChildElements &)=delete
no copy CTOR
A element access type concept template to retrieve element information from the AccessType,...
AccessType access_type
access type
static element_type getElement(access_type &access, const std::string &full_element_name)
Get a element object for the given full_element_name.
CodecElement< self_type, ChildElements< self_type > > element_type
supported element type
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 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.
CodecElementAccess< AccessType > self_type
self type
static void * getAddress(access_type &access, const CodecIndex &index)
Get the address (with write access)
A CodecElement to get and set values.
child_elements_type & getChildElements()
Gets an reference to the child elements.
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.
typename child_elements_type::const_iterator const_iterator_type
CodecElement< CodecElementAccess< Codec >, ChildElements< CodecElementAccess< Codec > > > 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.
typename child_elements_type::iterator 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.
FactoryElement< CodecElementAccess< Codec >, ChildElements< CodecElementAccess< Codec > > > factory_base_type
void * getAddress()
Get the address (with writing access)
void setVariantValue(const a_util::variant::Variant &value)
Sets the value from value as variant.
DecoderElement< CodecElementAccess< Codec >, ChildElements< CodecElementAccess< Codec > > > base_type
typename factory_base_type::child_elements_type child_elements_type
void setStringValue(const std::string &value)
Sets the value from value as string.
self_type getArrayElement(size_t array_pos=0) const
Get the array element of the given array_pos.
typename CodecElementAccess< Codec >::access_type access_type
static constexpr size_t _invalid_array_pos
Invalid array pos.
static constexpr size_t _invalid_element_index
Invalid element index.
Fast Access Index Type for the coders.
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.
AccessType access_type
access type in use
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.
DecoderElementAccess< AccessType > self_type
self type
DecoderElement< self_type, ChildElements< self_type > > element_type
supported element type
A DecoderElement to get values.
std::string getStringValue() const
Get the value as string.
FactoryElement< DecoderElementAccess< const Decoder >, ChildElements< DecoderElementAccess< const Decoder > > > 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
T getValue() const
Get the value as type T.
void getRawValue(void *value, size_t value_size) const
Get the as copy to the value buffer.
DecoderElement< DecoderElementAccess< const Decoder >, ChildElements< DecoderElementAccess< const Decoder > > > self_type
a_util::variant::Variant getVariantValue() const
Get the value as variant.
DecoderElement()=delete
CTOR.
self_type getArrayElement(size_t array_pos=0) const
Get the array element of the given array_pos.
const void * getAddress() const
Get the address of the element.
typename DecoderElementAccess< const Decoder >::access_type access_type
The const 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!)
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!)
ElementIteratorConst & operator++()
increasing operator to the next position.
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.
std::forward_iterator_tag iterator_category
iterator type
ElementIterator & operator++()
increasing operator to the next position.
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.
FactoryElementAccess< AccessType > self_type
self type
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.
FactoryElement< self_type, ChildElements< self_type > > element_type
element type
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.
const child_elements_type & getChildElements() const
Get the ChildElements.
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
const CodecIndex & getIndex() const
Get the codec index of the element.
FactoryElement & operator=(const FactoryElement &other)
move assignment operator
~FactoryElement()=default
DTOR.
ChildElements< FactoryElementAccess< const CodecFactory > > child_elements_type
std::string getName() const
Get the name of the element If the element is an array you get the elements array name representation...
ddl::codec::ElementType getType() const
Get the type of the element.
FactoryElement< FactoryElementAccess< const CodecFactory >, ChildElements< FactoryElementAccess< const CodecFactory > > > self_type
bool hasChildren() const
Get children information.
size_t getArraySize() const
Get the array size.
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 FactoryElementAccess< const CodecFactory >::access_type access_type
FactoryElement & operator=(FactoryElement &&other)
copy assignment operator
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).
Common include for component a_util::variant.