Dev Essential
Loading...
Searching...
No Matches
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,
319 ElementAccessType::resolve(_access, begin_index);
320 size_t element_child_count = begin_index.getLayout().child_element_count;
322 std::move(begin_index), _child_element_count, element_child_count, _access));
323 }
324 else {
325 return const_iterator(element_type(CodecIndex(), 0, 0, _access));
326 }
327 }
328
334 {
335 return cbegin();
336 }
337
342 {
343 if (_child_element_count > 0) {
345 CodecIndex(_codec_base_index,
346 {_child_element_count, CodecIndex::ElementIndex::_invalid_array_pos}),
347 _child_element_count,
348 0,
349 _access));
350 }
351 else {
352 return const_iterator(element_type(CodecIndex(), 0, 0, _access));
353 }
354 }
355
360 {
361 return cend();
362 }
363
368 {
369 if (_child_element_count > 0) {
370 CodecIndex begin_index(_codec_base_index, {0, 0});
371 ElementAccessType::resolve(_access, begin_index);
372 size_t element_child_count = begin_index.getLayout().child_element_count;
373 return iterator(element_type(
374 std::move(begin_index), _child_element_count, element_child_count, _access));
375 }
376 else {
377 return iterator(element_type(CodecIndex(), 0, 0, _access));
378 }
379 }
380
385 {
386 if (_child_element_count > 0) {
387 return iterator(element_type(CodecIndex(_codec_base_index, {_child_element_count, 0}),
388 _child_element_count,
389 0,
390 _access));
391 }
392 else {
393 return iterator(element_type(CodecIndex(), 0, 0, _access));
394 }
395 }
396
400 size_t size() const
401 {
402 return _child_element_count;
403 }
404
405private:
406 ChildElements(const CodecIndex& base_index, access_type& access)
407 : _codec_base_index(base_index),
408 _child_element_count(ElementAccessType::getChildCount(access, base_index)),
409 _access(access)
410 {
411 }
412
413 ChildElements(const CodecIndex& base_index, size_t child_element_count, access_type& access)
414 : _codec_base_index(base_index), _child_element_count(child_element_count), _access(access)
415 {
416 }
417 void resetChildCount(size_t child_element_count)
418 {
419 _child_element_count = child_element_count;
420 }
421 void resetChildCount()
422 {
423 resetChildCount(ElementAccessType::getChildCount(_access, _codec_base_index));
424 }
425
426 const CodecIndex& _codec_base_index;
427 size_t _child_element_count;
428 access_type& _access;
429};
430
438template <typename AccessType>
440public:
441 using access_type = AccessType;
444
453 static element_type getElement(access_type& access, std::string_view full_path)
454 {
455 return access.getElement(full_path);
456 }
457
464 static element_type getElement(access_type& access, const CodecIndex& index)
465 {
466 return access.getElement(index);
467 }
468
479 const CodecIndex& parent_index,
480 std::string_view relative_path)
481 {
482 return access.getChildElement(parent_index, relative_path);
483 }
484
491 static size_t getChildCount(access_type& access, const CodecIndex& index)
492 {
493 return access.getElementChildCount(index);
494 };
495
505 static std::string getFullName(access_type& access, const CodecIndex& index)
506 {
507 return access.getElementFullName(index);
508 }
509
519 static std::string getName(access_type& access, const CodecIndex& index)
520 {
521 return access.getElementName(index);
522 }
523
533 static std::string getBaseName(access_type& access, const CodecIndex& index)
534 {
535 return access.getElementBaseName(index);
536 }
537
545 static void resolve(access_type& access, CodecIndex& index)
546 {
547 return access.resolve(index);
548 }
549};
550
559template <typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
561public:
563 using access_type = typename ElementAccessType::access_type;
564 using child_elements_type = ChildElementsType;
568
593
597 FactoryElement() = delete;
603 : _codec_index(std::move(other._codec_index)),
604 _end_element_index(std::move(other._end_element_index)),
605 _child_elements(_codec_index, other._child_elements.size(), other._access),
606 _access(other._access)
607 {
608 }
609
615 {
616 _codec_index = std::move(other._codec_index);
617 _end_element_index = std::move(other._end_element_index);
618 _child_elements = child_elements_type(_codec_index, other._child_elements.size(), _access);
619 }
620
625 : _codec_index(other._codec_index),
626 _end_element_index(other._end_element_index),
627 _child_elements(_codec_index, other._child_elements.size(), other._access),
628 _access(other._access)
629 {
630 }
631
637 {
638 _codec_index = other._codec_index;
639 _end_element_index = other._end_element_index;
640 _child_elements = child_elements_type(_codec_index, other._child_elements.size(), _access);
641 }
642
647 ~FactoryElement() = default;
652 const CodecIndex& getIndex() const
653 {
654 return _codec_index;
655 }
656
660 size_t getArraySize() const
661 {
662 return _codec_index.getLayout().array_size;
663 }
664
669 {
670 return _codec_index.getType();
671 }
672
679 std::string getFullName() const
680 {
681 return ElementAccessType::getFullName(_access, _codec_index);
682 }
683
690 std::string getName() const
691 {
692 return ElementAccessType::getName(_access, _codec_index);
693 }
694
701 std::string getBaseName() const
702 {
703 return ElementAccessType::getBaseName(_access, _codec_index);
704 }
705
710 bool isArray() const
711 {
712 return _codec_index.getLayout().array_size > 1;
713 }
714
719 bool hasChildren() const
720 {
721 return _child_elements.size() > 0;
722 }
723
729 {
730 return _child_elements;
731 }
732
737 self_type getChildElement(std::string_view path) const
738 {
739 return ElementAccessType::getChildElement(_access, _codec_index, path);
740 }
741
746 self_type getArrayElement(size_t array_pos = 0) const
747 {
748 return self_type(_codec_index.getIndexForArrayPos(array_pos), getAccess());
749 }
750
755 bool isValid() const
756 {
757 return _codec_index != CodecIndex();
758 }
759
760private:
762 size_t end_element_index,
763 size_t child_elements_count,
764 access_type& access)
765 : _codec_index(std::move(index)),
766 _end_element_index(end_element_index),
767 _child_elements(_codec_index, child_elements_count, access),
768 _access(access)
769 {
770 }
771 FactoryElement(CodecIndex&& index, size_t end_element_index, access_type& access)
772 : _codec_index(std::move(index)),
773 _end_element_index(end_element_index),
774 _child_elements(
775 _codec_index, ElementAccessType::getChildCount(access, _codec_index), access),
776 _access(access)
777 {
778 }
779 FactoryElement(std::string_view full_path, access_type& access)
780 : _codec_index(std::move(ElementAccessType::getElement(access, full_path)._codec_index)),
781 _end_element_index(CodecIndex::ElementIndex::_invalid_element_index),
782 _child_elements(_codec_index, access),
783 _access(access)
784 {
785 }
786
787 FactoryElement(CodecIndex&& index, access_type& access)
788 : _codec_index(std::move(index)),
789 _end_element_index(CodecIndex::ElementIndex::_invalid_element_index),
790 _child_elements(_codec_index, access),
791 _access(access)
792 {
793 }
795 : _codec_index(CodecIndex()),
796 _end_element_index(CodecIndex::ElementIndex::_invalid_element_index),
797 _child_elements(_codec_index, 0, access),
798 _access(access)
799 {
800 }
801 void next()
802 {
803 auto break_increasing = false;
804 auto index_valid = false;
805 while (!break_increasing) {
806 ++_codec_index;
807 const auto element_index = _codec_index.back();
808 if (element_index.getIndex() != CodecIndex::ElementIndex::_invalid_element_index &&
809 element_index.getIndex() < _end_element_index) {
810 ElementAccessType::resolve(_access, _codec_index);
811 if (_codec_index.getLayout().array_size != 0) {
812 break_increasing = true;
813 index_valid = true;
814 }
815 }
816 else {
817 break_increasing = true;
818 }
819 }
820 if (index_valid) {
821 _child_elements.resetChildCount(_codec_index.getLayout().child_element_count);
822 }
823 }
824 access_type& getAccess() const
825 {
826 return _access;
827 }
828
829 void resetIndex(CodecIndex&& codec_index)
830 {
831 _codec_index = std::move(codec_index);
832 _child_elements.resetChildCount();
833 }
834 CodecIndex _codec_index;
835 size_t _end_element_index;
836 child_elements_type _child_elements;
837 access_type& _access;
838};
839
848template <typename AccessType>
849class DecoderElementAccess : public FactoryElementAccess<AccessType> {
850public:
851 using access_type = AccessType;
855
864 static element_type getElement(access_type& access, std::string_view full_path)
865 {
866 return access.getElement(full_path);
867 };
868
875 static element_type getElement(access_type& access, const CodecIndex& index)
876 {
877 return access.getElement(index);
878 }
879
890 const CodecIndex& parent_index,
891 std::string_view relative_path)
892 {
893 return access.getChildElement(parent_index, relative_path);
894 }
895
905 template <typename T>
906 static T getValue(access_type& access, const CodecIndex& index)
907 {
908 return access.template getElementValue<T>(index);
909 }
910
919 {
920 return access.getElementVariantValue(index);
921 }
922
930 static std::string getStringValue(access_type& access, const CodecIndex& index)
931 {
932 return access.getElementStringValue(index);
933 }
934
942 static void getRawValue(access_type& access,
943 const CodecIndex& index,
944 void* value,
945 size_t value_size)
946 {
947 access.getElementRawValue(index, value, value_size);
948 }
949
956 static const void* getAddress(access_type& access, const CodecIndex& index)
957 {
958 return access.getElementAddress(index);
959 }
960};
961
968template <typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
969class DecoderElement : public FactoryElement<ElementAccessType, ChildElementsType> {
970public:
974 using access_type = typename ElementAccessType::access_type;
976 using iterator_type = typename child_elements_type::iterator;
978 using const_iterator_type = typename child_elements_type::const_iterator;
979
999 friend base_type;
1004
1008 DecoderElement() = delete;
1016 template <typename T>
1017 T getValue() const
1018 {
1019 return ElementAccessType::template getValue<T>(base_type::getAccess(),
1021 }
1022
1027 {
1028 return ElementAccessType::getVariantValue(base_type::getAccess(), base_type::getIndex());
1029 }
1030
1034 std::string getStringValue() const
1035 {
1036 return ElementAccessType::getStringValue(base_type::getAccess(), base_type::getIndex());
1037 }
1038
1044 void getRawValue(void* value, size_t value_size) const
1045 {
1046 ElementAccessType::getRawValue(
1047 base_type::getAccess(), base_type::getIndex(), value, value_size);
1048 }
1049
1053 const void* getAddress() const
1054 {
1055 return ElementAccessType::getAddress(base_type::getAccess(), base_type::getIndex());
1056 }
1057
1062 self_type getChildElement(std::string_view path) const
1063 {
1064 return ElementAccessType::getChildElement(
1065 base_type::getAccess(), base_type::getIndex(), path);
1066 }
1067
1072 self_type getArrayElement(size_t array_pos = 0) const
1073 {
1074 return self_type(base_type::getIndex().getIndexForArrayPos(array_pos),
1075 base_type::getAccess());
1076 }
1077
1078private:
1079 DecoderElement(CodecIndex&& index,
1080 size_t end_element_index,
1081 size_t child_elements_count,
1082 access_type& access)
1083 : base_type(std::move(index), end_element_index, child_elements_count, access)
1084 {
1085 }
1086 DecoderElement(CodecIndex&& index, size_t end_element_index, access_type& access)
1087 : base_type(std::move(index), end_element_index, access)
1088 {
1089 }
1090 DecoderElement(const std::string& element_name, access_type& access)
1091 : base_type(element_name, access)
1092 {
1093 }
1094 DecoderElement(CodecIndex&& index, access_type& access) : base_type(std::move(index), access)
1095 {
1096 }
1097 DecoderElement(access_type& access) : base_type(access)
1098 {
1099 }
1100 void next()
1101 {
1102 base_type::next();
1103 }
1104};
1105
1114template <typename AccessType>
1115class CodecElementAccess : public DecoderElementAccess<AccessType> {
1116public:
1117 using access_type = AccessType;
1121
1130 static element_type getElement(access_type& access, std::string_view full_path)
1131 {
1132 return access.getElement(full_path);
1133 }
1134
1141 static element_type getElement(access_type& access, const CodecIndex& index)
1142 {
1143 return access.getElement(index);
1144 }
1145
1156 template <typename T>
1157 static void setValue(access_type& access, const CodecIndex& index, const T& value)
1158 {
1159 access.template setElementValue<T>(index, value);
1160 }
1161
1168 static void setVariantValue(access_type& access,
1169 const CodecIndex& index,
1170 const a_util::variant::Variant& value)
1171 {
1172 access.setElementVariantValue(index, value);
1173 }
1174
1181 static void setStringValue(access_type& access,
1182 const CodecIndex& index,
1183 const std::string& value)
1184 {
1185 access.setElementStringValue(index, value);
1186 }
1187
1195 static void setRawValue(access_type& access,
1196 const CodecIndex& index,
1197 const void* value,
1198 size_t value_size)
1199 {
1200 access.setElementRawValue(index, value, value_size);
1201 }
1202
1209 static void* getAddress(access_type& access, const CodecIndex& index)
1210 {
1211 return access.getElementAddress(index);
1212 }
1213};
1214
1220template <typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
1221class CodecElement : public DecoderElement<ElementAccessType, ChildElementsType> {
1222public:
1227 using access_type = typename ElementAccessType::access_type;
1230 using iterator_type = typename child_elements_type::iterator;
1232 using const_iterator_type = typename child_elements_type::const_iterator;
1233
1261 CodecElement() = delete;
1270 template <typename T>
1271 void setValue(const T& value)
1272 {
1273 return ElementAccessType::template setValue<T>(
1274 base_type::getAccess(), base_type::getIndex(), value);
1275 }
1276
1282 {
1283 return ElementAccessType::setVariantValue(
1284 base_type::getAccess(), base_type::getIndex(), value);
1285 };
1286
1291 void setStringValue(const std::string& value)
1292 {
1293 return ElementAccessType::setStringValue(
1294 base_type::getAccess(), base_type::getIndex(), value);
1295 };
1296
1302 void setRawValue(const void* value, size_t value_size)
1303 {
1304 return ElementAccessType::setRawValue(
1305 base_type::getAccess(), base_type::getIndex(), value, value_size);
1306 };
1307
1314 void reset(bool zero_value_of_known_type = false)
1315 {
1316 const auto& layout = base_type::getIndex().getLayout();
1317 if (layout.constant_info->isConstant()) {
1318 return ElementAccessType::setVariantValue(base_type::getAccess(),
1320 layout.constant_info->getConstantValue());
1321 }
1322 else if (layout.default_value_info->hasDefaultValue()) {
1323 return ElementAccessType::setVariantValue(base_type::getAccess(),
1325 layout.default_value_info->getDefaultValue());
1326 }
1327 else {
1328 // we can only reset known types
1329 if (zero_value_of_known_type) {
1330 auto known_type = base_type::getType();
1331 if (known_type != ElementType::cet_empty &&
1332 known_type != ElementType::cet_sub_codec &&
1333 known_type != ElementType::cet_user_type) {
1334 uint64_t null_value = 0;
1335 return ElementAccessType::setRawValue(base_type::getAccess(),
1337 &null_value,
1338 sizeof(null_value));
1339 }
1340 }
1341 }
1342 }
1343
1350 {
1351 return ElementAccessType::getAddress(base_type::getAccess(), base_type::getIndex());
1352 }
1353
1361 {
1362 return factory_base_type::_child_elements;
1363 }
1364
1370 self_type getChildElement(std::string_view path) const
1371 {
1372 return ElementAccessType::getChildElement(
1373 base_type::getAccess(), base_type::getIndex(), path);
1374 }
1375
1382 self_type getChildElement(std::string_view name)
1383 {
1384 return ElementAccessType::getChildElement(
1385 base_type::getAccess(), base_type::getIndex(), name);
1386 }
1387
1392 self_type getArrayElement(size_t array_pos = 0) const
1393 {
1394 return self_type(base_type::getIndex().getIndexForArrayPos(array_pos),
1395 base_type::getAccess());
1396 }
1397
1403 self_type getArrayElement(size_t array_pos = 0)
1404 {
1405 return self_type(base_type::getIndex().getIndexForArrayPos(array_pos),
1406 base_type::getAccess());
1407 }
1408
1409private:
1410 CodecElement(CodecIndex&& index,
1411 size_t end_element_index,
1412 size_t child_elements_count,
1413 access_type& access)
1414 : base_type(std::move(index), end_element_index, child_elements_count, access)
1415 {
1416 }
1417 CodecElement(CodecIndex&& index, size_t end_element_index, access_type& access)
1418 : base_type(std::move(index), end_element_index, access)
1419 {
1420 }
1421 CodecElement(const std::string& element_name, access_type& access)
1422 : base_type(element_name, access)
1423 {
1424 }
1425 CodecElement(CodecIndex&& index, access_type& access) : base_type(std::move(index), access)
1426 {
1427 }
1428 CodecElement(access_type& access) : base_type(access)
1429 {
1430 }
1431 void next()
1432 {
1433 base_type::next();
1434 }
1435};
1436
1474template <typename ElementsType>
1476 ElementsType& elements,
1477 const std::function<void(std::conditional_t<std::is_const<ElementsType>::value,
1478 const typename ElementsType::element_type,
1479 typename ElementsType::element_type>&)>& func)
1480{
1481 for (auto& element: elements) {
1482 if (element.hasChildren()) {
1483 if (element.isArray()) {
1484 for (size_t array_pos = 0; array_pos < element.getArraySize(); ++array_pos) {
1485 auto array_element = element.getArrayElement(array_pos);
1486 auto& children = array_element.getChildElements();
1487 forEachLeafElement(children, func);
1488 }
1489 }
1490 else {
1491 auto& children = element.getChildElements();
1492 forEachLeafElement(children, func);
1493 }
1494 }
1495 else {
1496 if (element.isArray()) {
1497 for (size_t array_pos = 0; array_pos < element.getArraySize(); ++array_pos) {
1498 auto array_element = element.getArrayElement(array_pos);
1499 func(array_element);
1500 }
1501 }
1502 else {
1503 func(element);
1504 }
1505 }
1506 }
1507}
1508
1553template <typename ElementsType>
1555 ElementsType& elements,
1556 const std::function<void(std::conditional_t<std::is_const<ElementsType>::value,
1557 const typename ElementsType::element_type,
1558 typename ElementsType::element_type>&)>& func)
1559{
1560 for (auto& element: elements) {
1561 func(element);
1562 if (element.hasChildren()) {
1563 auto& children = element.getChildElements();
1564 forEachElement(children, func);
1565 }
1566 }
1567}
1568
1569} // namespace codec
1570} // namespace ddl
1571
1572#endif // DDL_CODEC_ITERATOR_CLASS_HEADER
Definition variant.h:46
~ChildElements()=default
DTOR.
ElementIteratorConst< DecoderElementAccess< const Decoder > > const_iterator
Definition codec_iterator.h:263
ChildElements & operator=(const ChildElements &)=delete
no copy operator
iterator end()
end
Definition codec_iterator.h:384
typename DecoderElementAccess< const Decoder >::element_type element_type
Definition codec_iterator.h:262
ElementIterator< DecoderElementAccess< const Decoder > > iterator
Definition codec_iterator.h:264
const_iterator end() const
end
Definition codec_iterator.h:359
iterator begin()
begin
Definition codec_iterator.h:367
const_iterator begin() const
begin
Definition codec_iterator.h:333
ChildElements(ChildElements &&)=default
move CTOR
ChildElements(const ChildElements &)=delete
no copy CTOR
const_iterator cend() const
cend
Definition codec_iterator.h:341
typename DecoderElementAccess< const Decoder >::access_type access_type
Definition codec_iterator.h:260
ChildElements & operator=(ChildElements &&)=default
move operator
const_iterator cbegin() const
cbegin
Definition codec_iterator.h:314
size_t size() const
Size of the container (child count)
Definition codec_iterator.h:400
A element access type concept template to retrieve element information from the AccessType,...
Definition codec_iterator.h:1115
static void setStringValue(access_type &access, const CodecIndex &index, const std::string &value)
Sets the value from value as string.
Definition codec_iterator.h:1181
AccessType access_type
access type
Definition codec_iterator.h:1117
static void setVariantValue(access_type &access, const CodecIndex &index, const a_util::variant::Variant &value)
Sets the value from value as variant.
Definition codec_iterator.h:1168
static void setValue(access_type &access, const CodecIndex &index, const T &value)
Sets the value from value of type T.
Definition codec_iterator.h:1157
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.
Definition codec_iterator.h:1195
static element_type getElement(access_type &access, const CodecIndex &index)
Get a element object for the given index.
Definition codec_iterator.h:1141
static element_type getElement(access_type &access, std::string_view full_path)
Get a element object for the given full_path.
Definition codec_iterator.h:1130
CodecElementAccess< AccessType > self_type
Definition codec_iterator.h:1118
static void * getAddress(access_type &access, const CodecIndex &index)
Get the address (with write access)
Definition codec_iterator.h:1209
CodecElement< self_type, ChildElements< self_type > > element_type
supported element type
Definition codec_iterator.h:1120
A CodecElement to get and set values.
Definition codec_iterator.h:1221
void setValue(const T &value)
Sets the value from value of type T.
Definition codec_iterator.h:1271
self_type getChildElement(std::string_view path) const
Get a dedicated ChildElement by name.
Definition codec_iterator.h:1370
CodecElement< CodecElementAccess< Codec >, ChildElements< CodecElementAccess< Codec > > > self_type
Definition codec_iterator.h:1226
typename child_elements_type::iterator iterator_type
Definition codec_iterator.h:1230
typename factory_base_type::child_elements_type child_elements_type
Definition codec_iterator.h:1229
void setRawValue(const void *value, size_t value_size)
Set the value by copying from a value buffer.
Definition codec_iterator.h:1302
DecoderElement< CodecElementAccess< Codec >, ChildElements< CodecElementAccess< Codec > > > base_type
Definition codec_iterator.h:1225
self_type getArrayElement(size_t array_pos=0)
Get the array element of the given array_pos.
Definition codec_iterator.h:1403
FactoryElement< CodecElementAccess< Codec >, ChildElements< CodecElementAccess< Codec > > > factory_base_type
Definition codec_iterator.h:1224
self_type getArrayElement(size_t array_pos=0) const
Get the array element of the given array_pos.
Definition codec_iterator.h:1392
typename child_elements_type::const_iterator const_iterator_type
Definition codec_iterator.h:1232
child_elements_type & getChildElements()
Gets an reference to the child elements.
Definition codec_iterator.h:1360
typename CodecElementAccess< Codec >::access_type access_type
Definition codec_iterator.h:1227
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...
Definition codec_iterator.h:1314
void setStringValue(const std::string &value)
Sets the value from value as string.
Definition codec_iterator.h:1291
CodecElement()=delete
CTOR.
self_type getChildElement(std::string_view name)
Get a dedicated ChildElement by name.
Definition codec_iterator.h:1382
void setVariantValue(const a_util::variant::Variant &value)
Sets the value from value as variant.
Definition codec_iterator.h:1281
void * getAddress()
Get the address (with writing access)
Definition codec_iterator.h:1349
static constexpr size_t _invalid_element_index
Invalid element index.
Definition codec_index.h:342
static constexpr size_t _invalid_array_pos
Invalid array pos.
Definition codec_index.h:346
Definition codec_index.h:276
const ElementLayout & getLayout() const
Get the Layout.
A element access type concept template to retrieve element information from the AccessType and get th...
Definition codec_iterator.h:849
AccessType access_type
access type in use
Definition codec_iterator.h:851
static element_type getChildElement(access_type &access, const CodecIndex &parent_index, std::string_view relative_path)
Get a child element object for the given element_name.
Definition codec_iterator.h:889
static element_type getElement(access_type &access, const CodecIndex &index)
Get a element object for the given index.
Definition codec_iterator.h:875
static element_type getElement(access_type &access, std::string_view full_path)
Get a element object for the given full_element_name.
Definition codec_iterator.h:864
DecoderElementAccess< AccessType > self_type
Definition codec_iterator.h:852
static const void * getAddress(access_type &access, const CodecIndex &index)
Get the address of the element.
Definition codec_iterator.h:956
DecoderElement< self_type, ChildElements< self_type > > element_type
supported element type
Definition codec_iterator.h:854
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.
Definition codec_iterator.h:942
static std::string getStringValue(access_type &access, const CodecIndex &index)
Get the value as type string.
Definition codec_iterator.h:930
static a_util::variant::Variant getVariantValue(access_type &access, const CodecIndex &index)
Get the value as variant.
Definition codec_iterator.h:918
static T getValue(access_type &access, const CodecIndex &index)
Get the value as type T.
Definition codec_iterator.h:906
A DecoderElement to get values.
Definition codec_iterator.h:969
typename DecoderElementAccess< const Decoder >::access_type access_type
Definition codec_iterator.h:974
void getRawValue(void *value, size_t value_size) const
Get the as copy to the value buffer.
Definition codec_iterator.h:1044
typename child_elements_type::iterator iterator_type
Definition codec_iterator.h:976
T getValue() const
Get the value as type T.
Definition codec_iterator.h:1017
self_type getArrayElement(size_t array_pos=0) const
Get the array element of the given array_pos.
Definition codec_iterator.h:1072
const void * getAddress() const
Get the address of the element.
Definition codec_iterator.h:1053
DecoderElement< DecoderElementAccess< const Decoder >, ChildElements< DecoderElementAccess< const Decoder > > > self_type
Definition codec_iterator.h:972
self_type getChildElement(std::string_view path) const
Get the child element with the given name.
Definition codec_iterator.h:1062
typename child_elements_type::const_iterator const_iterator_type
Definition codec_iterator.h:978
DecoderElement()=delete
CTOR.
typename base_type::child_elements_type child_elements_type
Definition codec_iterator.h:975
FactoryElement< DecoderElementAccess< const Decoder >, ChildElements< DecoderElementAccess< const Decoder > > > base_type
Definition codec_iterator.h:971
std::string getStringValue() const
Get the value as string.
Definition codec_iterator.h:1034
a_util::variant::Variant getVariantValue() const
Get the value as variant.
Definition codec_iterator.h:1026
The const element iterator.
Definition codec_iterator.h:161
ElementIteratorConst()=delete
default CTOR
const element_type value_type
const value type of the iterator
Definition codec_iterator.h:164
const_pointer operator->() const
pointer access (check for end!)
Definition codec_iterator.h:237
std::forward_iterator_tag iterator_category
iterator type
Definition codec_iterator.h:168
ElementIteratorConst & operator++()
increasing operator to the next position.
Definition codec_iterator.h:185
value_type * const_pointer
pointer to const data value type
Definition codec_iterator.h:166
ElementIteratorConst operator++(int)
iterator increasing.
Definition codec_iterator.h:194
const_reference operator*() const
defering access (check for end!)
Definition codec_iterator.h:228
value_type & const_reference
const reference value type
Definition codec_iterator.h:165
bool operator==(const ElementIteratorConst &rhs) const
checks for equality (refering the same element!)
Definition codec_iterator.h:208
bool operator!=(const ElementIteratorConst &rhs) const
checks for not equality (does not refer the same element!)
Definition codec_iterator.h:219
ElementIteratorConst(value_type &&element)
CTOR for one element.
Definition codec_iterator.h:178
typename ElementAccessType::element_type element_type
The element type in use.
Definition codec_iterator.h:163
int difference_type
difference value type
Definition codec_iterator.h:167
The element iterator.
Definition codec_iterator.h:42
const value_type & const_reference
const reference value type
Definition codec_iterator.h:47
ElementIterator operator++(int)
iterator increasing.
Definition codec_iterator.h:80
ElementIterator(value_type &&element)
CTOR for one element.
Definition codec_iterator.h:62
const_reference operator*() const
defering access (check for end!)
Definition codec_iterator.h:113
bool operator==(const ElementIterator &rhs) const
checks for equality (refering the same element!)
Definition codec_iterator.h:93
int difference_type
difference value type
Definition codec_iterator.h:50
typename ElementAccessType::element_type element_type
The element type in use.
Definition codec_iterator.h:44
std::forward_iterator_tag iterator_category
iterator type
Definition codec_iterator.h:51
ElementIterator & operator++()
increasing operator to the next position.
Definition codec_iterator.h:70
value_type & reference
Reference value type.
Definition codec_iterator.h:46
reference operator*()
defering access (check for end!)
Definition codec_iterator.h:131
element_type value_type
Value type of the iterator.
Definition codec_iterator.h:45
const_pointer operator->() const
pointer access (check for end!)
Definition codec_iterator.h:122
bool operator!=(const ElementIterator &rhs) const
checks for not equality (does not refer the same element!)
Definition codec_iterator.h:104
const value_type * const_pointer
pointer to const data value type
Definition codec_iterator.h:49
value_type * pointer
Pointer type.
Definition codec_iterator.h:48
ElementIterator()=delete
default CTOR
pointer operator->()
pointer access (check for end!)
Definition codec_iterator.h:140
A factory element access type concept template to retrieve element information from the AccessType....
Definition codec_iterator.h:439
static std::string getBaseName(access_type &access, const CodecIndex &index)
Get the name of the element within its level structure. If the element is an array you get the elemen...
Definition codec_iterator.h:533
FactoryElementAccess< AccessType > self_type
self type
Definition codec_iterator.h:442
static element_type getElement(access_type &access, const CodecIndex &index)
Get a element object for the given index.
Definition codec_iterator.h:464
static element_type getElement(access_type &access, std::string_view full_path)
Get a element object for the given full_element_name.
Definition codec_iterator.h:453
static std::string getName(access_type &access, const CodecIndex &index)
Get the name of the element within its level structure. If the element is an array you get the elemen...
Definition codec_iterator.h:519
static std::string getFullName(access_type &access, const CodecIndex &index)
Get the full name of the element within its main structure. If the element is an array you get the el...
Definition codec_iterator.h:505
static size_t getChildCount(access_type &access, const CodecIndex &index)
Get the Child Count.
Definition codec_iterator.h:491
AccessType access_type
The access type (CodecFactory, Codec, Decoder, etc.)
Definition codec_iterator.h:441
static void resolve(access_type &access, CodecIndex &index)
Resolves the given CodecIndex and set the layout information.
Definition codec_iterator.h:545
static element_type getChildElement(access_type &access, const CodecIndex &parent_index, std::string_view relative_path)
Get a child element object for the given element_name.
Definition codec_iterator.h:478
FactoryElement< self_type, ChildElements< self_type > > element_type
element type
Definition codec_iterator.h:443
A FactoryElement.
Definition codec_iterator.h:560
self_type getArrayElement(size_t array_pos=0) const
Get the array element of the given array_pos.
Definition codec_iterator.h:746
typename child_elements_type::iterator iterator_type
Definition codec_iterator.h:565
~FactoryElement()=default
DTOR.
FactoryElement & operator=(const FactoryElement &other)
move assignment operator
Definition codec_iterator.h:636
FactoryElement< FactoryElementAccess< const CodecFactory >, ChildElements< FactoryElementAccess< const CodecFactory > > > self_type
Definition codec_iterator.h:562
ChildElements< FactoryElementAccess< const CodecFactory > > child_elements_type
Definition codec_iterator.h:564
const child_elements_type & getChildElements() const
Get the ChildElements.
Definition codec_iterator.h:728
std::string getBaseName() const
Get the base name of the element. If the element is an array you get the elements base name represent...
Definition codec_iterator.h:701
bool isArray() const
Get array information.
Definition codec_iterator.h:710
bool isValid() const
Get validation indormation.
Definition codec_iterator.h:755
self_type getChildElement(std::string_view path) const
Get the child element with the given name.
Definition codec_iterator.h:737
std::string getFullName() const
Get the full name of the element. If the element is an array you get the elements array name represen...
Definition codec_iterator.h:679
typename child_elements_type::const_iterator const_iterator_type
Definition codec_iterator.h:567
FactoryElement(const FactoryElement &other)
copy CTOR
Definition codec_iterator.h:624
size_t getArraySize() const
Get the array size.
Definition codec_iterator.h:660
FactoryElement(FactoryElement &&other)
move CTOR
Definition codec_iterator.h:602
ddl::codec::ElementType getType() const
Get the type of the element.
Definition codec_iterator.h:668
bool hasChildren() const
Get children information.
Definition codec_iterator.h:719
FactoryElement & operator=(FactoryElement &&other)
copy assignment operator
Definition codec_iterator.h:614
std::string getName() const
Get the name of the element If the element is an array you get the elements array name representation...
Definition codec_iterator.h:690
FactoryElement()=delete
no CTOR
const CodecIndex & getIndex() const
Get the codec index of the element.
Definition codec_iterator.h:652
typename FactoryElementAccess< const CodecFactory >::access_type access_type
Definition codec_iterator.h:563
Namespace for the new faster CodecFactory/Decoder/Codec implementation.
Definition codec.h:22
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.
Definition codec_iterator.h:1475
ElementType
The element type of the value.
Definition codec_type_info.h:30
@ cet_sub_codec
type marks a subcodec/substructure with children
Definition codec_type_info.h:43
@ cet_empty
Variant type is empty.
Definition codec_type_info.h:31
@ cet_user_type
type marks a user defined type
Definition codec_type_info.h:44
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 codec_iterator.h:1554
definition of the ddl namespace
Definition codec.h:21