2 * Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
4 * SPDX-License-Identifier: MIT
7 #ifndef BABELTRACE_CPP_COMMON_BT2_FIELD_CLASS_HPP
8 #define BABELTRACE_CPP_COMMON_BT2_FIELD_CLASS_HPP
11 #include <type_traits>
13 #include <babeltrace2/babeltrace.h>
15 #include "common/assert.h"
16 #include "cpp-common/bt2c/c-string-view.hpp"
17 #include "cpp-common/bt2s/optional.hpp"
19 #include "borrowed-object-iterator.hpp"
20 #include "borrowed-object.hpp"
22 #include "field-location.hpp"
23 #include "field-path.hpp"
24 #include "integer-range-set.hpp"
25 #include "internal/utils.hpp"
26 #include "optional-borrowed-object.hpp"
27 #include "shared-object.hpp"
33 struct FieldClassRefFuncs final
35 static void get(const bt_field_class * const libObjPtr) noexcept
37 bt_field_class_get_ref(libObjPtr);
40 static void put(const bt_field_class * const libObjPtr) noexcept
42 bt_field_class_put_ref(libObjPtr);
46 template <typename LibObjT>
47 struct CommonFieldClassSpec;
49 /* Functions specific to mutable field classes */
51 struct CommonFieldClassSpec<bt_field_class> final
53 static bt_value *userAttributes(bt_field_class * const libObjPtr) noexcept
55 return bt_field_class_borrow_user_attributes(libObjPtr);
59 /* Functions specific to constant field classes */
61 struct CommonFieldClassSpec<const bt_field_class> final
63 static const bt_value *userAttributes(const bt_field_class * const libObjPtr) noexcept
65 return bt_field_class_borrow_user_attributes_const(libObjPtr);
69 } /* namespace internal */
71 template <typename ObjT, typename LibObjT>
72 using SharedFieldClass = SharedObject<ObjT, LibObjT, internal::FieldClassRefFuncs>;
74 template <typename LibObjT>
75 class CommonBitArrayFieldClass;
77 template <typename LibObjT>
78 class CommonIntegerFieldClass;
80 template <typename LibObjT>
81 class ConstEnumerationFieldClassMapping;
83 template <typename LibObjT>
84 class CommonBaseEnumerationFieldClass;
86 template <typename LibObjT, typename MappingT>
87 class CommonEnumerationFieldClass;
89 template <typename LibObjT>
90 class CommonStructureFieldClass;
92 template <typename LibObjT>
93 class CommonArrayFieldClass;
95 template <typename LibObjT>
96 class CommonStaticArrayFieldClass;
98 template <typename LibObjT>
99 class CommonDynamicArrayWithLengthFieldClass;
101 template <typename LibObjT>
102 class CommonBlobFieldClass;
104 template <typename LibObjT>
105 class CommonStaticBlobFieldClass;
107 template <typename LibObjT>
108 class CommonDynamicBlobWithLengthFieldClass;
110 template <typename LibObjT>
111 class CommonOptionFieldClass;
113 template <typename LibObjT>
114 class CommonOptionWithSelectorFieldClass;
116 template <typename LibObjT>
117 class CommonOptionWithBoolSelectorFieldClass;
119 template <typename LibObjT>
120 class CommonVariantFieldClass;
122 template <typename LibObjT, typename RangeSetT>
123 class CommonOptionWithIntegerSelectorFieldClass;
125 template <typename LibObjT>
126 class CommonVariantWithoutSelectorFieldClass;
128 template <typename LibObjT>
129 class CommonVariantWithSelectorFieldClass;
131 template <typename LibObjT>
132 class ConstVariantWithIntegerSelectorFieldClassOption;
134 template <typename LibObjT, typename RangeSetT>
135 class CommonVariantWithIntegerSelectorFieldClass;
137 template <typename LibObjT>
138 class CommonEventClass;
140 template <typename LibObjT>
141 class CommonStreamClass;
143 template <typename LibObjT>
144 class CommonTraceClass;
146 enum class FieldClassType : std::uint64_t
148 Bool = BT_FIELD_CLASS_TYPE_BOOL,
149 BitArray = BT_FIELD_CLASS_TYPE_BIT_ARRAY,
150 UnsignedInteger = BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER,
151 SignedInteger = BT_FIELD_CLASS_TYPE_SIGNED_INTEGER,
152 UnsignedEnumeration = BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION,
153 SignedEnumeration = BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION,
154 SinglePrecisionReal = BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL,
155 DoublePrecisionReal = BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL,
156 String = BT_FIELD_CLASS_TYPE_STRING,
157 Structure = BT_FIELD_CLASS_TYPE_STRUCTURE,
158 StaticArray = BT_FIELD_CLASS_TYPE_STATIC_ARRAY,
159 DynamicArrayWithoutLength = BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD,
160 DynamicArrayWithLength = BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD,
161 OptionWithoutSelector = BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD,
162 OptionWithBoolSelector = BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD,
163 OptionWithUnsignedIntegerSelector =
164 BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
165 OptionWithSignedIntegerSelector = BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
166 VariantWithoutSelector = BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD,
167 VariantWithUnsignedIntegerSelector =
168 BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD,
169 VariantWithSignedIntegerSelector =
170 BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD,
171 StaticBlob = BT_FIELD_CLASS_TYPE_STATIC_BLOB,
172 DynamicBlob = BT_FIELD_CLASS_TYPE_DYNAMIC_BLOB,
173 DynamicBlobWithoutLengthField = BT_FIELD_CLASS_TYPE_DYNAMIC_BLOB_WITHOUT_LENGTH_FIELD,
174 DynamicBlobWithLengthField = BT_FIELD_CLASS_TYPE_DYNAMIC_BLOB_WITH_LENGTH_FIELD,
177 template <typename LibObjT>
178 class CommonFieldClass : public BorrowedObject<LibObjT>
181 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
184 using _ThisCommonFieldClass = CommonFieldClass<LibObjT>;
187 using typename BorrowedObject<LibObjT>::LibObjPtr;
188 using Shared = SharedFieldClass<CommonFieldClass<LibObjT>, LibObjT>;
189 using UserAttributes = internal::DepUserAttrs<LibObjT>;
191 explicit CommonFieldClass(const LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr}
195 template <typename OtherLibObjT>
196 CommonFieldClass(const CommonFieldClass<OtherLibObjT> fc) noexcept : _ThisBorrowedObject {fc}
200 template <typename OtherLibObjT>
201 CommonFieldClass operator=(const CommonFieldClass<OtherLibObjT> fc) noexcept
203 _ThisBorrowedObject::operator=(fc);
207 CommonFieldClass<const bt_field_class> asConst() const noexcept
209 return CommonFieldClass<const bt_field_class> {*this};
212 FieldClassType type() const noexcept
214 return static_cast<FieldClassType>(bt_field_class_get_type(this->libObjPtr()));
217 bool isBool() const noexcept
219 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_BOOL);
222 bool isBitArray() const noexcept
224 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_BIT_ARRAY);
227 bool isInteger() const noexcept
229 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_INTEGER);
232 bool isUnsignedInteger() const noexcept
234 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER);
237 bool isSignedInteger() const noexcept
239 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_SIGNED_INTEGER);
242 bool isEnumeration() const noexcept
244 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_ENUMERATION);
247 bool isUnsignedEnumeration() const noexcept
249 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION);
252 bool isSignedEnumeration() const noexcept
254 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION);
257 bool isReal() const noexcept
259 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_REAL);
262 bool isSinglePrecisionReal() const noexcept
264 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL);
267 bool isDoublePrecisionReal() const noexcept
269 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL);
272 bool isString() const noexcept
274 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_STRING);
277 bool isStructure() const noexcept
279 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_STRUCTURE);
282 bool isArray() const noexcept
284 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_ARRAY);
287 bool isStaticArray() const noexcept
289 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_STATIC_ARRAY);
292 bool isDynamicArray() const noexcept
294 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY);
297 bool isDynamicArrayWithoutLength() const noexcept
299 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD);
302 bool isDynamicArrayWithLength() const noexcept
304 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD);
307 bool isOption() const noexcept
309 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_OPTION);
312 bool isOptionWithoutSelector() const noexcept
314 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD);
317 bool isOptionWithSelector() const noexcept
319 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD);
322 bool isOptionWithBoolSelector() const noexcept
324 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD);
327 bool isOptionWithIntegerSelector() const noexcept
329 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD);
332 bool isOptionWithUnsignedIntegerSelector() const noexcept
334 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD);
337 bool isOptionWithSignedIntegerSelector() const noexcept
339 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD);
342 bool isVariant() const noexcept
344 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_VARIANT);
347 bool isVariantWithoutSelector() const noexcept
349 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD);
352 bool isVariantWithSelector() const noexcept
354 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_VARIANT_WITH_SELECTOR_FIELD);
357 bool isVariantWithIntegerSelector() const noexcept
359 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD);
362 bool isVariantWithUnsignedIntegerSelector() const noexcept
364 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD);
367 bool isVariantWithSignedIntegerSelector() const noexcept
369 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD);
372 bool isBlob() const noexcept
374 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_BLOB);
377 bool isStaticBlob() const noexcept
379 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_STATIC_BLOB);
382 bool isDynamicBlob() const noexcept
384 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_DYNAMIC_BLOB);
387 bool isDynamicBlobWithoutLength() const noexcept
389 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_DYNAMIC_BLOB_WITHOUT_LENGTH_FIELD);
392 bool isDynamicBlobWithLength() const noexcept
394 return this->_libTypeIs(BT_FIELD_CLASS_TYPE_DYNAMIC_BLOB_WITH_LENGTH_FIELD);
397 template <typename FieldClassT>
398 FieldClassT as() const noexcept
400 return FieldClassT {this->libObjPtr()};
403 CommonBitArrayFieldClass<LibObjT> asBitArray() const noexcept;
404 CommonIntegerFieldClass<LibObjT> asInteger() const noexcept;
405 CommonBaseEnumerationFieldClass<LibObjT> asEnumeration() const noexcept;
406 CommonEnumerationFieldClass<LibObjT, ConstEnumerationFieldClassMapping<
407 const bt_field_class_enumeration_unsigned_mapping>>
408 asUnsignedEnumeration() const noexcept;
410 CommonEnumerationFieldClass<
411 LibObjT, ConstEnumerationFieldClassMapping<const bt_field_class_enumeration_signed_mapping>>
412 asSignedEnumeration() const noexcept;
414 CommonStructureFieldClass<LibObjT> asStructure() const noexcept;
415 CommonArrayFieldClass<LibObjT> asArray() const noexcept;
416 CommonStaticArrayFieldClass<LibObjT> asStaticArray() const noexcept;
417 CommonDynamicArrayWithLengthFieldClass<LibObjT> asDynamicArrayWithLength() const noexcept;
418 CommonBlobFieldClass<LibObjT> asBlob() const noexcept;
419 CommonStaticBlobFieldClass<LibObjT> asStaticBlob() const noexcept;
420 CommonDynamicBlobWithLengthFieldClass<LibObjT> asDynamicBlobWithLength() const noexcept;
421 CommonOptionFieldClass<LibObjT> asOption() const noexcept;
422 CommonOptionWithSelectorFieldClass<LibObjT> asOptionWithSelector() const noexcept;
423 CommonOptionWithBoolSelectorFieldClass<LibObjT> asOptionWithBoolSelector() const noexcept;
425 CommonOptionWithIntegerSelectorFieldClass<LibObjT, ConstUnsignedIntegerRangeSet>
426 asOptionWithUnsignedIntegerSelector() const noexcept;
428 CommonOptionWithIntegerSelectorFieldClass<LibObjT, ConstSignedIntegerRangeSet>
429 asOptionWithSignedIntegerSelector() const noexcept;
431 CommonVariantFieldClass<LibObjT> asVariant() const noexcept;
432 CommonVariantWithoutSelectorFieldClass<LibObjT> asVariantWithoutSelector() const noexcept;
433 CommonVariantWithSelectorFieldClass<LibObjT> asVariantWithSelector() const noexcept;
435 CommonVariantWithIntegerSelectorFieldClass<
436 LibObjT, ConstVariantWithIntegerSelectorFieldClassOption<
437 const bt_field_class_variant_with_selector_field_integer_unsigned_option>>
438 asVariantWithUnsignedIntegerSelector() const noexcept;
440 CommonVariantWithIntegerSelectorFieldClass<
441 LibObjT, ConstVariantWithIntegerSelectorFieldClassOption<
442 const bt_field_class_variant_with_selector_field_integer_signed_option>>
443 asVariantWithSignedIntegerSelector() const noexcept;
445 template <typename LibValT>
446 CommonFieldClass userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
448 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstFieldClass`.");
450 bt_field_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
454 UserAttributes userAttributes() const noexcept
456 return UserAttributes {
457 internal::CommonFieldClassSpec<LibObjT>::userAttributes(this->libObjPtr())};
460 Shared shared() const noexcept
462 return Shared::createWithRef(*this);
466 bool _libTypeIs(const bt_field_class_type type) const noexcept
468 return bt_field_class_type_is(bt_field_class_get_type(this->libObjPtr()), type);
472 using FieldClass = CommonFieldClass<bt_field_class>;
473 using ConstFieldClass = CommonFieldClass<const bt_field_class>;
477 struct FieldClassTypeDescr
479 using Const = ConstFieldClass;
480 using NonConst = FieldClass;
484 struct TypeDescr<FieldClass> : public FieldClassTypeDescr
489 struct TypeDescr<ConstFieldClass> : public FieldClassTypeDescr
493 } /* namespace internal */
495 class ConstBitArrayFieldClassFlag final : public BorrowedObject<const bt_field_class_bit_array_flag>
498 using RangeSet = ConstUnsignedIntegerRangeSet;
500 explicit ConstBitArrayFieldClassFlag(const LibObjPtr libObjPtr) noexcept :
501 _ThisBorrowedObject {libObjPtr}
505 RangeSet ranges() const noexcept
508 bt_field_class_bit_array_flag_borrow_index_ranges_const(this->libObjPtr())};
511 bt2c::CStringView label() const noexcept
513 return bt_field_class_bit_array_flag_get_label(this->libObjPtr());
517 template <typename LibObjT>
518 class CommonBitArrayFieldClass final : public CommonFieldClass<LibObjT>
521 using typename CommonFieldClass<LibObjT>::_ThisCommonFieldClass;
524 using typename CommonFieldClass<LibObjT>::LibObjPtr;
525 using Shared = SharedFieldClass<CommonBitArrayFieldClass<LibObjT>, LibObjT>;
526 using Iterator = BorrowedObjectIterator<CommonBitArrayFieldClass>;
528 explicit CommonBitArrayFieldClass(const LibObjPtr libObjPtr) noexcept :
529 _ThisCommonFieldClass {libObjPtr}
531 BT_ASSERT_DBG(this->isBitArray());
534 template <typename OtherLibObjT>
535 CommonBitArrayFieldClass(const CommonBitArrayFieldClass<OtherLibObjT> fc) noexcept :
536 _ThisCommonFieldClass {fc}
540 template <typename OtherLibObjT>
541 CommonBitArrayFieldClass<LibObjT>
542 operator=(const CommonBitArrayFieldClass<OtherLibObjT> fc) noexcept
544 _ThisCommonFieldClass::operator=(fc);
548 CommonBitArrayFieldClass<const bt_field_class> asConst() const noexcept
550 return CommonBitArrayFieldClass<const bt_field_class> {*this};
553 std::uint64_t length() const noexcept
555 return bt_field_class_bit_array_get_length(this->libObjPtr());
558 ConstBitArrayFieldClassFlag operator[](const std::uint64_t index) const noexcept
560 return ConstBitArrayFieldClassFlag {
561 bt_field_class_bit_array_borrow_flag_by_index_const(this->libObjPtr(), index)};
564 OptionalBorrowedObject<ConstBitArrayFieldClassFlag>
565 operator[](const bt2c::CStringView label) const noexcept
567 return bt_field_class_bit_array_borrow_flag_by_label_const(this->libObjPtr(), label);
570 CommonBitArrayFieldClass addFlag(const bt2c::CStringView label,
571 const ConstBitArrayFieldClassFlag::RangeSet ranges) const
573 static_assert(!std::is_const<LibObjT>::value,
574 "Not available with `bt2::ConstBitArrayFieldClass`.");
576 if (bt_field_class_bit_array_add_flag(this->libObjPtr(), label, ranges.libObjPtr()) ==
577 BT_FIELD_CLASS_BIT_ARRAY_ADD_FLAG_STATUS_MEMORY_ERROR) {
578 throw MemoryError {};
584 Iterator begin() const noexcept
586 return Iterator {*this, 0};
589 Iterator end() const noexcept
591 return Iterator {*this, this->length()};
594 Shared shared() const noexcept
596 return Shared::createWithRef(*this);
600 using BitArrayFieldClass = CommonBitArrayFieldClass<bt_field_class>;
601 using ConstBitArrayFieldClass = CommonBitArrayFieldClass<const bt_field_class>;
605 struct BitArrayFieldClassTypeDescr
607 using Const = ConstBitArrayFieldClass;
608 using NonConst = BitArrayFieldClass;
612 struct TypeDescr<BitArrayFieldClass> : public BitArrayFieldClassTypeDescr
617 struct TypeDescr<ConstBitArrayFieldClass> : public BitArrayFieldClassTypeDescr
621 } /* namespace internal */
623 enum class DisplayBase
625 Binary = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY,
626 Octal = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL,
627 Decimal = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL,
628 Hexadecimal = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL,
631 template <typename LibObjT>
632 class CommonIntegerFieldClass : public CommonFieldClass<LibObjT>
635 using typename CommonFieldClass<LibObjT>::_ThisCommonFieldClass;
638 using _ThisCommonIntegerFieldClass = CommonIntegerFieldClass<LibObjT>;
641 using typename CommonFieldClass<LibObjT>::LibObjPtr;
642 using Shared = SharedFieldClass<CommonIntegerFieldClass<LibObjT>, LibObjT>;
644 explicit CommonIntegerFieldClass(const LibObjPtr libObjPtr) noexcept :
645 _ThisCommonFieldClass {libObjPtr}
647 BT_ASSERT_DBG(this->isInteger());
650 template <typename OtherLibObjT>
651 CommonIntegerFieldClass(const CommonIntegerFieldClass<OtherLibObjT> fc) noexcept :
652 _ThisCommonFieldClass {fc}
656 template <typename OtherLibObjT>
657 CommonIntegerFieldClass operator=(const CommonIntegerFieldClass<OtherLibObjT> fc) noexcept
659 _ThisCommonFieldClass::operator=(fc);
663 CommonIntegerFieldClass<const bt_field_class> asConst() const noexcept
665 return CommonIntegerFieldClass<const bt_field_class> {*this};
668 CommonIntegerFieldClass fieldValueRange(const std::uint64_t n) const noexcept
670 static_assert(!std::is_const<LibObjT>::value,
671 "Not available with `bt2::ConstIntegerFieldClass`.");
673 bt_field_class_integer_set_field_value_range(this->libObjPtr(), n);
677 std::uint64_t fieldValueRange() const noexcept
679 return bt_field_class_integer_get_field_value_range(this->libObjPtr());
682 CommonIntegerFieldClass preferredDisplayBase(const DisplayBase base) const noexcept
684 static_assert(!std::is_const<LibObjT>::value,
685 "Not available with `bt2::ConstIntegerFieldClass`.");
687 bt_field_class_integer_set_preferred_display_base(
688 this->libObjPtr(), static_cast<bt_field_class_integer_preferred_display_base>(base));
692 DisplayBase preferredDisplayBase() const noexcept
694 return static_cast<DisplayBase>(
695 bt_field_class_integer_get_preferred_display_base(this->libObjPtr()));
698 Shared shared() const noexcept
700 return Shared::createWithRef(*this);
704 using IntegerFieldClass = CommonIntegerFieldClass<bt_field_class>;
705 using ConstIntegerFieldClass = CommonIntegerFieldClass<const bt_field_class>;
709 struct IntegerFieldClassTypeDescr
711 using Const = ConstIntegerFieldClass;
712 using NonConst = IntegerFieldClass;
716 struct TypeDescr<IntegerFieldClass> : public IntegerFieldClassTypeDescr
721 struct TypeDescr<ConstIntegerFieldClass> : public IntegerFieldClassTypeDescr
725 template <typename LibObjT>
726 struct ConstEnumerationFieldClassMappingSpec;
728 /* Functions specific to unsigned enumeration field class mappings */
730 struct ConstEnumerationFieldClassMappingSpec<const bt_field_class_enumeration_unsigned_mapping>
733 static const bt_integer_range_set_unsigned *
734 ranges(const bt_field_class_enumeration_unsigned_mapping * const libObjPtr) noexcept
736 return bt_field_class_enumeration_unsigned_mapping_borrow_ranges_const(libObjPtr);
740 label(const bt_field_class_enumeration_unsigned_mapping * const libObjPtr) noexcept
742 return bt_field_class_enumeration_mapping_get_label(
743 bt_field_class_enumeration_unsigned_mapping_as_mapping_const(libObjPtr));
747 /* Functions specific to signed enumeration field class mappings */
749 struct ConstEnumerationFieldClassMappingSpec<const bt_field_class_enumeration_signed_mapping> final
751 static const bt_integer_range_set_signed *
752 ranges(const bt_field_class_enumeration_signed_mapping * const libObjPtr) noexcept
754 return bt_field_class_enumeration_signed_mapping_borrow_ranges_const(libObjPtr);
758 label(const bt_field_class_enumeration_signed_mapping * const libObjPtr) noexcept
760 return bt_field_class_enumeration_mapping_get_label(
761 bt_field_class_enumeration_signed_mapping_as_mapping_const(libObjPtr));
765 } /* namespace internal */
767 template <typename LibObjT>
768 class ConstEnumerationFieldClassMapping final : public BorrowedObject<LibObjT>
771 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
774 using typename BorrowedObject<LibObjT>::LibObjPtr;
776 using RangeSet = typename std::conditional<
777 std::is_same<LibObjT, const bt_field_class_enumeration_unsigned_mapping>::value,
778 ConstUnsignedIntegerRangeSet, ConstSignedIntegerRangeSet>::type;
780 explicit ConstEnumerationFieldClassMapping(const LibObjPtr libObjPtr) noexcept :
781 _ThisBorrowedObject {libObjPtr}
785 ConstEnumerationFieldClassMapping(const ConstEnumerationFieldClassMapping& mapping) noexcept :
786 _ThisBorrowedObject {mapping}
790 ConstEnumerationFieldClassMapping
791 operator=(const ConstEnumerationFieldClassMapping& mapping) noexcept
793 _ThisBorrowedObject::operator=(mapping);
797 RangeSet ranges() const noexcept
800 internal::ConstEnumerationFieldClassMappingSpec<LibObjT>::ranges(this->libObjPtr())};
803 bt2c::CStringView label() const noexcept
805 return internal::ConstEnumerationFieldClassMappingSpec<LibObjT>::label(this->libObjPtr());
809 using ConstUnsignedEnumerationFieldClassMapping =
810 ConstEnumerationFieldClassMapping<const bt_field_class_enumeration_unsigned_mapping>;
812 using ConstSignedEnumerationFieldClassMapping =
813 ConstEnumerationFieldClassMapping<const bt_field_class_enumeration_signed_mapping>;
817 template <typename MappingT>
818 struct CommonEnumerationFieldClassSpec;
820 /* Functions specific to unsigned enumeration field classes */
822 struct CommonEnumerationFieldClassSpec<ConstUnsignedEnumerationFieldClassMapping> final
824 static const bt_field_class_enumeration_unsigned_mapping *
825 mappingByIndex(const bt_field_class * const libObjPtr, const std::uint64_t index) noexcept
827 return bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const(libObjPtr, index);
830 static const bt_field_class_enumeration_unsigned_mapping *
831 mappingByLabel(const bt_field_class * const libObjPtr, const char * const label) noexcept
833 return bt_field_class_enumeration_unsigned_borrow_mapping_by_label_const(libObjPtr, label);
836 static bt_field_class_enumeration_add_mapping_status
837 addMapping(bt_field_class * const libObjPtr, const char * const label,
838 const bt_integer_range_set_unsigned * const libRanges) noexcept
840 return bt_field_class_enumeration_unsigned_add_mapping(libObjPtr, label, libRanges);
844 /* Functions specific to signed enumeration field classes */
846 struct CommonEnumerationFieldClassSpec<ConstSignedEnumerationFieldClassMapping> final
848 static const bt_field_class_enumeration_signed_mapping *
849 mappingByIndex(const bt_field_class * const libObjPtr, const std::uint64_t index) noexcept
851 return bt_field_class_enumeration_signed_borrow_mapping_by_index_const(libObjPtr, index);
854 static const bt_field_class_enumeration_signed_mapping *
855 mappingByLabel(const bt_field_class * const libObjPtr, const char * const label) noexcept
857 return bt_field_class_enumeration_signed_borrow_mapping_by_label_const(libObjPtr, label);
860 static bt_field_class_enumeration_add_mapping_status
861 addMapping(bt_field_class * const libObjPtr, const char * const label,
862 const bt_integer_range_set_signed * const libRanges) noexcept
864 return bt_field_class_enumeration_signed_add_mapping(libObjPtr, label, libRanges);
868 } /* namespace internal */
870 template <typename LibObjT>
871 class CommonBaseEnumerationFieldClass : public CommonIntegerFieldClass<LibObjT>
874 using typename CommonIntegerFieldClass<LibObjT>::_ThisCommonIntegerFieldClass;
877 using _ThisCommonBaseEnumerationFieldClass = CommonBaseEnumerationFieldClass<LibObjT>;
880 using typename CommonFieldClass<LibObjT>::LibObjPtr;
881 using Shared = SharedFieldClass<_ThisCommonBaseEnumerationFieldClass, LibObjT>;
883 explicit CommonBaseEnumerationFieldClass(const LibObjPtr libObjPtr) noexcept :
884 _ThisCommonIntegerFieldClass {libObjPtr}
886 BT_ASSERT_DBG(this->isEnumeration());
889 template <typename OtherLibObjT>
890 CommonBaseEnumerationFieldClass(const CommonBaseEnumerationFieldClass<OtherLibObjT> fc) noexcept
892 _ThisCommonIntegerFieldClass {fc}
896 template <typename OtherLibObjT>
897 CommonBaseEnumerationFieldClass
898 operator=(const CommonBaseEnumerationFieldClass<OtherLibObjT> fc) noexcept
900 _ThisCommonIntegerFieldClass::operator=(fc);
904 CommonBaseEnumerationFieldClass<const bt_field_class> asConst() const noexcept
906 return CommonBaseEnumerationFieldClass<const bt_field_class> {*this};
909 std::uint64_t length() const noexcept
911 return bt_field_class_enumeration_get_mapping_count(this->libObjPtr());
914 Shared shared() const noexcept
916 return Shared::createWithRef(*this);
920 template <typename LibObjT, typename MappingT>
921 class CommonEnumerationFieldClass final : public CommonBaseEnumerationFieldClass<LibObjT>
924 using typename CommonBaseEnumerationFieldClass<LibObjT>::_ThisCommonBaseEnumerationFieldClass;
927 using typename CommonFieldClass<LibObjT>::LibObjPtr;
928 using Shared = SharedFieldClass<CommonEnumerationFieldClass, LibObjT>;
929 using Iterator = BorrowedObjectIterator<CommonEnumerationFieldClass>;
930 using Mapping = MappingT;
932 explicit CommonEnumerationFieldClass(const LibObjPtr libObjPtr) noexcept :
933 _ThisCommonBaseEnumerationFieldClass {libObjPtr}
935 BT_ASSERT_DBG(this->isEnumeration());
938 template <typename OtherLibObjT>
939 CommonEnumerationFieldClass(
940 const CommonEnumerationFieldClass<OtherLibObjT, MappingT> fc) noexcept :
941 CommonEnumerationFieldClass {fc}
945 template <typename OtherLibObjT>
946 CommonEnumerationFieldClass
947 operator=(const CommonEnumerationFieldClass<OtherLibObjT, MappingT> fc) noexcept
949 CommonEnumerationFieldClass::operator=(fc);
953 Mapping operator[](const std::uint64_t index) const noexcept
955 return Mapping {internal::CommonEnumerationFieldClassSpec<MappingT>::mappingByIndex(
956 this->libObjPtr(), index)};
959 OptionalBorrowedObject<Mapping> operator[](const bt2c::CStringView label) const noexcept
961 return internal::CommonEnumerationFieldClassSpec<MappingT>::mappingByLabel(
962 this->libObjPtr(), label);
965 CommonEnumerationFieldClass addMapping(const bt2c::CStringView label,
966 const typename Mapping::RangeSet ranges) const
968 static_assert(!std::is_const<LibObjT>::value,
969 "Not available with `bt2::Const*EnumerationFieldClass`.");
971 const auto status = internal::CommonEnumerationFieldClassSpec<MappingT>::addMapping(
972 this->libObjPtr(), label, ranges.libObjPtr());
974 if (status == BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_MEMORY_ERROR) {
975 throw MemoryError {};
981 Iterator begin() const noexcept
983 return Iterator {*this, 0};
986 Iterator end() const noexcept
988 return Iterator {*this, this->length()};
991 Shared shared() const noexcept
993 return Shared::createWithRef(*this);
997 using EnumerationFieldClass = CommonBaseEnumerationFieldClass<bt_field_class>;
998 using ConstEnumerationFieldClass = CommonBaseEnumerationFieldClass<const bt_field_class>;
1000 using UnsignedEnumerationFieldClass =
1001 CommonEnumerationFieldClass<bt_field_class, ConstUnsignedEnumerationFieldClassMapping>;
1003 using ConstUnsignedEnumerationFieldClass =
1004 CommonEnumerationFieldClass<const bt_field_class, ConstUnsignedEnumerationFieldClassMapping>;
1006 using SignedEnumerationFieldClass =
1007 CommonEnumerationFieldClass<bt_field_class, ConstSignedEnumerationFieldClassMapping>;
1009 using ConstSignedEnumerationFieldClass =
1010 CommonEnumerationFieldClass<const bt_field_class, ConstSignedEnumerationFieldClassMapping>;
1012 namespace internal {
1014 struct UnsignedEnumerationFieldClassTypeDescr
1016 using Const = ConstUnsignedEnumerationFieldClass;
1017 using NonConst = UnsignedEnumerationFieldClass;
1021 struct TypeDescr<UnsignedEnumerationFieldClass> : public UnsignedEnumerationFieldClassTypeDescr
1026 struct TypeDescr<ConstUnsignedEnumerationFieldClass> : public UnsignedEnumerationFieldClassTypeDescr
1030 struct SignedEnumerationFieldClassTypeDescr
1032 using Const = ConstSignedEnumerationFieldClass;
1033 using NonConst = SignedEnumerationFieldClass;
1037 struct TypeDescr<SignedEnumerationFieldClass> : public SignedEnumerationFieldClassTypeDescr
1042 struct TypeDescr<ConstSignedEnumerationFieldClass> : public SignedEnumerationFieldClassTypeDescr
1046 template <typename LibObjT>
1047 struct CommonStructureFieldClassMemberSpec;
1049 /* Functions specific to mutable structure field class members */
1051 struct CommonStructureFieldClassMemberSpec<bt_field_class_structure_member> final
1053 static bt_field_class *fieldClass(bt_field_class_structure_member * const libObjPtr) noexcept
1055 return bt_field_class_structure_member_borrow_field_class(libObjPtr);
1058 static bt_value *userAttributes(bt_field_class_structure_member * const libObjPtr) noexcept
1060 return bt_field_class_structure_member_borrow_user_attributes(libObjPtr);
1064 /* Functions specific to constant structure field class members */
1066 struct CommonStructureFieldClassMemberSpec<const bt_field_class_structure_member> final
1068 static const bt_field_class *
1069 fieldClass(const bt_field_class_structure_member * const libObjPtr) noexcept
1071 return bt_field_class_structure_member_borrow_field_class_const(libObjPtr);
1074 static const bt_value *
1075 userAttributes(const bt_field_class_structure_member * const libObjPtr) noexcept
1077 return bt_field_class_structure_member_borrow_user_attributes_const(libObjPtr);
1081 } /* namespace internal */
1083 template <typename LibObjT>
1084 class CommonStructureFieldClassMember final : public BorrowedObject<LibObjT>
1087 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
1088 using _FieldClass = internal::DepFc<LibObjT>;
1091 using typename BorrowedObject<LibObjT>::LibObjPtr;
1092 using UserAttributes = internal::DepUserAttrs<LibObjT>;
1094 explicit CommonStructureFieldClassMember(const LibObjPtr libObjPtr) noexcept :
1095 _ThisBorrowedObject {libObjPtr}
1099 template <typename OtherLibObjT>
1100 CommonStructureFieldClassMember(const CommonStructureFieldClassMember<OtherLibObjT> fc) noexcept
1102 _ThisBorrowedObject {fc}
1106 template <typename OtherLibObjT>
1107 CommonStructureFieldClassMember<LibObjT>
1108 operator=(const CommonStructureFieldClassMember<OtherLibObjT> fc) noexcept
1110 _ThisBorrowedObject::operator=(fc);
1114 CommonStructureFieldClassMember<const bt_field_class_structure_member> asConst() const noexcept
1116 return CommonStructureFieldClassMember<const bt_field_class_structure_member> {*this};
1119 bt2c::CStringView name() const noexcept
1121 return bt_field_class_structure_member_get_name(this->libObjPtr());
1124 _FieldClass fieldClass() const noexcept
1126 return _FieldClass {
1127 internal::CommonStructureFieldClassMemberSpec<LibObjT>::fieldClass(this->libObjPtr())};
1130 template <typename LibValT>
1131 CommonStructureFieldClassMember
1132 userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
1134 static_assert(!std::is_const<LibObjT>::value,
1135 "Not available with `bt2::ConstStructureFieldClassMember`.");
1137 bt_field_class_structure_member_set_user_attributes(this->libObjPtr(),
1138 userAttrs.libObjPtr());
1142 UserAttributes userAttributes() const noexcept
1144 return UserAttributes {
1145 internal::CommonStructureFieldClassMemberSpec<LibObjT>::userAttributes(
1146 this->libObjPtr())};
1150 using StructureFieldClassMember = CommonStructureFieldClassMember<bt_field_class_structure_member>;
1152 using ConstStructureFieldClassMember =
1153 CommonStructureFieldClassMember<const bt_field_class_structure_member>;
1155 namespace internal {
1157 struct StructureFieldClassMemberTypeDescr
1159 using Const = ConstStructureFieldClassMember;
1160 using NonConst = StructureFieldClassMember;
1164 struct TypeDescr<StructureFieldClassMember> : public StructureFieldClassMemberTypeDescr
1169 struct TypeDescr<ConstStructureFieldClassMember> : public StructureFieldClassMemberTypeDescr
1173 template <typename LibObjT>
1174 struct CommonStructureFieldClassSpec;
1176 /* Functions specific to mutable structure field classes */
1178 struct CommonStructureFieldClassSpec<bt_field_class> final
1180 static bt_field_class_structure_member *memberByIndex(bt_field_class * const libObjPtr,
1181 const std::uint64_t index) noexcept
1183 return bt_field_class_structure_borrow_member_by_index(libObjPtr, index);
1186 static bt_field_class_structure_member *memberByName(bt_field_class * const libObjPtr,
1187 const char * const name) noexcept
1189 return bt_field_class_structure_borrow_member_by_name(libObjPtr, name);
1193 /* Functions specific to constant structure field classes */
1195 struct CommonStructureFieldClassSpec<const bt_field_class> final
1197 static const bt_field_class_structure_member *
1198 memberByIndex(const bt_field_class * const libObjPtr, const std::uint64_t index) noexcept
1200 return bt_field_class_structure_borrow_member_by_index_const(libObjPtr, index);
1203 static const bt_field_class_structure_member *
1204 memberByName(const bt_field_class * const libObjPtr, const char * const name) noexcept
1206 return bt_field_class_structure_borrow_member_by_name_const(libObjPtr, name);
1210 } /* namespace internal */
1212 template <typename LibObjT>
1213 class CommonStructureFieldClass final : public CommonFieldClass<LibObjT>
1216 using typename CommonFieldClass<LibObjT>::_ThisCommonFieldClass;
1219 using typename CommonFieldClass<LibObjT>::LibObjPtr;
1220 using Shared = SharedFieldClass<CommonStructureFieldClass<LibObjT>, LibObjT>;
1221 using Iterator = BorrowedObjectIterator<CommonStructureFieldClass<LibObjT>>;
1224 internal::DepType<LibObjT, StructureFieldClassMember, ConstStructureFieldClassMember>;
1226 explicit CommonStructureFieldClass(const LibObjPtr libObjPtr) noexcept :
1227 _ThisCommonFieldClass {libObjPtr}
1229 BT_ASSERT_DBG(this->isStructure());
1232 template <typename OtherLibObjT>
1233 CommonStructureFieldClass(const CommonStructureFieldClass<OtherLibObjT> fc) noexcept :
1234 _ThisCommonFieldClass {fc}
1238 template <typename OtherLibObjT>
1239 CommonStructureFieldClass operator=(const CommonStructureFieldClass<OtherLibObjT> fc) noexcept
1241 _ThisCommonFieldClass::operator=(fc);
1245 CommonStructureFieldClass<const bt_field_class> asConst() const noexcept
1247 return CommonStructureFieldClass<const bt_field_class> {*this};
1250 CommonStructureFieldClass appendMember(const bt2c::CStringView name, const FieldClass fc) const
1252 static_assert(!std::is_const<LibObjT>::value,
1253 "Not available with `bt2::ConstStructureFieldClass`.");
1256 bt_field_class_structure_append_member(this->libObjPtr(), name, fc.libObjPtr());
1258 if (status == BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_MEMORY_ERROR) {
1259 throw MemoryError {};
1265 std::uint64_t length() const noexcept
1267 return bt_field_class_structure_get_member_count(this->libObjPtr());
1270 Iterator begin() const noexcept
1272 return Iterator {*this, 0};
1275 Iterator end() const noexcept
1277 return Iterator {*this, this->length()};
1280 Member operator[](const std::uint64_t index) const noexcept
1282 return Member {internal::CommonStructureFieldClassSpec<LibObjT>::memberByIndex(
1283 this->libObjPtr(), index)};
1286 OptionalBorrowedObject<Member> operator[](const bt2c::CStringView name) const noexcept
1288 return internal::CommonStructureFieldClassSpec<LibObjT>::memberByName(this->libObjPtr(),
1292 Shared shared() const noexcept
1294 return Shared::createWithRef(*this);
1298 using StructureFieldClass = CommonStructureFieldClass<bt_field_class>;
1299 using ConstStructureFieldClass = CommonStructureFieldClass<const bt_field_class>;
1301 namespace internal {
1303 struct StructureFieldClassTypeDescr
1305 using Const = ConstStructureFieldClass;
1306 using NonConst = StructureFieldClass;
1310 struct TypeDescr<StructureFieldClass> : public StructureFieldClassTypeDescr
1315 struct TypeDescr<ConstStructureFieldClass> : public StructureFieldClassTypeDescr
1319 template <typename LibObjT>
1320 struct CommonArrayFieldClassSpec;
1322 /* Functions specific to mutable array field classes */
1324 struct CommonArrayFieldClassSpec<bt_field_class> final
1326 static bt_field_class *elementFieldClass(bt_field_class * const libObjPtr) noexcept
1328 return bt_field_class_array_borrow_element_field_class(libObjPtr);
1332 /* Functions specific to constant array field classes */
1334 struct CommonArrayFieldClassSpec<const bt_field_class> final
1336 static const bt_field_class *elementFieldClass(const bt_field_class * const libObjPtr) noexcept
1338 return bt_field_class_array_borrow_element_field_class_const(libObjPtr);
1342 } /* namespace internal */
1344 template <typename LibObjT>
1345 class CommonArrayFieldClass : public CommonFieldClass<LibObjT>
1348 using typename CommonFieldClass<LibObjT>::_ThisCommonFieldClass;
1349 using _FieldClass = internal::DepFc<LibObjT>;
1352 using _ThisCommonArrayFieldClass = CommonArrayFieldClass<LibObjT>;
1355 using typename CommonFieldClass<LibObjT>::LibObjPtr;
1356 using Shared = SharedFieldClass<CommonArrayFieldClass<LibObjT>, LibObjT>;
1358 explicit CommonArrayFieldClass(const LibObjPtr libObjPtr) noexcept :
1359 _ThisCommonFieldClass {libObjPtr}
1361 BT_ASSERT_DBG(this->isArray());
1364 template <typename OtherLibObjT>
1365 CommonArrayFieldClass(const CommonArrayFieldClass<OtherLibObjT> fc) noexcept :
1366 _ThisCommonFieldClass {fc}
1370 template <typename OtherLibObjT>
1371 CommonArrayFieldClass operator=(const CommonArrayFieldClass<OtherLibObjT> fc) noexcept
1373 _ThisCommonFieldClass::operator=(fc);
1377 CommonArrayFieldClass<const bt_field_class> asConst() const noexcept
1379 return CommonArrayFieldClass<const bt_field_class> {*this};
1382 _FieldClass elementFieldClass() const noexcept
1384 return _FieldClass {
1385 internal::CommonArrayFieldClassSpec<LibObjT>::elementFieldClass(this->libObjPtr())};
1388 Shared shared() const noexcept
1390 return Shared::createWithRef(*this);
1394 using ArrayFieldClass = CommonArrayFieldClass<bt_field_class>;
1395 using ConstArrayFieldClass = CommonArrayFieldClass<const bt_field_class>;
1397 namespace internal {
1399 struct ArrayFieldClassTypeDescr
1401 using Const = ConstArrayFieldClass;
1402 using NonConst = ArrayFieldClass;
1406 struct TypeDescr<ArrayFieldClass> : public ArrayFieldClassTypeDescr
1411 struct TypeDescr<ConstArrayFieldClass> : public ArrayFieldClassTypeDescr
1415 } /* namespace internal */
1417 template <typename LibObjT>
1418 class CommonStaticArrayFieldClass final : public CommonArrayFieldClass<LibObjT>
1421 using typename CommonArrayFieldClass<LibObjT>::_ThisCommonArrayFieldClass;
1424 using typename CommonFieldClass<LibObjT>::LibObjPtr;
1425 using Shared = SharedFieldClass<CommonStaticArrayFieldClass<LibObjT>, LibObjT>;
1427 explicit CommonStaticArrayFieldClass(const LibObjPtr libObjPtr) noexcept :
1428 _ThisCommonArrayFieldClass {libObjPtr}
1430 BT_ASSERT_DBG(this->isStaticArray());
1433 template <typename OtherLibObjT>
1434 CommonStaticArrayFieldClass(const CommonStaticArrayFieldClass<OtherLibObjT> fc) noexcept :
1435 _ThisCommonArrayFieldClass {fc}
1439 template <typename OtherLibObjT>
1440 CommonStaticArrayFieldClass
1441 operator=(const CommonStaticArrayFieldClass<OtherLibObjT> fc) noexcept
1443 _ThisCommonArrayFieldClass::operator=(fc);
1447 CommonStaticArrayFieldClass<const bt_field_class> asConst() const noexcept
1449 return CommonStaticArrayFieldClass<const bt_field_class> {*this};
1452 std::uint64_t length() const noexcept
1454 return bt_field_class_array_static_get_length(this->libObjPtr());
1457 Shared shared() const noexcept
1459 return Shared::createWithRef(*this);
1463 using StaticArrayFieldClass = CommonStaticArrayFieldClass<bt_field_class>;
1464 using ConstStaticArrayFieldClass = CommonStaticArrayFieldClass<const bt_field_class>;
1466 namespace internal {
1468 struct StaticArrayFieldClassTypeDescr
1470 using Const = ConstStaticArrayFieldClass;
1471 using NonConst = StaticArrayFieldClass;
1475 struct TypeDescr<StaticArrayFieldClass> : public StaticArrayFieldClassTypeDescr
1480 struct TypeDescr<ConstStaticArrayFieldClass> : public StaticArrayFieldClassTypeDescr
1484 } /* namespace internal */
1486 template <typename LibObjT>
1487 class CommonDynamicArrayWithLengthFieldClass final : public CommonArrayFieldClass<LibObjT>
1490 using typename CommonArrayFieldClass<LibObjT>::_ThisCommonArrayFieldClass;
1493 using typename CommonFieldClass<LibObjT>::LibObjPtr;
1494 using Shared = SharedFieldClass<CommonDynamicArrayWithLengthFieldClass<LibObjT>, LibObjT>;
1496 explicit CommonDynamicArrayWithLengthFieldClass(const LibObjPtr libObjPtr) noexcept :
1497 _ThisCommonArrayFieldClass {libObjPtr}
1499 BT_ASSERT_DBG(this->isDynamicArrayWithLength());
1502 template <typename OtherLibObjT>
1503 CommonDynamicArrayWithLengthFieldClass(
1504 const CommonDynamicArrayWithLengthFieldClass<OtherLibObjT> fc) noexcept :
1505 _ThisCommonArrayFieldClass {fc}
1509 template <typename OtherLibObjT>
1510 CommonDynamicArrayWithLengthFieldClass
1511 operator=(const CommonDynamicArrayWithLengthFieldClass<OtherLibObjT> fc) noexcept
1513 _ThisCommonArrayFieldClass::operator=(fc);
1517 CommonDynamicArrayWithLengthFieldClass<const bt_field_class> asConst() const noexcept
1519 return CommonDynamicArrayWithLengthFieldClass<const bt_field_class> {*this};
1522 ConstFieldPath lengthFieldPath() const noexcept
1524 return ConstFieldPath {
1525 bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
1526 this->libObjPtr())};
1529 ConstFieldLocation lengthFieldLocation() const noexcept
1531 return ConstFieldLocation {
1532 bt_field_class_array_dynamic_with_length_field_borrow_length_field_location_const(
1533 this->libObjPtr())};
1536 Shared shared() const noexcept
1538 return Shared::createWithRef(*this);
1542 using DynamicArrayWithLengthFieldClass = CommonDynamicArrayWithLengthFieldClass<bt_field_class>;
1544 using ConstDynamicArrayWithLengthFieldClass =
1545 CommonDynamicArrayWithLengthFieldClass<const bt_field_class>;
1547 namespace internal {
1549 struct DynamicArrayWithLengthFieldClassTypeDescr
1551 using Const = ConstDynamicArrayWithLengthFieldClass;
1552 using NonConst = DynamicArrayWithLengthFieldClass;
1556 struct TypeDescr<DynamicArrayWithLengthFieldClass> :
1557 public DynamicArrayWithLengthFieldClassTypeDescr
1562 struct TypeDescr<ConstDynamicArrayWithLengthFieldClass> :
1563 public DynamicArrayWithLengthFieldClassTypeDescr
1567 } /* namespace internal */
1569 template <typename LibObjT>
1570 class CommonBlobFieldClass : public CommonFieldClass<LibObjT>
1573 using typename CommonFieldClass<LibObjT>::_ThisCommonFieldClass;
1576 using _ThisCommonBlobFieldClass = CommonBlobFieldClass<LibObjT>;
1579 using Shared = SharedFieldClass<CommonBlobFieldClass<LibObjT>, LibObjT>;
1580 using typename CommonFieldClass<LibObjT>::LibObjPtr;
1582 explicit CommonBlobFieldClass(const LibObjPtr libObjPtr) noexcept :
1583 _ThisCommonFieldClass {libObjPtr}
1585 BT_ASSERT_DBG(this->isBlob());
1588 template <typename OtherLibObjT>
1589 CommonBlobFieldClass(const CommonBlobFieldClass<OtherLibObjT> fc) noexcept :
1590 _ThisCommonFieldClass {fc}
1594 template <typename OtherLibObjT>
1595 CommonBlobFieldClass operator=(const CommonBlobFieldClass<OtherLibObjT> fc) noexcept
1597 _ThisCommonFieldClass::operator=(fc);
1601 CommonBlobFieldClass<const bt_field_class> asConst() const noexcept
1603 return CommonBlobFieldClass<const bt_field_class> {*this};
1606 bt2c::CStringView mediaType() const noexcept
1608 return bt_field_class_blob_get_media_type(this->libObjPtr());
1611 CommonBlobFieldClass mediaType(const bt2c::CStringView mediaType) const
1613 static_assert(!std::is_const<LibObjT>::value,
1614 "Not available with `bt2::ConstBlobFieldClass`.");
1616 if (bt_field_class_blob_set_media_type(this->libObjPtr(), mediaType) ==
1617 BT_FIELD_CLASS_BLOB_SET_MEDIA_TYPE_STATUS_MEMORY_ERROR) {
1618 throw MemoryError {};
1624 Shared shared() const noexcept
1626 return Shared::createWithRef(*this);
1630 using BlobFieldClass = CommonBlobFieldClass<bt_field_class>;
1631 using ConstBlobFieldClass = CommonBlobFieldClass<const bt_field_class>;
1633 namespace internal {
1635 struct BlobFieldClassTypeDescr
1637 using Const = ConstBlobFieldClass;
1638 using NonConst = BlobFieldClass;
1642 struct TypeDescr<BlobFieldClass> : public BlobFieldClassTypeDescr
1647 struct TypeDescr<ConstBlobFieldClass> : public BlobFieldClassTypeDescr
1651 } /* namespace internal */
1653 template <typename LibObjT>
1654 class CommonStaticBlobFieldClass final : public CommonBlobFieldClass<LibObjT>
1657 using typename CommonBlobFieldClass<LibObjT>::_ThisCommonBlobFieldClass;
1660 using Shared = SharedFieldClass<CommonStaticBlobFieldClass<LibObjT>, LibObjT>;
1661 using typename CommonFieldClass<LibObjT>::LibObjPtr;
1663 explicit CommonStaticBlobFieldClass(const LibObjPtr libObjPtr) noexcept :
1664 _ThisCommonBlobFieldClass {libObjPtr}
1666 BT_ASSERT_DBG(this->isStaticBlob());
1669 template <typename OtherLibObjT>
1670 CommonStaticBlobFieldClass(const CommonStaticBlobFieldClass<OtherLibObjT> fc) noexcept :
1671 _ThisCommonBlobFieldClass {fc}
1675 template <typename OtherLibObjT>
1676 CommonStaticBlobFieldClass operator=(const CommonStaticBlobFieldClass<OtherLibObjT> fc) noexcept
1678 _ThisCommonBlobFieldClass::operator=(fc);
1682 CommonStaticBlobFieldClass<const bt_field_class> asConst() const noexcept
1684 return CommonStaticBlobFieldClass<const bt_field_class> {*this};
1687 std::uint64_t length() const noexcept
1689 return bt_field_class_blob_static_get_length(this->libObjPtr());
1692 Shared shared() const noexcept
1694 return Shared::createWithRef(*this);
1698 using StaticBlobFieldClass = CommonStaticBlobFieldClass<bt_field_class>;
1699 using ConstStaticBlobFieldClass = CommonStaticBlobFieldClass<const bt_field_class>;
1701 namespace internal {
1703 struct StaticBlobFieldClassTypeDescr
1705 using Const = ConstStaticBlobFieldClass;
1706 using NonConst = StaticBlobFieldClass;
1710 struct TypeDescr<StaticBlobFieldClass> : public StaticBlobFieldClassTypeDescr
1715 struct TypeDescr<ConstStaticBlobFieldClass> : public StaticBlobFieldClassTypeDescr
1719 } /* namespace internal */
1721 template <typename LibObjT>
1722 class CommonDynamicBlobWithLengthFieldClass final : public CommonBlobFieldClass<LibObjT>
1725 using typename CommonBlobFieldClass<LibObjT>::_ThisCommonBlobFieldClass;
1728 using Shared = SharedFieldClass<CommonDynamicBlobWithLengthFieldClass<LibObjT>, LibObjT>;
1729 using typename CommonFieldClass<LibObjT>::LibObjPtr;
1731 explicit CommonDynamicBlobWithLengthFieldClass(const LibObjPtr libObjPtr) noexcept :
1732 _ThisCommonBlobFieldClass {libObjPtr}
1734 BT_ASSERT_DBG(this->isDynamicBlobWithLength());
1737 template <typename OtherLibObjT>
1738 CommonDynamicBlobWithLengthFieldClass(
1739 const CommonDynamicBlobWithLengthFieldClass<OtherLibObjT> fc) noexcept :
1740 _ThisCommonBlobFieldClass {fc}
1744 template <typename OtherLibObjT>
1745 CommonDynamicBlobWithLengthFieldClass
1746 operator=(const CommonDynamicBlobWithLengthFieldClass<OtherLibObjT> fc) noexcept
1748 _ThisCommonBlobFieldClass::operator=(fc);
1752 CommonDynamicBlobWithLengthFieldClass<const bt_field_class> asConst() const noexcept
1754 return CommonDynamicBlobWithLengthFieldClass<const bt_field_class> {*this};
1757 ConstFieldLocation lengthFieldLocation() const noexcept
1759 return ConstFieldLocation {
1760 bt_field_class_blob_dynamic_with_length_field_borrow_length_field_location_const(
1761 this->libObjPtr())};
1764 Shared shared() const noexcept
1766 return Shared::createWithRef(*this);
1770 using DynamicBlobWithLengthFieldClass = CommonDynamicBlobWithLengthFieldClass<bt_field_class>;
1772 using ConstDynamicBlobWithLengthFieldClass =
1773 CommonDynamicBlobWithLengthFieldClass<const bt_field_class>;
1775 namespace internal {
1777 struct DynamicBlobWithLengthFieldClassTypeDescr
1779 using Const = ConstDynamicBlobWithLengthFieldClass;
1780 using NonConst = DynamicBlobWithLengthFieldClass;
1784 struct TypeDescr<DynamicBlobWithLengthFieldClass> : public DynamicBlobWithLengthFieldClassTypeDescr
1789 struct TypeDescr<ConstDynamicBlobWithLengthFieldClass> :
1790 public DynamicBlobWithLengthFieldClassTypeDescr
1794 template <typename LibObjT>
1795 struct CommonOptionFieldClassSpec;
1797 /* Functions specific to mutable option field classes */
1799 struct CommonOptionFieldClassSpec<bt_field_class> final
1801 static bt_field_class *fieldClass(bt_field_class * const libObjPtr) noexcept
1803 return bt_field_class_option_borrow_field_class(libObjPtr);
1807 /* Functions specific to constant option field classes */
1809 struct CommonOptionFieldClassSpec<const bt_field_class> final
1811 static const bt_field_class *fieldClass(const bt_field_class * const libObjPtr) noexcept
1813 return bt_field_class_option_borrow_field_class_const(libObjPtr);
1817 } /* namespace internal */
1819 template <typename LibObjT>
1820 class CommonOptionFieldClass : public CommonFieldClass<LibObjT>
1823 using typename CommonFieldClass<LibObjT>::_ThisCommonFieldClass;
1824 using _FieldClass = internal::DepFc<LibObjT>;
1827 using _ThisCommonOptionFieldClass = CommonOptionFieldClass<LibObjT>;
1830 using typename CommonFieldClass<LibObjT>::LibObjPtr;
1831 using Shared = SharedFieldClass<CommonOptionFieldClass<LibObjT>, LibObjT>;
1833 explicit CommonOptionFieldClass(const LibObjPtr libObjPtr) noexcept :
1834 _ThisCommonFieldClass {libObjPtr}
1836 BT_ASSERT_DBG(this->isOption());
1839 template <typename OtherLibObjT>
1840 CommonOptionFieldClass(const CommonOptionFieldClass<OtherLibObjT> fc) noexcept :
1841 _ThisCommonFieldClass {fc}
1845 template <typename OtherLibObjT>
1846 CommonOptionFieldClass operator=(const CommonOptionFieldClass<OtherLibObjT> fc) noexcept
1848 _ThisCommonFieldClass::operator=(fc);
1852 CommonOptionFieldClass<const bt_field_class> asConst() const noexcept
1854 return CommonOptionFieldClass<const bt_field_class> {*this};
1857 _FieldClass fieldClass() const noexcept
1859 return _FieldClass {
1860 internal::CommonOptionFieldClassSpec<LibObjT>::fieldClass(this->libObjPtr())};
1863 Shared shared() const noexcept
1865 return Shared::createWithRef(*this);
1869 using OptionFieldClass = CommonOptionFieldClass<bt_field_class>;
1870 using ConstOptionFieldClass = CommonOptionFieldClass<const bt_field_class>;
1872 namespace internal {
1874 struct OptionFieldClassTypeDescr
1876 using Const = ConstOptionFieldClass;
1877 using NonConst = OptionFieldClass;
1881 struct TypeDescr<OptionFieldClass> : public OptionFieldClassTypeDescr
1886 struct TypeDescr<ConstOptionFieldClass> : public OptionFieldClassTypeDescr
1890 } /* namespace internal */
1892 template <typename LibObjT>
1893 class CommonOptionWithSelectorFieldClass : public CommonOptionFieldClass<LibObjT>
1896 using typename CommonOptionFieldClass<LibObjT>::_ThisCommonOptionFieldClass;
1899 using _ThisCommonOptionWithSelectorFieldClass = CommonOptionWithSelectorFieldClass<LibObjT>;
1902 using typename CommonFieldClass<LibObjT>::LibObjPtr;
1903 using Shared = SharedFieldClass<CommonOptionWithSelectorFieldClass<LibObjT>, LibObjT>;
1905 explicit CommonOptionWithSelectorFieldClass(const LibObjPtr libObjPtr) noexcept :
1906 _ThisCommonOptionFieldClass {libObjPtr}
1908 BT_ASSERT_DBG(this->isOptionWithSelector());
1911 template <typename OtherLibObjT>
1912 CommonOptionWithSelectorFieldClass(
1913 const CommonOptionWithSelectorFieldClass<OtherLibObjT> fc) noexcept :
1914 _ThisCommonOptionFieldClass {fc}
1918 template <typename OtherLibObjT>
1919 CommonOptionWithSelectorFieldClass
1920 operator=(const CommonOptionWithSelectorFieldClass<OtherLibObjT> fc) noexcept
1922 _ThisCommonOptionFieldClass::operator=(fc);
1926 CommonOptionWithSelectorFieldClass<const bt_field_class> asConst() const noexcept
1928 return CommonOptionWithSelectorFieldClass<const bt_field_class> {*this};
1931 ConstFieldPath selectorFieldPath() const noexcept
1933 return ConstFieldPath {
1934 bt_field_class_option_with_selector_field_borrow_selector_field_path_const(
1935 this->libObjPtr())};
1938 ConstFieldLocation selectorFieldLocation() const noexcept
1940 return ConstFieldLocation {
1941 bt_field_class_option_with_selector_field_borrow_selector_field_location_const(
1942 this->libObjPtr())};
1945 Shared shared() const noexcept
1947 return Shared::createWithRef(*this);
1951 using OptionWithSelectorFieldClass = CommonOptionWithSelectorFieldClass<bt_field_class>;
1952 using ConstOptionWithSelectorFieldClass = CommonOptionWithSelectorFieldClass<const bt_field_class>;
1954 namespace internal {
1956 struct OptionWithSelectorFieldClassTypeDescr
1958 using Const = ConstOptionWithSelectorFieldClass;
1959 using NonConst = OptionWithSelectorFieldClass;
1963 struct TypeDescr<OptionWithSelectorFieldClass> : public OptionWithSelectorFieldClassTypeDescr
1968 struct TypeDescr<ConstOptionWithSelectorFieldClass> : public OptionWithSelectorFieldClassTypeDescr
1972 } /* namespace internal */
1974 template <typename LibObjT>
1975 class CommonOptionWithBoolSelectorFieldClass : public CommonOptionWithSelectorFieldClass<LibObjT>
1978 using typename CommonOptionWithSelectorFieldClass<
1979 LibObjT>::_ThisCommonOptionWithSelectorFieldClass;
1982 using typename CommonFieldClass<LibObjT>::LibObjPtr;
1983 using Shared = SharedFieldClass<CommonOptionWithBoolSelectorFieldClass<LibObjT>, LibObjT>;
1985 explicit CommonOptionWithBoolSelectorFieldClass(const LibObjPtr libObjPtr) noexcept :
1986 _ThisCommonOptionWithSelectorFieldClass {libObjPtr}
1988 BT_ASSERT_DBG(this->isOptionWithBoolSelector());
1991 template <typename OtherLibObjT>
1992 CommonOptionWithBoolSelectorFieldClass(
1993 const CommonOptionWithBoolSelectorFieldClass<OtherLibObjT> fc) noexcept :
1994 _ThisCommonOptionWithSelectorFieldClass {fc}
1998 template <typename OtherLibObjT>
1999 CommonOptionWithBoolSelectorFieldClass
2000 operator=(const CommonOptionWithBoolSelectorFieldClass<OtherLibObjT> fc) noexcept
2002 _ThisCommonOptionWithSelectorFieldClass::operator=(fc);
2006 CommonOptionWithBoolSelectorFieldClass<const bt_field_class> asConst() const noexcept
2008 return CommonOptionWithBoolSelectorFieldClass<const bt_field_class> {*this};
2011 bool selectorIsReversed() const noexcept
2013 return bt_field_class_option_with_selector_field_bool_selector_is_reversed(
2017 Shared shared() const noexcept
2019 return Shared::createWithRef(*this);
2023 using OptionWithBoolSelectorFieldClass = CommonOptionWithBoolSelectorFieldClass<bt_field_class>;
2025 using ConstOptionWithBoolSelectorFieldClass =
2026 CommonOptionWithBoolSelectorFieldClass<const bt_field_class>;
2028 namespace internal {
2030 struct OptionWithBoolSelectorFieldClassTypeDescr
2032 using Const = ConstOptionWithBoolSelectorFieldClass;
2033 using NonConst = OptionWithBoolSelectorFieldClass;
2037 struct TypeDescr<OptionWithBoolSelectorFieldClass> :
2038 public OptionWithBoolSelectorFieldClassTypeDescr
2043 struct TypeDescr<ConstOptionWithBoolSelectorFieldClass> :
2044 public OptionWithBoolSelectorFieldClassTypeDescr
2048 template <typename RangeSetT>
2049 struct CommonOptionWithIntegerSelectorFieldClassSpec;
2051 /* Functions specific to option field classes with unsigned integer ranges */
2053 struct CommonOptionWithIntegerSelectorFieldClassSpec<ConstUnsignedIntegerRangeSet> final
2055 static const bt_integer_range_set_unsigned *
2056 ranges(const bt_field_class * const libObjPtr) noexcept
2058 return bt_field_class_option_with_selector_field_integer_unsigned_borrow_selector_ranges_const(
2063 /* Functions specific to option field classes with signed ranges */
2065 struct CommonOptionWithIntegerSelectorFieldClassSpec<ConstSignedIntegerRangeSet> final
2067 static const bt_integer_range_set_signed *
2068 ranges(const bt_field_class * const libObjPtr) noexcept
2070 return bt_field_class_option_with_selector_field_integer_signed_borrow_selector_ranges_const(
2075 } /* namespace internal */
2077 template <typename LibObjT, typename RangeSetT>
2078 class CommonOptionWithIntegerSelectorFieldClass : public CommonOptionWithSelectorFieldClass<LibObjT>
2081 using typename CommonOptionWithSelectorFieldClass<
2082 LibObjT>::_ThisCommonOptionWithSelectorFieldClass;
2085 using typename CommonFieldClass<LibObjT>::LibObjPtr;
2086 using Shared = SharedFieldClass<CommonOptionWithIntegerSelectorFieldClass, LibObjT>;
2087 using RangeSet = RangeSetT;
2089 explicit CommonOptionWithIntegerSelectorFieldClass(const LibObjPtr libObjPtr) noexcept :
2090 _ThisCommonOptionWithSelectorFieldClass {libObjPtr}
2092 BT_ASSERT_DBG(this->isOptionWithIntegerSelector());
2095 template <typename OtherLibObjT>
2096 CommonOptionWithIntegerSelectorFieldClass(
2097 const CommonOptionWithIntegerSelectorFieldClass<OtherLibObjT, RangeSetT> fc) noexcept :
2098 _ThisCommonOptionWithSelectorFieldClass {fc}
2102 template <typename OtherLibObjT>
2103 CommonOptionWithIntegerSelectorFieldClass
2104 operator=(const CommonOptionWithIntegerSelectorFieldClass<OtherLibObjT, RangeSetT> fc) noexcept
2106 _ThisCommonOptionWithSelectorFieldClass::operator=(fc);
2110 RangeSet ranges() const noexcept
2112 return RangeSet {internal::CommonOptionWithIntegerSelectorFieldClassSpec<RangeSetT>::ranges(
2113 this->libObjPtr())};
2116 Shared shared() const noexcept
2118 return Shared::createWithRef(*this);
2122 using OptionWithUnsignedIntegerSelectorFieldClass =
2123 CommonOptionWithIntegerSelectorFieldClass<bt_field_class, ConstUnsignedIntegerRangeSet>;
2125 using ConstOptionWithUnsignedIntegerSelectorFieldClass =
2126 CommonOptionWithIntegerSelectorFieldClass<const bt_field_class, ConstUnsignedIntegerRangeSet>;
2128 using OptionWithSignedIntegerSelectorFieldClass =
2129 CommonOptionWithIntegerSelectorFieldClass<bt_field_class, ConstSignedIntegerRangeSet>;
2131 using ConstOptionWithSignedIntegerSelectorFieldClass =
2132 CommonOptionWithIntegerSelectorFieldClass<const bt_field_class, ConstSignedIntegerRangeSet>;
2134 namespace internal {
2136 struct OptionWithUnsignedIntegerSelectorFieldClassTypeDescr
2138 using Const = ConstOptionWithUnsignedIntegerSelectorFieldClass;
2139 using NonConst = OptionWithUnsignedIntegerSelectorFieldClass;
2143 struct TypeDescr<OptionWithUnsignedIntegerSelectorFieldClass> :
2144 public OptionWithUnsignedIntegerSelectorFieldClassTypeDescr
2149 struct TypeDescr<ConstOptionWithUnsignedIntegerSelectorFieldClass> :
2150 public OptionWithUnsignedIntegerSelectorFieldClassTypeDescr
2154 struct OptionWithSignedIntegerSelectorFieldClassTypeDescr
2156 using Const = ConstOptionWithSignedIntegerSelectorFieldClass;
2157 using NonConst = OptionWithSignedIntegerSelectorFieldClass;
2161 struct TypeDescr<OptionWithSignedIntegerSelectorFieldClass> :
2162 public OptionWithSignedIntegerSelectorFieldClassTypeDescr
2167 struct TypeDescr<ConstOptionWithSignedIntegerSelectorFieldClass> :
2168 public OptionWithSignedIntegerSelectorFieldClassTypeDescr
2172 template <typename LibObjT>
2173 struct CommonVariantFieldClassOptionSpec;
2175 /* Functions specific to mutable variant field class options */
2177 struct CommonVariantFieldClassOptionSpec<bt_field_class_variant_option> final
2179 static bt_field_class *fieldClass(bt_field_class_variant_option * const libObjPtr) noexcept
2181 return bt_field_class_variant_option_borrow_field_class(libObjPtr);
2184 static bt_value *userAttributes(bt_field_class_variant_option * const libObjPtr) noexcept
2186 return bt_field_class_variant_option_borrow_user_attributes(libObjPtr);
2190 /* Functions specific to constant variant field class options */
2192 struct CommonVariantFieldClassOptionSpec<const bt_field_class_variant_option> final
2194 static const bt_field_class *
2195 fieldClass(const bt_field_class_variant_option * const libObjPtr) noexcept
2197 return bt_field_class_variant_option_borrow_field_class_const(libObjPtr);
2200 static const bt_value *
2201 userAttributes(const bt_field_class_variant_option * const libObjPtr) noexcept
2203 return bt_field_class_variant_option_borrow_user_attributes_const(libObjPtr);
2207 } /* namespace internal */
2209 template <typename LibObjT>
2210 class CommonVariantFieldClassOption : public BorrowedObject<LibObjT>
2213 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
2214 using _FieldClass = internal::DepFc<LibObjT>;
2217 using typename BorrowedObject<LibObjT>::LibObjPtr;
2218 using UserAttributes = internal::DepUserAttrs<LibObjT>;
2220 explicit CommonVariantFieldClassOption(const LibObjPtr libObjPtr) noexcept :
2221 _ThisBorrowedObject {libObjPtr}
2225 template <typename OtherLibObjT>
2226 CommonVariantFieldClassOption(const CommonVariantFieldClassOption<OtherLibObjT> fc) noexcept :
2227 _ThisBorrowedObject {fc}
2231 template <typename OtherLibObjT>
2232 CommonVariantFieldClassOption
2233 operator=(const CommonVariantFieldClassOption<OtherLibObjT> fc) noexcept
2235 _ThisBorrowedObject::operator=(fc);
2239 CommonVariantFieldClassOption<const bt_field_class_variant_option> asConst() const noexcept
2241 return CommonVariantFieldClassOption<const bt_field_class_variant_option> {*this};
2244 bt2c::CStringView name() const noexcept
2246 return bt_field_class_variant_option_get_name(this->libObjPtr());
2249 _FieldClass fieldClass() const noexcept
2251 return _FieldClass {
2252 internal::CommonVariantFieldClassOptionSpec<LibObjT>::fieldClass(this->libObjPtr())};
2255 template <typename LibValT>
2256 CommonVariantFieldClassOption
2257 userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
2259 static_assert(!std::is_const<LibObjT>::value,
2260 "Not available with `bt2::ConstVariantFieldClassOption`.");
2262 bt_field_class_variant_option_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr());
2266 UserAttributes userAttributes() const noexcept
2268 return UserAttributes {internal::CommonVariantFieldClassOptionSpec<LibObjT>::userAttributes(
2269 this->libObjPtr())};
2273 using VariantFieldClassOption = CommonVariantFieldClassOption<bt_field_class_variant_option>;
2275 using ConstVariantFieldClassOption =
2276 CommonVariantFieldClassOption<const bt_field_class_variant_option>;
2278 namespace internal {
2280 struct VariantFieldClassOptionTypeDescr
2282 using Const = ConstVariantFieldClassOption;
2283 using NonConst = VariantFieldClassOption;
2287 struct TypeDescr<VariantFieldClassOption> : public VariantFieldClassOptionTypeDescr
2292 struct TypeDescr<ConstVariantFieldClassOption> : public VariantFieldClassOptionTypeDescr
2296 template <typename LibObjT>
2297 struct ConstVariantWithIntegerSelectorFieldClassOptionSpec;
2299 /* Functions specific to variant field class options with unsigned integer selector */
2301 struct ConstVariantWithIntegerSelectorFieldClassOptionSpec<
2302 const bt_field_class_variant_with_selector_field_integer_unsigned_option>
2305 static const bt_integer_range_set_unsigned *
2306 ranges(const bt_field_class_variant_with_selector_field_integer_unsigned_option
2307 * const libObjPtr) noexcept
2309 return bt_field_class_variant_with_selector_field_integer_unsigned_option_borrow_ranges_const(
2313 static const bt_field_class_variant_option *
2314 asBaseOption(const bt_field_class_variant_with_selector_field_integer_unsigned_option
2315 * const libObjPtr) noexcept
2317 return bt_field_class_variant_with_selector_field_integer_unsigned_option_as_option_const(
2322 /* Functions specific to variant field class options with signed integer selector */
2324 struct ConstVariantWithIntegerSelectorFieldClassOptionSpec<
2325 const bt_field_class_variant_with_selector_field_integer_signed_option>
2328 static const bt_integer_range_set_signed *
2329 ranges(const bt_field_class_variant_with_selector_field_integer_signed_option
2330 * const libObjPtr) noexcept
2332 return bt_field_class_variant_with_selector_field_integer_signed_option_borrow_ranges_const(
2336 static const bt_field_class_variant_option *
2337 asBaseOption(const bt_field_class_variant_with_selector_field_integer_signed_option
2338 * const libObjPtr) noexcept
2340 return bt_field_class_variant_with_selector_field_integer_signed_option_as_option_const(
2345 } /* namespace internal */
2347 template <typename LibObjT>
2348 class ConstVariantWithIntegerSelectorFieldClassOption : public BorrowedObject<LibObjT>
2351 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
2352 using _Spec = internal::ConstVariantWithIntegerSelectorFieldClassOptionSpec<LibObjT>;
2355 using typename BorrowedObject<LibObjT>::LibObjPtr;
2357 using RangeSet = typename std::conditional<
2360 const bt_field_class_variant_with_selector_field_integer_unsigned_option>::value,
2361 ConstUnsignedIntegerRangeSet, ConstSignedIntegerRangeSet>::type;
2363 explicit ConstVariantWithIntegerSelectorFieldClassOption(const LibObjPtr libObjPtr) noexcept :
2364 _ThisBorrowedObject {libObjPtr}
2368 template <typename OtherLibObjT>
2369 ConstVariantWithIntegerSelectorFieldClassOption(
2370 const ConstVariantWithIntegerSelectorFieldClassOption<OtherLibObjT> fc) noexcept :
2371 _ThisBorrowedObject {fc}
2375 template <typename OtherLibObjT>
2376 ConstVariantWithIntegerSelectorFieldClassOption
2377 operator=(const ConstVariantWithIntegerSelectorFieldClassOption<OtherLibObjT> fc) noexcept
2379 _ThisBorrowedObject::operator=(fc);
2383 ConstVariantFieldClassOption asBaseOption() const noexcept
2385 return ConstVariantFieldClassOption {_Spec::asBaseOption(this->libObjPtr())};
2388 bt2c::CStringView name() const noexcept
2390 return this->asBaseOption().name();
2393 ConstFieldClass fieldClass() const noexcept
2395 return this->asBaseOption().fieldClass();
2398 RangeSet ranges() const noexcept
2400 return RangeSet {_Spec::ranges(this->libObjPtr())};
2404 using ConstVariantWithUnsignedIntegerSelectorFieldClassOption =
2405 ConstVariantWithIntegerSelectorFieldClassOption<
2406 const bt_field_class_variant_with_selector_field_integer_unsigned_option>;
2408 using ConstVariantWithSignedIntegerSelectorFieldClassOption =
2409 ConstVariantWithIntegerSelectorFieldClassOption<
2410 const bt_field_class_variant_with_selector_field_integer_signed_option>;
2412 namespace internal {
2414 template <typename LibObjT>
2415 struct CommonVariantFieldClassSpec;
2417 /* Functions specific to mutable variant field classes */
2419 struct CommonVariantFieldClassSpec<bt_field_class> final
2421 static bt_field_class_variant_option *optionByIndex(bt_field_class * const libObjPtr,
2422 const std::uint64_t index) noexcept
2424 return bt_field_class_variant_borrow_option_by_index(libObjPtr, index);
2427 static bt_field_class_variant_option *optionByName(bt_field_class * const libObjPtr,
2428 const char * const name) noexcept
2430 return bt_field_class_variant_borrow_option_by_name(libObjPtr, name);
2434 /* Functions specific to constant variant field classes */
2436 struct CommonVariantFieldClassSpec<const bt_field_class> final
2438 static const bt_field_class_variant_option *
2439 optionByIndex(const bt_field_class * const libObjPtr, const std::uint64_t index) noexcept
2441 return bt_field_class_variant_borrow_option_by_index_const(libObjPtr, index);
2444 static const bt_field_class_variant_option *optionByName(const bt_field_class * const libObjPtr,
2445 const char * const name) noexcept
2447 return bt_field_class_variant_borrow_option_by_name_const(libObjPtr, name);
2451 } /* namespace internal */
2453 template <typename LibObjT>
2454 class CommonVariantFieldClass : public CommonFieldClass<LibObjT>
2457 using typename CommonFieldClass<LibObjT>::_ThisCommonFieldClass;
2460 using _ThisCommonVariantFieldClass = CommonVariantFieldClass<LibObjT>;
2463 using typename CommonFieldClass<LibObjT>::LibObjPtr;
2464 using Shared = SharedFieldClass<CommonVariantFieldClass<LibObjT>, LibObjT>;
2465 using Iterator = BorrowedObjectIterator<CommonVariantFieldClass>;
2468 internal::DepType<LibObjT, VariantFieldClassOption, ConstVariantFieldClassOption>;
2470 explicit CommonVariantFieldClass(const LibObjPtr libObjPtr) noexcept :
2471 _ThisCommonFieldClass {libObjPtr}
2473 BT_ASSERT_DBG(this->isVariant());
2476 template <typename OtherLibObjT>
2477 CommonVariantFieldClass(const CommonVariantFieldClass<OtherLibObjT> fc) noexcept :
2478 _ThisCommonFieldClass {fc}
2482 template <typename OtherLibObjT>
2483 CommonVariantFieldClass operator=(const CommonVariantFieldClass<OtherLibObjT> fc) noexcept
2485 _ThisCommonFieldClass::operator=(fc);
2489 CommonVariantFieldClass<const bt_field_class> asConst() const noexcept
2491 return CommonVariantFieldClass<const bt_field_class> {*this};
2494 std::uint64_t length() const noexcept
2496 return bt_field_class_variant_get_option_count(this->libObjPtr());
2499 Iterator begin() const noexcept
2501 return Iterator {*this, 0};
2504 Iterator end() const noexcept
2506 return Iterator {*this, this->length()};
2509 Option operator[](const std::uint64_t index) const noexcept
2511 return Option {internal::CommonVariantFieldClassSpec<LibObjT>::optionByIndex(
2512 this->libObjPtr(), index)};
2515 OptionalBorrowedObject<Option> operator[](const bt2c::CStringView name) const noexcept
2517 return internal::CommonVariantFieldClassSpec<LibObjT>::optionByName(this->libObjPtr(),
2521 Shared shared() const noexcept
2523 return Shared::createWithRef(*this);
2527 using VariantFieldClass = CommonVariantFieldClass<bt_field_class>;
2528 using ConstVariantFieldClass = CommonVariantFieldClass<const bt_field_class>;
2530 namespace internal {
2532 struct VariantFieldClassTypeDescr
2534 using Const = ConstVariantFieldClass;
2535 using NonConst = VariantFieldClass;
2539 struct TypeDescr<VariantFieldClass> : public VariantFieldClassTypeDescr
2544 struct TypeDescr<ConstVariantFieldClass> : public VariantFieldClassTypeDescr
2548 } /* namespace internal */
2550 template <typename LibObjT>
2551 class CommonVariantWithoutSelectorFieldClass : public CommonVariantFieldClass<LibObjT>
2554 using typename CommonVariantFieldClass<LibObjT>::_ThisCommonVariantFieldClass;
2557 using typename CommonFieldClass<LibObjT>::LibObjPtr;
2558 using Shared = SharedFieldClass<CommonVariantWithoutSelectorFieldClass<LibObjT>, LibObjT>;
2560 explicit CommonVariantWithoutSelectorFieldClass(const LibObjPtr libObjPtr) noexcept :
2561 _ThisCommonVariantFieldClass {libObjPtr}
2563 BT_ASSERT_DBG(this->isVariantWithoutSelector());
2566 template <typename OtherLibObjT>
2567 CommonVariantWithoutSelectorFieldClass(
2568 const CommonVariantWithoutSelectorFieldClass<OtherLibObjT> fc) noexcept :
2569 _ThisCommonVariantFieldClass {fc}
2573 template <typename OtherLibObjT>
2574 CommonVariantWithoutSelectorFieldClass
2575 operator=(const CommonVariantWithoutSelectorFieldClass<OtherLibObjT> fc) noexcept
2577 _ThisCommonVariantFieldClass::operator=(fc);
2581 CommonVariantWithoutSelectorFieldClass<const bt_field_class> asConst() const noexcept
2583 return CommonVariantWithoutSelectorFieldClass<const bt_field_class> {*this};
2586 CommonVariantWithoutSelectorFieldClass appendOption(const char * const name,
2587 const FieldClass fc) const
2589 static_assert(!std::is_const<LibObjT>::value,
2590 "Not available with `bt2::ConstVariantWithoutSelectorFieldClass`.");
2592 const auto status = bt_field_class_variant_without_selector_append_option(
2593 this->libObjPtr(), name, fc.libObjPtr());
2596 BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR) {
2597 throw MemoryError {};
2603 CommonVariantWithoutSelectorFieldClass appendOption(const bt2c::CStringView name,
2604 const FieldClass fc) const
2606 return this->appendOption(name.data(), fc);
2609 CommonVariantWithoutSelectorFieldClass appendOption(const bt2s::optional<std::string>& name,
2610 const FieldClass fc) const
2612 return this->appendOption(name ? name->data() : nullptr, fc);
2615 Shared shared() const noexcept
2617 return Shared::createWithRef(*this);
2621 using VariantWithoutSelectorFieldClass = CommonVariantWithoutSelectorFieldClass<bt_field_class>;
2622 using ConstVariantWithoutSelectorFieldClass =
2623 CommonVariantWithoutSelectorFieldClass<const bt_field_class>;
2625 namespace internal {
2627 struct VariantWithoutSelectorFieldClassTypeDescr
2629 using Const = ConstVariantWithoutSelectorFieldClass;
2630 using NonConst = VariantWithoutSelectorFieldClass;
2634 struct TypeDescr<VariantWithoutSelectorFieldClass> :
2635 public VariantWithoutSelectorFieldClassTypeDescr
2640 struct TypeDescr<ConstVariantWithoutSelectorFieldClass> :
2641 public VariantWithoutSelectorFieldClassTypeDescr
2645 template <typename OptionT>
2646 struct CommonVariantWithIntegerSelectorFieldClassSpec;
2648 /* Functions specific to variant field classes with unsigned integer selector */
2650 struct CommonVariantWithIntegerSelectorFieldClassSpec<
2651 ConstVariantWithUnsignedIntegerSelectorFieldClassOption>
2654 static const bt_field_class_variant_with_selector_field_integer_unsigned_option *
2655 optionByIndex(const bt_field_class * const libObjPtr, const std::uint64_t index) noexcept
2657 return bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_index_const(
2661 static const bt_field_class_variant_with_selector_field_integer_unsigned_option *
2662 optionByName(const bt_field_class * const libObjPtr, const char * const name) noexcept
2664 return bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_name_const(
2668 static bt_field_class_variant_with_selector_field_integer_append_option_status
2669 appendOption(bt_field_class * const libObjPtr, const char * const name,
2670 bt_field_class * const libOptFcPtr,
2671 const bt_integer_range_set_unsigned * const libRangesPtr)
2673 return bt_field_class_variant_with_selector_field_integer_unsigned_append_option(
2674 libObjPtr, name, libOptFcPtr, libRangesPtr);
2678 /* Functions specific to variant field classes with signed integer selector */
2680 struct CommonVariantWithIntegerSelectorFieldClassSpec<
2681 ConstVariantWithSignedIntegerSelectorFieldClassOption>
2684 static const bt_field_class_variant_with_selector_field_integer_signed_option *
2685 optionByIndex(const bt_field_class * const libObjPtr, const std::uint64_t index) noexcept
2687 return bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index_const(
2691 static const bt_field_class_variant_with_selector_field_integer_signed_option *
2692 optionByName(const bt_field_class * const libObjPtr, const char * const name) noexcept
2694 return bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_name_const(
2698 static bt_field_class_variant_with_selector_field_integer_append_option_status
2699 appendOption(bt_field_class * const libObjPtr, const char * const name,
2700 bt_field_class * const libOptFcPtr,
2701 const bt_integer_range_set_signed * const libRangesPtr)
2703 return bt_field_class_variant_with_selector_field_integer_signed_append_option(
2704 libObjPtr, name, libOptFcPtr, libRangesPtr);
2708 } /* namespace internal */
2710 template <typename LibObjT>
2711 class CommonVariantWithSelectorFieldClass : public CommonVariantFieldClass<LibObjT>
2714 using typename CommonVariantFieldClass<LibObjT>::_ThisCommonVariantFieldClass;
2717 using _ThisCommonVariantWithSelectorFieldClass = CommonVariantWithSelectorFieldClass<LibObjT>;
2720 using typename CommonFieldClass<LibObjT>::LibObjPtr;
2721 using Shared = SharedFieldClass<_ThisCommonVariantWithSelectorFieldClass, LibObjT>;
2723 explicit CommonVariantWithSelectorFieldClass(const LibObjPtr libObjPtr) noexcept :
2724 _ThisCommonVariantFieldClass {libObjPtr}
2726 BT_ASSERT_DBG(this->isVariantWithSelector());
2729 template <typename OtherLibObjT>
2730 CommonVariantWithSelectorFieldClass(
2731 const CommonVariantWithSelectorFieldClass<OtherLibObjT> fc) noexcept :
2732 _ThisCommonVariantFieldClass {fc}
2736 template <typename OtherLibObjT>
2737 CommonVariantWithSelectorFieldClass
2738 operator=(const CommonVariantWithSelectorFieldClass<OtherLibObjT> fc) noexcept
2740 _ThisCommonVariantFieldClass::operator=(fc);
2744 CommonVariantWithSelectorFieldClass<const bt_field_class> asConst() const noexcept
2746 return CommonVariantWithSelectorFieldClass<const bt_field_class> {*this};
2749 ConstFieldPath selectorFieldPath() const noexcept
2751 return ConstFieldPath {
2752 bt_field_class_variant_with_selector_field_borrow_selector_field_path_const(
2753 this->libObjPtr())};
2756 ConstFieldLocation selectorFieldLocation() const noexcept
2758 return ConstFieldLocation {
2759 bt_field_class_variant_with_selector_field_borrow_selector_field_location_const(
2760 this->libObjPtr())};
2763 Shared shared() const noexcept
2765 return Shared::createWithRef(*this);
2769 using VariantWithSelectorFieldClass = CommonVariantWithSelectorFieldClass<bt_field_class>;
2770 using ConstVariantWithSelectorFieldClass =
2771 CommonVariantWithSelectorFieldClass<const bt_field_class>;
2773 template <typename LibObjT, typename OptionT>
2774 class CommonVariantWithIntegerSelectorFieldClass :
2775 public CommonVariantWithSelectorFieldClass<LibObjT>
2778 using typename CommonVariantWithSelectorFieldClass<
2779 LibObjT>::_ThisCommonVariantWithSelectorFieldClass;
2781 using _Spec = internal::CommonVariantWithIntegerSelectorFieldClassSpec<OptionT>;
2784 using typename CommonFieldClass<LibObjT>::LibObjPtr;
2785 using Shared = SharedFieldClass<CommonVariantWithIntegerSelectorFieldClass, LibObjT>;
2786 using Option = OptionT;
2789 BorrowedObjectIterator<CommonVariantWithIntegerSelectorFieldClass<LibObjT, Option>>;
2791 explicit CommonVariantWithIntegerSelectorFieldClass(const LibObjPtr libObjPtr) noexcept :
2792 _ThisCommonVariantWithSelectorFieldClass {libObjPtr}
2794 BT_ASSERT_DBG(this->isVariantWithIntegerSelector());
2797 template <typename OtherLibObjT>
2798 CommonVariantWithIntegerSelectorFieldClass(
2799 const CommonVariantWithIntegerSelectorFieldClass<OtherLibObjT, OptionT> fc) noexcept :
2800 _ThisCommonVariantWithSelectorFieldClass {fc}
2804 template <typename OtherLibObjT>
2805 CommonVariantWithIntegerSelectorFieldClass
2806 operator=(const CommonVariantWithIntegerSelectorFieldClass<OtherLibObjT, OptionT> fc) noexcept
2808 _ThisCommonVariantWithSelectorFieldClass::operator=(fc);
2812 Option operator[](const std::uint64_t index) const noexcept
2814 return Option {_Spec::optionByIndex(this->libObjPtr(), index)};
2817 OptionalBorrowedObject<Option> operator[](const bt2c::CStringView name) const noexcept
2819 return _Spec::optionByName(this->libObjPtr(), name);
2822 CommonVariantWithIntegerSelectorFieldClass
2823 appendOption(const char * const name, const FieldClass fc,
2824 const typename Option::RangeSet ranges) const
2827 !std::is_const<LibObjT>::value,
2828 "Not available with `bt2::ConstVariantWithUnsignedIntegerSelectorFieldClass`.");
2831 _Spec::appendOption(this->libObjPtr(), name, fc.libObjPtr(), ranges.libObjPtr());
2834 BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR) {
2835 throw MemoryError {};
2841 CommonVariantWithIntegerSelectorFieldClass
2842 appendOption(const bt2c::CStringView name, const FieldClass fc,
2843 const typename Option::RangeSet ranges) const
2845 return this->appendOption(name.data(), fc, ranges);
2848 CommonVariantWithIntegerSelectorFieldClass
2849 appendOption(const bt2s::optional<std::string>& name, const FieldClass fc,
2850 const typename Option::RangeSet ranges) const
2852 return this->appendOption(name ? name->data() : nullptr, fc, ranges);
2855 Iterator begin() const noexcept
2857 return Iterator {*this, 0};
2860 Iterator end() const noexcept
2862 return Iterator {*this, this->length()};
2865 Shared shared() const noexcept
2867 return Shared::createWithRef(*this);
2871 using VariantWithUnsignedIntegerSelectorFieldClass = CommonVariantWithIntegerSelectorFieldClass<
2872 bt_field_class, ConstVariantWithUnsignedIntegerSelectorFieldClassOption>;
2874 using ConstVariantWithUnsignedIntegerSelectorFieldClass =
2875 CommonVariantWithIntegerSelectorFieldClass<
2876 const bt_field_class, ConstVariantWithUnsignedIntegerSelectorFieldClassOption>;
2878 using VariantWithSignedIntegerSelectorFieldClass = CommonVariantWithIntegerSelectorFieldClass<
2879 bt_field_class, ConstVariantWithSignedIntegerSelectorFieldClassOption>;
2881 using ConstVariantWithSignedIntegerSelectorFieldClass = CommonVariantWithIntegerSelectorFieldClass<
2882 const bt_field_class, ConstVariantWithSignedIntegerSelectorFieldClassOption>;
2884 namespace internal {
2886 struct VariantWithUnsignedIntegerSelectorFieldClassTypeDescr
2888 using Const = ConstVariantWithUnsignedIntegerSelectorFieldClass;
2889 using NonConst = VariantWithUnsignedIntegerSelectorFieldClass;
2893 struct TypeDescr<VariantWithUnsignedIntegerSelectorFieldClass> :
2894 public VariantWithUnsignedIntegerSelectorFieldClassTypeDescr
2899 struct TypeDescr<ConstVariantWithUnsignedIntegerSelectorFieldClass> :
2900 public VariantWithUnsignedIntegerSelectorFieldClassTypeDescr
2904 struct VariantWithSignedIntegerSelectorFieldClassTypeDescr
2906 using Const = ConstVariantWithSignedIntegerSelectorFieldClass;
2907 using NonConst = VariantWithSignedIntegerSelectorFieldClass;
2911 struct TypeDescr<VariantWithSignedIntegerSelectorFieldClass> :
2912 public VariantWithSignedIntegerSelectorFieldClassTypeDescr
2917 struct TypeDescr<ConstVariantWithSignedIntegerSelectorFieldClass> :
2918 public VariantWithSignedIntegerSelectorFieldClassTypeDescr
2922 } /* namespace internal */
2924 template <typename LibObjT>
2925 CommonBitArrayFieldClass<LibObjT> CommonFieldClass<LibObjT>::asBitArray() const noexcept
2927 return CommonBitArrayFieldClass<LibObjT> {this->libObjPtr()};
2930 template <typename LibObjT>
2931 CommonIntegerFieldClass<LibObjT> CommonFieldClass<LibObjT>::asInteger() const noexcept
2933 return CommonIntegerFieldClass<LibObjT> {this->libObjPtr()};
2936 template <typename LibObjT>
2937 CommonBaseEnumerationFieldClass<LibObjT> CommonFieldClass<LibObjT>::asEnumeration() const noexcept
2939 return CommonBaseEnumerationFieldClass<LibObjT> {this->libObjPtr()};
2942 template <typename LibObjT>
2943 CommonEnumerationFieldClass<LibObjT, ConstUnsignedEnumerationFieldClassMapping>
2944 CommonFieldClass<LibObjT>::asUnsignedEnumeration() const noexcept
2946 BT_ASSERT_DBG(this->isUnsignedEnumeration());
2947 return CommonEnumerationFieldClass<LibObjT, ConstUnsignedEnumerationFieldClassMapping> {
2951 template <typename LibObjT>
2952 CommonEnumerationFieldClass<LibObjT, ConstSignedEnumerationFieldClassMapping>
2953 CommonFieldClass<LibObjT>::asSignedEnumeration() const noexcept
2955 BT_ASSERT_DBG(this->isSignedEnumeration());
2956 return CommonEnumerationFieldClass<LibObjT, ConstSignedEnumerationFieldClassMapping> {
2960 template <typename LibObjT>
2961 CommonStructureFieldClass<LibObjT> CommonFieldClass<LibObjT>::asStructure() const noexcept
2963 return CommonStructureFieldClass<LibObjT> {this->libObjPtr()};
2966 template <typename LibObjT>
2967 CommonArrayFieldClass<LibObjT> CommonFieldClass<LibObjT>::asArray() const noexcept
2969 return CommonArrayFieldClass<LibObjT> {this->libObjPtr()};
2972 template <typename LibObjT>
2973 CommonStaticArrayFieldClass<LibObjT> CommonFieldClass<LibObjT>::asStaticArray() const noexcept
2975 return CommonStaticArrayFieldClass<LibObjT> {this->libObjPtr()};
2978 template <typename LibObjT>
2979 CommonDynamicArrayWithLengthFieldClass<LibObjT>
2980 CommonFieldClass<LibObjT>::asDynamicArrayWithLength() const noexcept
2982 return CommonDynamicArrayWithLengthFieldClass<LibObjT> {this->libObjPtr()};
2985 template <typename LibObjT>
2986 CommonBlobFieldClass<LibObjT> CommonFieldClass<LibObjT>::asBlob() const noexcept
2988 BT_ASSERT_DBG(this->isBlob());
2989 return CommonBlobFieldClass<LibObjT> {this->libObjPtr()};
2992 template <typename LibObjT>
2993 CommonStaticBlobFieldClass<LibObjT> CommonFieldClass<LibObjT>::asStaticBlob() const noexcept
2995 BT_ASSERT_DBG(this->isStaticBlob());
2996 return CommonStaticBlobFieldClass<LibObjT> {this->libObjPtr()};
2999 template <typename LibObjT>
3000 CommonDynamicBlobWithLengthFieldClass<LibObjT>
3001 CommonFieldClass<LibObjT>::asDynamicBlobWithLength() const noexcept
3003 BT_ASSERT_DBG(this->isDynamicBlobWithLength());
3004 return CommonDynamicBlobWithLengthFieldClass<LibObjT> {this->libObjPtr()};
3007 template <typename LibObjT>
3008 CommonOptionFieldClass<LibObjT> CommonFieldClass<LibObjT>::asOption() const noexcept
3010 return CommonOptionFieldClass<LibObjT> {this->libObjPtr()};
3013 template <typename LibObjT>
3014 CommonOptionWithSelectorFieldClass<LibObjT>
3015 CommonFieldClass<LibObjT>::asOptionWithSelector() const noexcept
3017 return CommonOptionWithSelectorFieldClass<LibObjT> {this->libObjPtr()};
3020 template <typename LibObjT>
3021 CommonOptionWithBoolSelectorFieldClass<LibObjT>
3022 CommonFieldClass<LibObjT>::asOptionWithBoolSelector() const noexcept
3024 return CommonOptionWithBoolSelectorFieldClass<LibObjT> {this->libObjPtr()};
3027 template <typename LibObjT>
3028 CommonOptionWithIntegerSelectorFieldClass<LibObjT, ConstUnsignedIntegerRangeSet>
3029 CommonFieldClass<LibObjT>::asOptionWithUnsignedIntegerSelector() const noexcept
3031 BT_ASSERT_DBG(this->isOptionWithUnsignedIntegerSelector());
3032 return CommonOptionWithIntegerSelectorFieldClass<LibObjT, ConstUnsignedIntegerRangeSet> {
3036 template <typename LibObjT>
3037 CommonOptionWithIntegerSelectorFieldClass<LibObjT, ConstSignedIntegerRangeSet>
3038 CommonFieldClass<LibObjT>::asOptionWithSignedIntegerSelector() const noexcept
3040 BT_ASSERT_DBG(this->isOptionWithSignedIntegerSelector());
3041 return CommonOptionWithIntegerSelectorFieldClass<LibObjT, ConstSignedIntegerRangeSet> {
3045 template <typename LibObjT>
3046 CommonVariantFieldClass<LibObjT> CommonFieldClass<LibObjT>::asVariant() const noexcept
3048 return CommonVariantFieldClass<LibObjT> {this->libObjPtr()};
3051 template <typename LibObjT>
3052 CommonVariantWithoutSelectorFieldClass<LibObjT>
3053 CommonFieldClass<LibObjT>::asVariantWithoutSelector() const noexcept
3055 return CommonVariantWithoutSelectorFieldClass<LibObjT> {this->libObjPtr()};
3058 template <typename LibObjT>
3059 CommonVariantWithSelectorFieldClass<LibObjT>
3060 CommonFieldClass<LibObjT>::asVariantWithSelector() const noexcept
3062 return CommonVariantWithSelectorFieldClass<LibObjT> {this->libObjPtr()};
3065 template <typename LibObjT>
3066 CommonVariantWithIntegerSelectorFieldClass<LibObjT,
3067 ConstVariantWithUnsignedIntegerSelectorFieldClassOption>
3068 CommonFieldClass<LibObjT>::asVariantWithUnsignedIntegerSelector() const noexcept
3070 BT_ASSERT_DBG(this->isVariantWithUnsignedIntegerSelector());
3071 return CommonVariantWithIntegerSelectorFieldClass<
3072 LibObjT, ConstVariantWithUnsignedIntegerSelectorFieldClassOption> {this->libObjPtr()};
3075 template <typename LibObjT>
3076 CommonVariantWithIntegerSelectorFieldClass<LibObjT,
3077 ConstVariantWithSignedIntegerSelectorFieldClassOption>
3078 CommonFieldClass<LibObjT>::asVariantWithSignedIntegerSelector() const noexcept
3080 BT_ASSERT_DBG(this->isVariantWithSignedIntegerSelector());
3081 return CommonVariantWithIntegerSelectorFieldClass<
3082 LibObjT, ConstVariantWithSignedIntegerSelectorFieldClassOption> {this->libObjPtr()};
3085 } /* namespace bt2 */
3087 #endif /* BABELTRACE_CPP_COMMON_BT2_FIELD_CLASS_HPP */