6853510eb0cf55ddfc4536d93a0500540a01b1e6
[babeltrace.git] / src / cpp-common / bt2 / field.hpp
1 /*
2 * Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7 #ifndef BABELTRACE_CPP_COMMON_BT2_FIELD_HPP
8 #define BABELTRACE_CPP_COMMON_BT2_FIELD_HPP
9
10 #include <cstdint>
11 #include <type_traits>
12
13 #include <babeltrace2/babeltrace.h>
14
15 #include "common/assert.h"
16 #include "cpp-common/bt2c/c-string-view.hpp"
17
18 #include "borrowed-object.hpp"
19 #include "field-class.hpp"
20 #include "internal/utils.hpp"
21 #include "optional-borrowed-object.hpp"
22 #include "raw-value-proxy.hpp"
23
24 namespace bt2 {
25
26 template <typename LibObjT>
27 class CommonBoolField;
28
29 template <typename LibObjT>
30 class CommonBitArrayField;
31
32 template <typename LibObjT>
33 class CommonUnsignedIntegerField;
34
35 template <typename LibObjT>
36 class CommonSignedIntegerField;
37
38 template <typename LibObjT>
39 class CommonUnsignedEnumerationField;
40
41 template <typename LibObjT>
42 class CommonSignedEnumerationField;
43
44 template <typename LibObjT>
45 class CommonSinglePrecisionRealField;
46
47 template <typename LibObjT>
48 class CommonDoublePrecisionRealField;
49
50 template <typename LibObjT>
51 class CommonStringField;
52
53 template <typename LibObjT>
54 class CommonStructureField;
55
56 template <typename LibObjT>
57 class CommonArrayField;
58
59 template <typename LibObjT>
60 class CommonDynamicArrayField;
61
62 template <typename LibObjT>
63 class CommonOptionField;
64
65 template <typename LibObjT>
66 class CommonVariantField;
67
68 namespace internal {
69
70 template <typename LibObjT>
71 struct CommonFieldSpec;
72
73 /* Functions specific to mutable fields */
74 template <>
75 struct CommonFieldSpec<bt_field> final
76 {
77 static bt_field_class *cls(bt_field * const libObjPtr) noexcept
78 {
79 return bt_field_borrow_class(libObjPtr);
80 }
81 };
82
83 /* Functions specific to constant fields */
84 template <>
85 struct CommonFieldSpec<const bt_field> final
86 {
87 static const bt_field_class *cls(const bt_field * const libObjPtr) noexcept
88 {
89 return bt_field_borrow_class_const(libObjPtr);
90 }
91 };
92
93 } /* namespace internal */
94
95 template <typename LibObjT>
96 class CommonField : public BorrowedObject<LibObjT>
97 {
98 private:
99 using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
100
101 protected:
102 using _ThisCommonField = CommonField<LibObjT>;
103
104 public:
105 using typename BorrowedObject<LibObjT>::LibObjPtr;
106 using Class = internal::DepFc<LibObjT>;
107
108 explicit CommonField(const LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr}
109 {
110 }
111
112 template <typename OtherLibObjT>
113 CommonField(const CommonField<OtherLibObjT> val) noexcept : _ThisBorrowedObject {val}
114 {
115 }
116
117 template <typename OtherLibObjT>
118 _ThisCommonField operator=(const CommonField<OtherLibObjT> val) noexcept
119 {
120 _ThisBorrowedObject::operator=(val);
121 return *this;
122 }
123
124 CommonField<const bt_field> asConst() const noexcept
125 {
126 return CommonField<const bt_field> {*this};
127 }
128
129 FieldClassType classType() const noexcept
130 {
131 return static_cast<FieldClassType>(bt_field_get_class_type(this->libObjPtr()));
132 }
133
134 Class cls() const noexcept
135 {
136 return Class {internal::CommonFieldSpec<LibObjT>::cls(this->libObjPtr())};
137 }
138
139 bool isBool() const noexcept
140 {
141 return this->cls().isBool();
142 }
143
144 bool isBitArray() const noexcept
145 {
146 return this->cls().isBitArray();
147 }
148
149 bool isUnsignedInteger() const noexcept
150 {
151 return this->cls().isUnsignedInteger();
152 }
153
154 bool isSignedInteger() const noexcept
155 {
156 return this->cls().isSignedInteger();
157 }
158
159 bool isUnsignedEnumeration() const noexcept
160 {
161 return this->cls().isUnsignedEnumeration();
162 }
163
164 bool isSignedEnumeration() const noexcept
165 {
166 return this->cls().isSignedEnumeration();
167 }
168
169 bool isSinglePrecisionReal() const noexcept
170 {
171 return this->cls().isSinglePrecisionReal();
172 }
173
174 bool isDoublePrecisionReal() const noexcept
175 {
176 return this->cls().isDoublePrecisionReal();
177 }
178
179 bool isString() const noexcept
180 {
181 return this->cls().isString();
182 }
183
184 bool isStructure() const noexcept
185 {
186 return this->cls().isStructure();
187 }
188
189 bool isArray() const noexcept
190 {
191 return this->cls().isArray();
192 }
193
194 bool isDynamicArray() const noexcept
195 {
196 return this->cls().isDynamicArray();
197 }
198
199 bool isOption() const noexcept
200 {
201 return this->cls().isOption();
202 }
203
204 bool isVariant() const noexcept
205 {
206 return this->cls().isVariant();
207 }
208
209 template <typename FieldT>
210 FieldT as() const noexcept
211 {
212 return FieldT {this->libObjPtr()};
213 }
214
215 CommonBoolField<LibObjT> asBool() const noexcept;
216 CommonBitArrayField<LibObjT> asBitArray() const noexcept;
217 CommonUnsignedIntegerField<LibObjT> asUnsignedInteger() const noexcept;
218 CommonSignedIntegerField<LibObjT> asSignedInteger() const noexcept;
219 CommonUnsignedEnumerationField<LibObjT> asUnsignedEnumeration() const noexcept;
220 CommonSignedEnumerationField<LibObjT> asSignedEnumeration() const noexcept;
221 CommonSinglePrecisionRealField<LibObjT> asSinglePrecisionReal() const noexcept;
222 CommonDoublePrecisionRealField<LibObjT> asDoublePrecisionReal() const noexcept;
223 CommonStringField<LibObjT> asString() const noexcept;
224 CommonStructureField<LibObjT> asStructure() const noexcept;
225 CommonArrayField<LibObjT> asArray() const noexcept;
226 CommonDynamicArrayField<LibObjT> asDynamicArray() const noexcept;
227 CommonOptionField<LibObjT> asOption() const noexcept;
228 CommonVariantField<LibObjT> asVariant() const noexcept;
229 };
230
231 using Field = CommonField<bt_field>;
232 using ConstField = CommonField<const bt_field>;
233
234 namespace internal {
235
236 struct FieldTypeDescr
237 {
238 using Const = ConstField;
239 using NonConst = Field;
240 };
241
242 template <>
243 struct TypeDescr<Field> : public FieldTypeDescr
244 {
245 };
246
247 template <>
248 struct TypeDescr<ConstField> : public FieldTypeDescr
249 {
250 };
251
252 } /* namespace internal */
253
254 template <typename LibObjT>
255 class CommonBoolField final : public CommonField<LibObjT>
256 {
257 private:
258 using typename CommonField<LibObjT>::_ThisCommonField;
259
260 public:
261 using typename CommonField<LibObjT>::LibObjPtr;
262 using Value = bool;
263
264 explicit CommonBoolField(const LibObjPtr libObjPtr) noexcept : _ThisCommonField {libObjPtr}
265 {
266 BT_ASSERT_DBG(this->isBool());
267 }
268
269 template <typename OtherLibObjT>
270 CommonBoolField(const CommonBoolField<OtherLibObjT> val) noexcept : _ThisCommonField {val}
271 {
272 }
273
274 template <typename OtherLibObjT>
275 CommonBoolField<LibObjT> operator=(const CommonBoolField<OtherLibObjT> val) noexcept
276 {
277 _ThisCommonField::operator=(val);
278 return *this;
279 }
280
281 CommonBoolField<const bt_field> asConst() const noexcept
282 {
283 return CommonBoolField<const bt_field> {*this};
284 }
285
286 RawValueProxy<CommonBoolField> operator*() const noexcept
287 {
288 return RawValueProxy<CommonBoolField> {*this};
289 }
290
291 void value(const Value val) const noexcept
292 {
293 static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstBoolField`.");
294
295 bt_field_bool_set_value(this->libObjPtr(), static_cast<bt_bool>(val));
296 }
297
298 Value value() const noexcept
299 {
300 return static_cast<Value>(bt_field_bool_get_value(this->libObjPtr()));
301 }
302 };
303
304 using BoolField = CommonBoolField<bt_field>;
305 using ConstBoolField = CommonBoolField<const bt_field>;
306
307 namespace internal {
308
309 struct BoolFieldTypeDescr
310 {
311 using Const = ConstBoolField;
312 using NonConst = BoolField;
313 };
314
315 template <>
316 struct TypeDescr<BoolField> : public BoolFieldTypeDescr
317 {
318 };
319
320 template <>
321 struct TypeDescr<ConstBoolField> : public BoolFieldTypeDescr
322 {
323 };
324
325 } /* namespace internal */
326
327 template <typename LibObjT>
328 class CommonBitArrayField final : public CommonField<LibObjT>
329 {
330 private:
331 using typename CommonField<LibObjT>::_ThisCommonField;
332
333 public:
334 using typename CommonField<LibObjT>::LibObjPtr;
335 using Class = internal::DepType<LibObjT, BitArrayFieldClass, ConstBitArrayFieldClass>;
336
337 explicit CommonBitArrayField(const LibObjPtr libObjPtr) noexcept : _ThisCommonField {libObjPtr}
338 {
339 BT_ASSERT_DBG(this->isBitArray());
340 }
341
342 template <typename OtherLibObjT>
343 CommonBitArrayField(const CommonBitArrayField<OtherLibObjT> val) noexcept :
344 _ThisCommonField {val}
345 {
346 }
347
348 template <typename OtherLibObjT>
349 CommonBitArrayField<LibObjT> operator=(const CommonBitArrayField<OtherLibObjT> val) noexcept
350 {
351 _ThisCommonField::operator=(val);
352 return *this;
353 }
354
355 CommonBitArrayField<const bt_field> asConst() const noexcept
356 {
357 return CommonBitArrayField<const bt_field> {*this};
358 }
359
360 ConstBitArrayFieldClass cls() const noexcept
361 {
362 return ConstBitArrayFieldClass {
363 internal::CommonFieldSpec<const bt_field>::cls(this->libObjPtr())};
364 }
365
366 Class cls() noexcept
367 {
368 return Class {internal::CommonFieldSpec<LibObjT>::cls(this->libObjPtr())};
369 }
370
371 void valueAsInteger(const std::uint64_t bits) const noexcept
372 {
373 static_assert(!std::is_const<LibObjT>::value,
374 "Not available with `bt2::ConstBitArrayField`.");
375
376 bt_field_bit_array_set_value_as_integer(this->libObjPtr(), bits);
377 }
378
379 std::uint64_t valueAsInteger() const noexcept
380 {
381 return bt_field_bit_array_get_value_as_integer(this->libObjPtr());
382 }
383
384 bool bitValue(const std::uint64_t index) const noexcept
385 {
386 BT_ASSERT_DBG(index < this->cls().length());
387 return static_cast<bool>(this->valueAsInteger() & (1ULL << index));
388 }
389 };
390
391 using BitArrayField = CommonBitArrayField<bt_field>;
392 using ConstBitArrayField = CommonBitArrayField<const bt_field>;
393
394 namespace internal {
395
396 struct BitArrayFieldTypeDescr
397 {
398 using Const = ConstBitArrayField;
399 using NonConst = BitArrayField;
400 };
401
402 template <>
403 struct TypeDescr<BitArrayField> : public BitArrayFieldTypeDescr
404 {
405 };
406
407 template <>
408 struct TypeDescr<ConstBitArrayField> : public BitArrayFieldTypeDescr
409 {
410 };
411
412 } /* namespace internal */
413
414 template <typename LibObjT>
415 class CommonUnsignedIntegerField : public CommonField<LibObjT>
416 {
417 private:
418 using typename CommonField<LibObjT>::_ThisCommonField;
419
420 protected:
421 using _ThisCommonUnsignedIntegerField = CommonUnsignedIntegerField<LibObjT>;
422
423 public:
424 using typename CommonField<LibObjT>::LibObjPtr;
425 using Value = std::uint64_t;
426 using Class = internal::DepType<LibObjT, IntegerFieldClass, ConstIntegerFieldClass>;
427
428 explicit CommonUnsignedIntegerField(const LibObjPtr libObjPtr) noexcept :
429 _ThisCommonField {libObjPtr}
430 {
431 BT_ASSERT_DBG(this->isUnsignedInteger());
432 }
433
434 template <typename OtherLibObjT>
435 CommonUnsignedIntegerField(const CommonUnsignedIntegerField<OtherLibObjT> val) noexcept :
436 _ThisCommonField {val}
437 {
438 }
439
440 template <typename OtherLibObjT>
441 _ThisCommonUnsignedIntegerField
442 operator=(const CommonUnsignedIntegerField<OtherLibObjT> val) noexcept
443 {
444 _ThisCommonField::operator=(val);
445 return *this;
446 }
447
448 CommonUnsignedIntegerField<const bt_field> asConst() const noexcept
449 {
450 return CommonUnsignedIntegerField<const bt_field> {*this};
451 }
452
453 Class cls() const noexcept
454 {
455 return Class {internal::CommonFieldSpec<LibObjT>::cls(this->libObjPtr())};
456 }
457
458 RawValueProxy<CommonUnsignedIntegerField> operator*() const noexcept
459 {
460 return RawValueProxy<CommonUnsignedIntegerField> {*this};
461 }
462
463 void value(const Value val) const noexcept
464 {
465 static_assert(!std::is_const<LibObjT>::value,
466 "Not available with `bt2::ConstUnsignedIntegerField`.");
467
468 bt_field_integer_unsigned_set_value(this->libObjPtr(), val);
469 }
470
471 Value value() const noexcept
472 {
473 return bt_field_integer_unsigned_get_value(this->libObjPtr());
474 }
475 };
476
477 using UnsignedIntegerField = CommonUnsignedIntegerField<bt_field>;
478 using ConstUnsignedIntegerField = CommonUnsignedIntegerField<const bt_field>;
479
480 namespace internal {
481
482 struct UnsignedIntegerFieldTypeDescr
483 {
484 using Const = ConstUnsignedIntegerField;
485 using NonConst = UnsignedIntegerField;
486 };
487
488 template <>
489 struct TypeDescr<UnsignedIntegerField> : public UnsignedIntegerFieldTypeDescr
490 {
491 };
492
493 template <>
494 struct TypeDescr<ConstUnsignedIntegerField> : public UnsignedIntegerFieldTypeDescr
495 {
496 };
497
498 } /* namespace internal */
499
500 template <typename LibObjT>
501 class CommonSignedIntegerField : public CommonField<LibObjT>
502 {
503 private:
504 using typename CommonField<LibObjT>::_ThisCommonField;
505
506 protected:
507 using _ThisCommonSignedIntegerField = CommonSignedIntegerField<LibObjT>;
508
509 public:
510 using typename CommonField<LibObjT>::LibObjPtr;
511 using Value = std::int64_t;
512 using Class = internal::DepType<LibObjT, IntegerFieldClass, ConstIntegerFieldClass>;
513
514 explicit CommonSignedIntegerField(const LibObjPtr libObjPtr) noexcept :
515 _ThisCommonField {libObjPtr}
516 {
517 BT_ASSERT_DBG(this->isSignedInteger());
518 }
519
520 template <typename OtherLibObjT>
521 CommonSignedIntegerField(const CommonSignedIntegerField<OtherLibObjT> val) noexcept :
522 _ThisCommonField {val}
523 {
524 }
525
526 template <typename OtherLibObjT>
527 _ThisCommonSignedIntegerField
528 operator=(const CommonSignedIntegerField<OtherLibObjT> val) noexcept
529 {
530 _ThisCommonField::operator=(val);
531 return *this;
532 }
533
534 CommonSignedIntegerField<const bt_field> asConst() const noexcept
535 {
536 return CommonSignedIntegerField<const bt_field> {*this};
537 }
538
539 Class cls() const noexcept
540 {
541 return Class {internal::CommonFieldSpec<LibObjT>::cls(this->libObjPtr())};
542 }
543
544 RawValueProxy<CommonSignedIntegerField> operator*() const noexcept
545 {
546 return RawValueProxy<CommonSignedIntegerField> {*this};
547 }
548
549 void value(const Value val) const noexcept
550 {
551 static_assert(!std::is_const<LibObjT>::value,
552 "Not available with `bt2::ConstSignedIntegerField`.");
553
554 bt_field_integer_signed_set_value(this->libObjPtr(), val);
555 }
556
557 Value value() const noexcept
558 {
559 return bt_field_integer_signed_get_value(this->libObjPtr());
560 }
561 };
562
563 using SignedIntegerField = CommonSignedIntegerField<bt_field>;
564 using ConstSignedIntegerField = CommonSignedIntegerField<const bt_field>;
565
566 namespace internal {
567
568 struct SignedIntegerFieldTypeDescr
569 {
570 using Const = ConstSignedIntegerField;
571 using NonConst = SignedIntegerField;
572 };
573
574 template <>
575 struct TypeDescr<SignedIntegerField> : public SignedIntegerFieldTypeDescr
576 {
577 };
578
579 template <>
580 struct TypeDescr<ConstSignedIntegerField> : public SignedIntegerFieldTypeDescr
581 {
582 };
583
584 } /* namespace internal */
585
586 class EnumerationFieldClassMappingLabels
587 {
588 public:
589 explicit EnumerationFieldClassMappingLabels(
590 const bt_field_class_enumeration_mapping_label_array labels, const std::uint64_t size) :
591 _mLabels {labels},
592 _mLen {size}
593 {
594 }
595
596 std::uint64_t length() const noexcept
597 {
598 return _mLen;
599 }
600
601 bt2c::CStringView operator[](const std::uint64_t index) const noexcept
602 {
603 return _mLabels[index];
604 }
605
606 private:
607 bt_field_class_enumeration_mapping_label_array _mLabels;
608 std::uint64_t _mLen;
609 };
610
611 template <typename LibObjT>
612 class CommonUnsignedEnumerationField final : public CommonUnsignedIntegerField<LibObjT>
613 {
614 private:
615 using typename CommonUnsignedIntegerField<LibObjT>::_ThisCommonUnsignedIntegerField;
616
617 public:
618 using typename CommonField<LibObjT>::LibObjPtr;
619
620 using Class = internal::DepType<LibObjT, UnsignedEnumerationFieldClass,
621 ConstUnsignedEnumerationFieldClass>;
622
623 explicit CommonUnsignedEnumerationField(const LibObjPtr libObjPtr) noexcept :
624 _ThisCommonUnsignedIntegerField {libObjPtr}
625 {
626 BT_ASSERT_DBG(this->isUnsignedEnumeration());
627 }
628
629 template <typename OtherLibObjT>
630 CommonUnsignedEnumerationField(const CommonUnsignedEnumerationField<OtherLibObjT> val) noexcept
631 :
632 _ThisCommonUnsignedIntegerField {val}
633 {
634 }
635
636 template <typename OtherLibObjT>
637 CommonUnsignedEnumerationField<LibObjT>
638 operator=(const CommonUnsignedEnumerationField<OtherLibObjT> val) noexcept
639 {
640 _ThisCommonUnsignedIntegerField::operator=(val);
641 return *this;
642 }
643
644 CommonUnsignedEnumerationField<const bt_field> asConst() const noexcept
645 {
646 return CommonUnsignedEnumerationField<const bt_field> {*this};
647 }
648
649 Class cls() const noexcept
650 {
651 return Class {internal::CommonFieldSpec<LibObjT>::cls(this->libObjPtr())};
652 }
653
654 EnumerationFieldClassMappingLabels labels() const
655 {
656 bt_field_class_enumeration_mapping_label_array labelArray;
657 std::uint64_t count;
658 const auto status = bt_field_enumeration_unsigned_get_mapping_labels(this->libObjPtr(),
659 &labelArray, &count);
660
661 if (status == BT_FIELD_ENUMERATION_GET_MAPPING_LABELS_STATUS_MEMORY_ERROR) {
662 throw MemoryError {};
663 }
664
665 return EnumerationFieldClassMappingLabels {labelArray, count};
666 }
667 };
668
669 using UnsignedEnumerationField = CommonUnsignedEnumerationField<bt_field>;
670 using ConstUnsignedEnumerationField = CommonUnsignedEnumerationField<const bt_field>;
671
672 namespace internal {
673
674 struct UnsignedEnumerationFieldTypeDescr
675 {
676 using Const = ConstUnsignedEnumerationField;
677 using NonConst = UnsignedEnumerationField;
678 };
679
680 template <>
681 struct TypeDescr<UnsignedEnumerationField> : public UnsignedEnumerationFieldTypeDescr
682 {
683 };
684
685 template <>
686 struct TypeDescr<ConstUnsignedEnumerationField> : public UnsignedEnumerationFieldTypeDescr
687 {
688 };
689
690 } /* namespace internal */
691
692 template <typename LibObjT>
693 class CommonSignedEnumerationField final : public CommonSignedIntegerField<LibObjT>
694 {
695 private:
696 using typename CommonSignedIntegerField<LibObjT>::_ThisCommonSignedIntegerField;
697
698 public:
699 using typename CommonField<LibObjT>::LibObjPtr;
700
701 using Class =
702 internal::DepType<LibObjT, SignedEnumerationFieldClass, ConstSignedEnumerationFieldClass>;
703
704 explicit CommonSignedEnumerationField(const LibObjPtr libObjPtr) noexcept :
705 _ThisCommonSignedIntegerField {libObjPtr}
706 {
707 BT_ASSERT_DBG(this->isSignedEnumeration());
708 }
709
710 template <typename OtherLibObjT>
711 CommonSignedEnumerationField(const CommonSignedEnumerationField<OtherLibObjT> val) noexcept :
712 _ThisCommonSignedIntegerField {val}
713 {
714 }
715
716 template <typename OtherLibObjT>
717 CommonSignedEnumerationField<LibObjT>
718 operator=(const CommonSignedEnumerationField<OtherLibObjT> val) noexcept
719 {
720 _ThisCommonSignedIntegerField::operator=(val);
721 return *this;
722 }
723
724 CommonSignedEnumerationField<const bt_field> asConst() const noexcept
725 {
726 return CommonSignedEnumerationField<const bt_field> {*this};
727 }
728
729 Class cls() const noexcept
730 {
731 return Class {internal::CommonFieldSpec<LibObjT>::cls(this->libObjPtr())};
732 }
733
734 EnumerationFieldClassMappingLabels labels() const
735 {
736 bt_field_class_enumeration_mapping_label_array labelArray;
737 std::uint64_t count;
738 const auto status =
739 bt_field_enumeration_signed_get_mapping_labels(this->libObjPtr(), &labelArray, &count);
740
741 if (status == BT_FIELD_ENUMERATION_GET_MAPPING_LABELS_STATUS_MEMORY_ERROR) {
742 throw MemoryError {};
743 }
744
745 return EnumerationFieldClassMappingLabels {labelArray, count};
746 }
747 };
748
749 using SignedEnumerationField = CommonSignedEnumerationField<bt_field>;
750 using ConstSignedEnumerationField = CommonSignedEnumerationField<const bt_field>;
751
752 namespace internal {
753
754 struct SignedEnumerationFieldTypeDescr
755 {
756 using Const = ConstSignedEnumerationField;
757 using NonConst = SignedEnumerationField;
758 };
759
760 template <>
761 struct TypeDescr<SignedEnumerationField> : public SignedEnumerationFieldTypeDescr
762 {
763 };
764
765 template <>
766 struct TypeDescr<ConstSignedEnumerationField> : public SignedEnumerationFieldTypeDescr
767 {
768 };
769
770 } /* namespace internal */
771
772 template <typename LibObjT>
773 class CommonSinglePrecisionRealField final : public CommonField<LibObjT>
774 {
775 private:
776 using typename CommonField<LibObjT>::_ThisCommonField;
777
778 public:
779 using typename CommonField<LibObjT>::LibObjPtr;
780 using Value = float;
781
782 explicit CommonSinglePrecisionRealField(const LibObjPtr libObjPtr) noexcept :
783 _ThisCommonField {libObjPtr}
784 {
785 BT_ASSERT_DBG(this->isSinglePrecisionReal());
786 }
787
788 template <typename OtherLibObjT>
789 CommonSinglePrecisionRealField(const CommonSinglePrecisionRealField<OtherLibObjT> val) noexcept
790 :
791 _ThisCommonField {val}
792 {
793 }
794
795 template <typename OtherLibObjT>
796 CommonSinglePrecisionRealField<LibObjT>
797 operator=(const CommonSinglePrecisionRealField<OtherLibObjT> val) noexcept
798 {
799 _ThisCommonField::operator=(val);
800 return *this;
801 }
802
803 CommonSinglePrecisionRealField<const bt_field> asConst() const noexcept
804 {
805 return CommonSinglePrecisionRealField<const bt_field> {*this};
806 }
807
808 RawValueProxy<CommonSinglePrecisionRealField> operator*() const noexcept
809 {
810 return RawValueProxy<CommonSinglePrecisionRealField> {*this};
811 }
812
813 void value(const Value val) const noexcept
814 {
815 static_assert(!std::is_const<LibObjT>::value,
816 "Not available with `bt2::ConstSinglePrecisionRealField`.");
817
818 bt_field_real_single_precision_set_value(this->libObjPtr(), val);
819 }
820
821 Value value() const noexcept
822 {
823 return bt_field_real_single_precision_get_value(this->libObjPtr());
824 }
825 };
826
827 using SinglePrecisionRealField = CommonSinglePrecisionRealField<bt_field>;
828 using ConstSinglePrecisionRealField = CommonSinglePrecisionRealField<const bt_field>;
829
830 namespace internal {
831
832 struct SinglePrecisionRealFieldTypeDescr
833 {
834 using Const = ConstSinglePrecisionRealField;
835 using NonConst = SinglePrecisionRealField;
836 };
837
838 template <>
839 struct TypeDescr<SinglePrecisionRealField> : public SinglePrecisionRealFieldTypeDescr
840 {
841 };
842
843 template <>
844 struct TypeDescr<ConstSinglePrecisionRealField> : public SinglePrecisionRealFieldTypeDescr
845 {
846 };
847
848 } /* namespace internal */
849
850 template <typename LibObjT>
851 class CommonDoublePrecisionRealField final : public CommonField<LibObjT>
852 {
853 private:
854 using typename CommonField<LibObjT>::_ThisCommonField;
855
856 public:
857 using typename CommonField<LibObjT>::LibObjPtr;
858 using Value = double;
859
860 explicit CommonDoublePrecisionRealField(const LibObjPtr libObjPtr) noexcept :
861 _ThisCommonField {libObjPtr}
862 {
863 BT_ASSERT_DBG(this->isDoublePrecisionReal());
864 }
865
866 template <typename OtherLibObjT>
867 CommonDoublePrecisionRealField(const CommonDoublePrecisionRealField<OtherLibObjT> val) noexcept
868 :
869 _ThisCommonField {val}
870 {
871 }
872
873 template <typename OtherLibObjT>
874 CommonDoublePrecisionRealField<LibObjT>
875 operator=(const CommonDoublePrecisionRealField<OtherLibObjT> val) noexcept
876 {
877 _ThisCommonField::operator=(val);
878 return *this;
879 }
880
881 CommonDoublePrecisionRealField<const bt_field> asConst() const noexcept
882 {
883 return CommonDoublePrecisionRealField<const bt_field> {*this};
884 }
885
886 RawValueProxy<CommonDoublePrecisionRealField> operator*() const noexcept
887 {
888 return RawValueProxy<CommonDoublePrecisionRealField> {*this};
889 }
890
891 void value(const Value val) const noexcept
892 {
893 static_assert(!std::is_const<LibObjT>::value,
894 "Not available with `bt2::ConstDoublePrecisionRealField`.");
895
896 bt_field_real_double_precision_set_value(this->libObjPtr(), val);
897 }
898
899 Value value() const noexcept
900 {
901 return bt_field_real_double_precision_get_value(this->libObjPtr());
902 }
903 };
904
905 using DoublePrecisionRealField = CommonDoublePrecisionRealField<bt_field>;
906 using ConstDoublePrecisionRealField = CommonDoublePrecisionRealField<const bt_field>;
907
908 namespace internal {
909
910 struct DoublePrecisionRealFieldTypeDescr
911 {
912 using Const = ConstDoublePrecisionRealField;
913 using NonConst = DoublePrecisionRealField;
914 };
915
916 template <>
917 struct TypeDescr<DoublePrecisionRealField> : public DoublePrecisionRealFieldTypeDescr
918 {
919 };
920
921 template <>
922 struct TypeDescr<ConstDoublePrecisionRealField> : public DoublePrecisionRealFieldTypeDescr
923 {
924 };
925
926 } /* namespace internal */
927
928 template <typename LibObjT>
929 class CommonStringField final : public CommonField<LibObjT>
930 {
931 private:
932 using typename CommonField<LibObjT>::_ThisCommonField;
933
934 public:
935 using typename CommonField<LibObjT>::LibObjPtr;
936 using Value = bt2c::CStringView;
937
938 explicit CommonStringField(const LibObjPtr libObjPtr) noexcept : _ThisCommonField {libObjPtr}
939 {
940 BT_ASSERT_DBG(this->isString());
941 }
942
943 template <typename OtherLibObjT>
944 CommonStringField(const CommonStringField<OtherLibObjT> val) noexcept : _ThisCommonField {val}
945 {
946 }
947
948 template <typename OtherLibObjT>
949 CommonStringField<LibObjT> operator=(const CommonStringField<OtherLibObjT> val) noexcept
950 {
951 _ThisCommonField::operator=(val);
952 return *this;
953 }
954
955 CommonStringField<const bt_field> asConst() const noexcept
956 {
957 return CommonStringField<const bt_field> {*this};
958 }
959
960 RawValueProxy<CommonStringField> operator*() const noexcept
961 {
962 return RawValueProxy<CommonStringField> {*this};
963 }
964
965 void value(const Value val) const
966 {
967 static_assert(!std::is_const<LibObjT>::value,
968 "Not available with `bt2::ConstStringField`.");
969
970 const auto status = bt_field_string_set_value(this->libObjPtr(), *val);
971
972 if (status == BT_FIELD_STRING_SET_VALUE_STATUS_MEMORY_ERROR) {
973 throw MemoryError {};
974 }
975 }
976
977 void append(const bt2c::CStringView begin, const std::uint64_t len) const
978 {
979 static_assert(!std::is_const<LibObjT>::value,
980 "Not available with `bt2::ConstStringField`.");
981
982 const auto status = bt_field_string_append_with_length(this->libObjPtr(), begin, len);
983
984 if (status == BT_FIELD_STRING_APPEND_STATUS_MEMORY_ERROR) {
985 throw MemoryError {};
986 }
987 }
988
989 void append(const bt2c::CStringView val) const
990 {
991 this->append(val, std::strlen(val));
992 }
993
994 void append(const std::string& val) const
995 {
996 this->append(val.data(), val.size());
997 }
998
999 void clear() const noexcept
1000 {
1001 static_assert(!std::is_const<LibObjT>::value,
1002 "Not available with `bt2::ConstStringField`.");
1003
1004 bt_field_string_clear(this->libObjPtr());
1005 }
1006
1007 Value value() const noexcept
1008 {
1009 return bt_field_string_get_value(this->libObjPtr());
1010 }
1011
1012 std::uint64_t length() const noexcept
1013 {
1014 return bt_field_string_get_length(this->libObjPtr());
1015 }
1016 };
1017
1018 using StringField = CommonStringField<bt_field>;
1019 using ConstStringField = CommonStringField<const bt_field>;
1020
1021 namespace internal {
1022
1023 struct StringFieldTypeDescr
1024 {
1025 using Const = ConstStringField;
1026 using NonConst = StringField;
1027 };
1028
1029 template <>
1030 struct TypeDescr<StringField> : public StringFieldTypeDescr
1031 {
1032 };
1033
1034 template <>
1035 struct TypeDescr<ConstStringField> : public StringFieldTypeDescr
1036 {
1037 };
1038
1039 template <typename LibObjT>
1040 struct CommonStructureFieldSpec;
1041
1042 /* Functions specific to mutable structure fields */
1043 template <>
1044 struct CommonStructureFieldSpec<bt_field> final
1045 {
1046 static bt_field *memberFieldByIndex(bt_field * const libObjPtr,
1047 const std::uint64_t index) noexcept
1048 {
1049 return bt_field_structure_borrow_member_field_by_index(libObjPtr, index);
1050 }
1051
1052 static bt_field *memberFieldByName(bt_field * const libObjPtr, const char * const name) noexcept
1053 {
1054 return bt_field_structure_borrow_member_field_by_name(libObjPtr, name);
1055 }
1056 };
1057
1058 /* Functions specific to constant structure fields */
1059 template <>
1060 struct CommonStructureFieldSpec<const bt_field> final
1061 {
1062 static const bt_field *memberFieldByIndex(const bt_field * const libObjPtr,
1063 const std::uint64_t index) noexcept
1064 {
1065 return bt_field_structure_borrow_member_field_by_index_const(libObjPtr, index);
1066 }
1067
1068 static const bt_field *memberFieldByName(const bt_field * const libObjPtr,
1069 const char * const name) noexcept
1070 {
1071 return bt_field_structure_borrow_member_field_by_name_const(libObjPtr, name);
1072 }
1073 };
1074
1075 } /* namespace internal */
1076
1077 template <typename LibObjT>
1078 class CommonStructureField final : public CommonField<LibObjT>
1079 {
1080 private:
1081 using typename CommonField<LibObjT>::_ThisCommonField;
1082 using _Spec = internal::CommonStructureFieldSpec<LibObjT>;
1083
1084 public:
1085 using typename CommonField<LibObjT>::LibObjPtr;
1086 using Class = internal::DepType<LibObjT, StructureFieldClass, ConstStructureFieldClass>;
1087
1088 explicit CommonStructureField(const LibObjPtr libObjPtr) noexcept : _ThisCommonField {libObjPtr}
1089 {
1090 BT_ASSERT_DBG(this->isStructure());
1091 }
1092
1093 template <typename OtherLibObjT>
1094 CommonStructureField(const CommonStructureField<OtherLibObjT> val) noexcept :
1095 _ThisCommonField {val}
1096 {
1097 }
1098
1099 template <typename OtherLibObjT>
1100 CommonStructureField<LibObjT> operator=(const CommonStructureField<OtherLibObjT> val) noexcept
1101 {
1102 _ThisCommonField::operator=(val);
1103 return *this;
1104 }
1105
1106 CommonStructureField<const bt_field> asConst() const noexcept
1107 {
1108 return CommonStructureField<const bt_field> {*this};
1109 }
1110
1111 Class cls() const noexcept
1112 {
1113 return Class {internal::CommonFieldSpec<LibObjT>::cls(this->libObjPtr())};
1114 }
1115
1116 std::uint64_t length() const noexcept
1117 {
1118 return this->cls().length();
1119 }
1120
1121 CommonField<LibObjT> operator[](const std::uint64_t index) const noexcept
1122 {
1123 return CommonField<LibObjT> {_Spec::memberFieldByIndex(this->libObjPtr(), index)};
1124 }
1125
1126 OptionalBorrowedObject<CommonField<LibObjT>>
1127 operator[](const bt2c::CStringView name) const noexcept
1128 {
1129 return _Spec::memberFieldByName(this->libObjPtr(), name);
1130 }
1131 };
1132
1133 using StructureField = CommonStructureField<bt_field>;
1134 using ConstStructureField = CommonStructureField<const bt_field>;
1135
1136 namespace internal {
1137
1138 struct StructureFieldTypeDescr
1139 {
1140 using Const = ConstStructureField;
1141 using NonConst = StructureField;
1142 };
1143
1144 template <>
1145 struct TypeDescr<StructureField> : public StructureFieldTypeDescr
1146 {
1147 };
1148
1149 template <>
1150 struct TypeDescr<ConstStructureField> : public StructureFieldTypeDescr
1151 {
1152 };
1153
1154 template <typename LibObjT>
1155 struct CommonArrayFieldSpec;
1156
1157 /* Functions specific to mutable array fields */
1158 template <>
1159 struct CommonArrayFieldSpec<bt_field> final
1160 {
1161 static bt_field *elementFieldByIndex(bt_field * const libObjPtr,
1162 const std::uint64_t index) noexcept
1163 {
1164 return bt_field_array_borrow_element_field_by_index(libObjPtr, index);
1165 }
1166 };
1167
1168 /* Functions specific to constant array fields */
1169 template <>
1170 struct CommonArrayFieldSpec<const bt_field> final
1171 {
1172 static const bt_field *elementFieldByIndex(const bt_field * const libObjPtr,
1173 const std::uint64_t index) noexcept
1174 {
1175 return bt_field_array_borrow_element_field_by_index_const(libObjPtr, index);
1176 }
1177 };
1178
1179 } /* namespace internal */
1180
1181 template <typename LibObjT>
1182 class CommonArrayField : public CommonField<LibObjT>
1183 {
1184 private:
1185 using typename CommonField<LibObjT>::_ThisCommonField;
1186 using _Spec = internal::CommonArrayFieldSpec<LibObjT>;
1187
1188 protected:
1189 using _ThisCommonArrayField = CommonArrayField<LibObjT>;
1190
1191 public:
1192 using typename CommonField<LibObjT>::LibObjPtr;
1193 using Class = internal::DepType<LibObjT, ArrayFieldClass, ConstArrayFieldClass>;
1194
1195 explicit CommonArrayField(const LibObjPtr libObjPtr) noexcept : _ThisCommonField {libObjPtr}
1196 {
1197 BT_ASSERT_DBG(this->isArray());
1198 }
1199
1200 template <typename OtherLibObjT>
1201 CommonArrayField(const CommonArrayField<OtherLibObjT> val) noexcept : _ThisCommonField {val}
1202 {
1203 }
1204
1205 template <typename OtherLibObjT>
1206 _ThisCommonArrayField operator=(const CommonArrayField<OtherLibObjT> val) noexcept
1207 {
1208 _ThisCommonField::operator=(val);
1209 return *this;
1210 }
1211
1212 CommonArrayField<const bt_field> asConst() const noexcept
1213 {
1214 return CommonArrayField<const bt_field> {*this};
1215 }
1216
1217 Class cls() const noexcept
1218 {
1219 return Class {internal::CommonFieldSpec<LibObjT>::cls(this->libObjPtr())};
1220 }
1221
1222 std::uint64_t length() const noexcept
1223 {
1224 return bt_field_array_get_length(this->libObjPtr());
1225 }
1226
1227 CommonField<LibObjT> operator[](const std::uint64_t index) const noexcept
1228 {
1229 return CommonField<LibObjT> {_Spec::elementFieldByIndex(this->libObjPtr(), index)};
1230 }
1231 };
1232
1233 using ArrayField = CommonArrayField<bt_field>;
1234 using ConstArrayField = CommonArrayField<const bt_field>;
1235
1236 namespace internal {
1237
1238 struct ArrayFieldTypeDescr
1239 {
1240 using Const = ConstArrayField;
1241 using NonConst = ArrayField;
1242 };
1243
1244 template <>
1245 struct TypeDescr<ArrayField> : public ArrayFieldTypeDescr
1246 {
1247 };
1248
1249 template <>
1250 struct TypeDescr<ConstArrayField> : public ArrayFieldTypeDescr
1251 {
1252 };
1253
1254 } /* namespace internal */
1255
1256 template <typename LibObjT>
1257 class CommonDynamicArrayField : public CommonArrayField<LibObjT>
1258 {
1259 private:
1260 using typename CommonArrayField<LibObjT>::_ThisCommonArrayField;
1261
1262 public:
1263 using typename CommonField<LibObjT>::LibObjPtr;
1264
1265 explicit CommonDynamicArrayField(const LibObjPtr libObjPtr) noexcept :
1266 _ThisCommonArrayField {libObjPtr}
1267 {
1268 BT_ASSERT_DBG(this->isDynamicArray());
1269 }
1270
1271 template <typename OtherLibObjT>
1272 CommonDynamicArrayField(const CommonDynamicArrayField<OtherLibObjT> val) noexcept :
1273 _ThisCommonArrayField {val}
1274 {
1275 }
1276
1277 template <typename OtherLibObjT>
1278 CommonDynamicArrayField<LibObjT>
1279 operator=(const CommonDynamicArrayField<OtherLibObjT> val) noexcept
1280 {
1281 _ThisCommonArrayField::operator=(val);
1282 return *this;
1283 }
1284
1285 CommonDynamicArrayField<const bt_field> asConst() const noexcept
1286 {
1287 return CommonDynamicArrayField<const bt_field> {*this};
1288 }
1289
1290 std::uint64_t length() const noexcept
1291 {
1292 return _ThisCommonArrayField::length();
1293 }
1294
1295 void length(const std::uint64_t length) const
1296 {
1297 static_assert(!std::is_const<LibObjT>::value,
1298 "Not available with `bt2::ConstDynamicArrayField`.");
1299
1300 const auto status = bt_field_array_dynamic_set_length(this->libObjPtr(), length);
1301
1302 if (status == BT_FIELD_DYNAMIC_ARRAY_SET_LENGTH_STATUS_MEMORY_ERROR) {
1303 throw MemoryError {};
1304 }
1305 }
1306 };
1307
1308 using DynamicArrayField = CommonDynamicArrayField<bt_field>;
1309 using ConstDynamicArrayField = CommonDynamicArrayField<const bt_field>;
1310
1311 namespace internal {
1312
1313 struct DynamicArrayFieldTypeDescr
1314 {
1315 using Const = ConstDynamicArrayField;
1316 using NonConst = DynamicArrayField;
1317 };
1318
1319 template <>
1320 struct TypeDescr<DynamicArrayField> : public DynamicArrayFieldTypeDescr
1321 {
1322 };
1323
1324 template <>
1325 struct TypeDescr<ConstDynamicArrayField> : public DynamicArrayFieldTypeDescr
1326 {
1327 };
1328
1329 template <typename LibObjT>
1330 struct CommonOptionFieldSpec;
1331
1332 /* Functions specific to mutable option fields */
1333 template <>
1334 struct CommonOptionFieldSpec<bt_field> final
1335 {
1336 static bt_field *field(bt_field * const libObjPtr) noexcept
1337 {
1338 return bt_field_option_borrow_field(libObjPtr);
1339 }
1340 };
1341
1342 /* Functions specific to constant option fields */
1343 template <>
1344 struct CommonOptionFieldSpec<const bt_field> final
1345 {
1346 static const bt_field *field(const bt_field * const libObjPtr) noexcept
1347 {
1348 return bt_field_option_borrow_field_const(libObjPtr);
1349 }
1350 };
1351
1352 } /* namespace internal */
1353
1354 template <typename LibObjT>
1355 class CommonOptionField : public CommonField<LibObjT>
1356 {
1357 private:
1358 using typename CommonField<LibObjT>::_ThisCommonField;
1359 using _Spec = internal::CommonOptionFieldSpec<LibObjT>;
1360
1361 public:
1362 using typename CommonField<LibObjT>::LibObjPtr;
1363 using Class = internal::DepType<LibObjT, OptionFieldClass, ConstOptionFieldClass>;
1364
1365 explicit CommonOptionField(const LibObjPtr libObjPtr) noexcept : _ThisCommonField {libObjPtr}
1366 {
1367 BT_ASSERT_DBG(this->isOption());
1368 }
1369
1370 template <typename OtherLibObjT>
1371 CommonOptionField(const CommonOptionField<OtherLibObjT> val) noexcept : _ThisCommonField {val}
1372 {
1373 }
1374
1375 template <typename OtherLibObjT>
1376 CommonOptionField<LibObjT> operator=(const CommonOptionField<OtherLibObjT> val) noexcept
1377 {
1378 _ThisCommonField::operator=(val);
1379 return *this;
1380 }
1381
1382 CommonOptionField<const bt_field> asConst() const noexcept
1383 {
1384 return CommonOptionField<const bt_field> {*this};
1385 }
1386
1387 Class cls() const noexcept
1388 {
1389 return Class {internal::CommonFieldSpec<LibObjT>::cls(this->libObjPtr())};
1390 }
1391
1392 void hasField(const bool hasField) const noexcept
1393 {
1394 static_assert(!std::is_const<LibObjT>::value,
1395 "Not available with `bt2::ConstOptionField`.");
1396
1397 bt_field_option_set_has_field(this->libObjPtr(), static_cast<bt_bool>(hasField));
1398 }
1399
1400 bool hasField() const noexcept
1401 {
1402 return this->field();
1403 }
1404
1405 OptionalBorrowedObject<CommonField<LibObjT>> field() const noexcept
1406 {
1407 return _Spec::field(this->libObjPtr());
1408 }
1409 };
1410
1411 using OptionField = CommonOptionField<bt_field>;
1412 using ConstOptionField = CommonOptionField<const bt_field>;
1413
1414 namespace internal {
1415
1416 struct OptionFieldTypeDescr
1417 {
1418 using Const = ConstOptionField;
1419 using NonConst = OptionField;
1420 };
1421
1422 template <>
1423 struct TypeDescr<OptionField> : public OptionFieldTypeDescr
1424 {
1425 };
1426
1427 template <>
1428 struct TypeDescr<ConstOptionField> : public OptionFieldTypeDescr
1429 {
1430 };
1431
1432 template <typename LibObjT>
1433 struct CommonVariantFieldSpec;
1434
1435 /* Functions specific to mutable variant fields */
1436 template <>
1437 struct CommonVariantFieldSpec<bt_field> final
1438 {
1439 static bt_field *selectedOptionField(bt_field * const libObjPtr) noexcept
1440 {
1441 return bt_field_variant_borrow_selected_option_field(libObjPtr);
1442 }
1443 };
1444
1445 /* Functions specific to constant variant fields */
1446 template <>
1447 struct CommonVariantFieldSpec<const bt_field> final
1448 {
1449 static const bt_field *selectedOptionField(const bt_field * const libObjPtr) noexcept
1450 {
1451 return bt_field_variant_borrow_selected_option_field_const(libObjPtr);
1452 }
1453 };
1454
1455 } /* namespace internal */
1456
1457 template <typename LibObjT>
1458 class CommonVariantField : public CommonField<LibObjT>
1459 {
1460 private:
1461 using typename CommonField<LibObjT>::_ThisCommonField;
1462 using _Spec = internal::CommonVariantFieldSpec<LibObjT>;
1463
1464 public:
1465 using typename CommonField<LibObjT>::LibObjPtr;
1466 using Class = internal::DepType<LibObjT, VariantFieldClass, ConstVariantFieldClass>;
1467
1468 explicit CommonVariantField(const LibObjPtr libObjPtr) noexcept : _ThisCommonField {libObjPtr}
1469 {
1470 BT_ASSERT_DBG(this->isVariant());
1471 }
1472
1473 template <typename OtherLibObjT>
1474 CommonVariantField(const CommonVariantField<OtherLibObjT> val) noexcept : _ThisCommonField {val}
1475 {
1476 }
1477
1478 template <typename OtherLibObjT>
1479 CommonVariantField<LibObjT> operator=(const CommonVariantField<OtherLibObjT> val) noexcept
1480 {
1481 _ThisCommonField::operator=(val);
1482 return *this;
1483 }
1484
1485 CommonVariantField<const bt_field> asConst() const noexcept
1486 {
1487 return CommonVariantField<const bt_field> {*this};
1488 }
1489
1490 Class cls() const noexcept
1491 {
1492 return Class {internal::CommonFieldSpec<LibObjT>::cls(this->libObjPtr())};
1493 }
1494
1495 void selectOption(const std::uint64_t index) const noexcept
1496 {
1497 static_assert(!std::is_const<LibObjT>::value,
1498 "Not available with `bt2::ConstVariantField`.");
1499
1500 static_cast<void>(bt_field_variant_select_option_by_index(this->libObjPtr(), index));
1501 }
1502
1503 CommonField<LibObjT> selectedOptionField() const noexcept
1504 {
1505 return CommonField<LibObjT> {_Spec::selectedOptionField(this->libObjPtr())};
1506 }
1507
1508 std::uint64_t selectedOptionIndex() const noexcept
1509 {
1510 return bt_field_variant_get_selected_option_index(this->libObjPtr());
1511 }
1512 };
1513
1514 using VariantField = CommonVariantField<bt_field>;
1515 using ConstVariantField = CommonVariantField<const bt_field>;
1516
1517 namespace internal {
1518
1519 struct VariantFieldTypeDescr
1520 {
1521 using Const = ConstVariantField;
1522 using NonConst = VariantField;
1523 };
1524
1525 template <>
1526 struct TypeDescr<VariantField> : public VariantFieldTypeDescr
1527 {
1528 };
1529
1530 template <>
1531 struct TypeDescr<ConstVariantField> : public VariantFieldTypeDescr
1532 {
1533 };
1534
1535 } /* namespace internal */
1536
1537 template <typename LibObjT>
1538 CommonBoolField<LibObjT> CommonField<LibObjT>::asBool() const noexcept
1539 {
1540 return CommonBoolField<LibObjT> {this->libObjPtr()};
1541 }
1542
1543 template <typename LibObjT>
1544 CommonBitArrayField<LibObjT> CommonField<LibObjT>::asBitArray() const noexcept
1545 {
1546 return CommonBitArrayField<LibObjT> {this->libObjPtr()};
1547 }
1548
1549 template <typename LibObjT>
1550 CommonUnsignedIntegerField<LibObjT> CommonField<LibObjT>::asUnsignedInteger() const noexcept
1551 {
1552 return CommonUnsignedIntegerField<LibObjT> {this->libObjPtr()};
1553 }
1554
1555 template <typename LibObjT>
1556 CommonSignedIntegerField<LibObjT> CommonField<LibObjT>::asSignedInteger() const noexcept
1557 {
1558 return CommonSignedIntegerField<LibObjT> {this->libObjPtr()};
1559 }
1560
1561 template <typename LibObjT>
1562 CommonUnsignedEnumerationField<LibObjT> CommonField<LibObjT>::asUnsignedEnumeration() const noexcept
1563 {
1564 return CommonUnsignedEnumerationField<LibObjT> {this->libObjPtr()};
1565 }
1566
1567 template <typename LibObjT>
1568 CommonSignedEnumerationField<LibObjT> CommonField<LibObjT>::asSignedEnumeration() const noexcept
1569 {
1570 return CommonSignedEnumerationField<LibObjT> {this->libObjPtr()};
1571 }
1572
1573 template <typename LibObjT>
1574 CommonSinglePrecisionRealField<LibObjT> CommonField<LibObjT>::asSinglePrecisionReal() const noexcept
1575 {
1576 return CommonSinglePrecisionRealField<LibObjT> {this->libObjPtr()};
1577 }
1578
1579 template <typename LibObjT>
1580 CommonDoublePrecisionRealField<LibObjT> CommonField<LibObjT>::asDoublePrecisionReal() const noexcept
1581 {
1582 return CommonDoublePrecisionRealField<LibObjT> {this->libObjPtr()};
1583 }
1584
1585 template <typename LibObjT>
1586 CommonStringField<LibObjT> CommonField<LibObjT>::asString() const noexcept
1587 {
1588 return CommonStringField<LibObjT> {this->libObjPtr()};
1589 }
1590
1591 template <typename LibObjT>
1592 CommonStructureField<LibObjT> CommonField<LibObjT>::asStructure() const noexcept
1593 {
1594 return CommonStructureField<LibObjT> {this->libObjPtr()};
1595 }
1596
1597 template <typename LibObjT>
1598 CommonArrayField<LibObjT> CommonField<LibObjT>::asArray() const noexcept
1599 {
1600 return CommonArrayField<LibObjT> {this->libObjPtr()};
1601 }
1602
1603 template <typename LibObjT>
1604 CommonDynamicArrayField<LibObjT> CommonField<LibObjT>::asDynamicArray() const noexcept
1605 {
1606 return CommonDynamicArrayField<LibObjT> {this->libObjPtr()};
1607 }
1608
1609 template <typename LibObjT>
1610 CommonOptionField<LibObjT> CommonField<LibObjT>::asOption() const noexcept
1611 {
1612 return CommonOptionField<LibObjT> {this->libObjPtr()};
1613 }
1614
1615 template <typename LibObjT>
1616 CommonVariantField<LibObjT> CommonField<LibObjT>::asVariant() const noexcept
1617 {
1618 return CommonVariantField<LibObjT> {this->libObjPtr()};
1619 }
1620
1621 } /* namespace bt2 */
1622
1623 #endif /* BABELTRACE_CPP_COMMON_BT2_FIELD_HPP */
This page took 0.06125 seconds and 3 git commands to generate.