X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fcpp-common%2Fbt2%2Ffield.hpp;fp=src%2Fcpp-common%2Fbt2%2Ffield.hpp;h=241c17764b20ef4f3edca63410c16af49c91922b;hb=dcb8ae9be121cdae6f6d16757d2233d705df057d;hp=509e66d2f63abc81e5b05c009df502793192dc49;hpb=c677c492013b15993843ac26e5210a544f64ba90;p=babeltrace.git diff --git a/src/cpp-common/bt2/field.hpp b/src/cpp-common/bt2/field.hpp index 509e66d2..241c1776 100644 --- a/src/cpp-common/bt2/field.hpp +++ b/src/cpp-common/bt2/field.hpp @@ -126,12 +126,7 @@ public: return static_cast(bt_field_get_class_type(this->libObjPtr())); } - ConstFieldClass cls() const noexcept - { - return ConstFieldClass {internal::CommonFieldSpec::cls(this->libObjPtr())}; - } - - Class cls() noexcept + Class cls() const noexcept { return Class {internal::CommonFieldSpec::cls(this->libObjPtr())}; } @@ -278,7 +273,7 @@ public: return *this; } - CommonBoolField& operator=(const Value val) noexcept + CommonBoolField operator=(const Value val) const noexcept { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); @@ -360,7 +355,7 @@ public: return Class {internal::CommonFieldSpec::cls(this->libObjPtr())}; } - CommonBitArrayField& operator=(const std::uint64_t bits) noexcept + CommonBitArrayField operator=(const std::uint64_t bits) const noexcept { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); @@ -439,18 +434,12 @@ public: return *this; } - ConstIntegerFieldClass cls() const noexcept - { - return ConstIntegerFieldClass { - internal::CommonFieldSpec::cls(this->libObjPtr())}; - } - - Class cls() noexcept + Class cls() const noexcept { return Class {internal::CommonFieldSpec::cls(this->libObjPtr())}; } - CommonUnsignedIntegerField& operator=(const Value val) noexcept + CommonUnsignedIntegerField operator=(const Value val) const noexcept { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); @@ -528,18 +517,12 @@ public: return *this; } - ConstIntegerFieldClass cls() const noexcept - { - return ConstIntegerFieldClass { - internal::CommonFieldSpec::cls(this->libObjPtr())}; - } - - Class cls() noexcept + Class cls() const noexcept { return Class {internal::CommonFieldSpec::cls(this->libObjPtr())}; } - CommonSignedIntegerField& operator=(const Value val) noexcept + CommonSignedIntegerField operator=(const Value val) const noexcept { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); @@ -645,15 +628,9 @@ public: return *this; } - ConstUnsignedEnumerationFieldClass cls() const noexcept - { - return ConstUnsignedEnumerationFieldClass { - internal::CommonFieldSpec::cls(this->libObjPtr())}; - } - using CommonUnsignedIntegerField::operator=; - Class cls() noexcept + Class cls() const noexcept { return Class {internal::CommonFieldSpec::cls(this->libObjPtr())}; } @@ -730,13 +707,7 @@ public: using CommonSignedIntegerField::operator=; - ConstSignedEnumerationFieldClass cls() const noexcept - { - return ConstSignedEnumerationFieldClass { - internal::CommonFieldSpec::cls(this->libObjPtr())}; - } - - Class cls() noexcept + Class cls() const noexcept { return Class {internal::CommonFieldSpec::cls(this->libObjPtr())}; } @@ -810,7 +781,7 @@ public: return *this; } - CommonSinglePrecisionRealField& operator=(const Value val) noexcept + CommonSinglePrecisionRealField operator=(const Value val) const noexcept { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); @@ -883,7 +854,7 @@ public: return *this; } - CommonDoublePrecisionRealField& operator=(const Value val) noexcept + CommonDoublePrecisionRealField operator=(const Value val) const noexcept { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); @@ -950,7 +921,7 @@ public: return *this; } - CommonStringField& operator=(const char * const val) + CommonStringField operator=(const char * const val) const { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); @@ -963,12 +934,12 @@ public: return *this; } - CommonStringField& operator=(const std::string& val) + CommonStringField operator=(const std::string& val) const { return *this = val.data(); } - void append(const char * const begin, const std::uint64_t len) + void append(const char * const begin, const std::uint64_t len) const { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); @@ -979,12 +950,12 @@ public: } } - void append(const std::string& val) + void append(const std::string& val) const { this->append(val.data(), val.size()); } - void clear() noexcept + void clear() const noexcept { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); @@ -1087,13 +1058,7 @@ public: return *this; } - ConstStructureFieldClass cls() const noexcept - { - return ConstStructureFieldClass { - internal::CommonFieldSpec::cls(this->libObjPtr())}; - } - - Class cls() noexcept + Class cls() const noexcept { return Class {internal::CommonFieldSpec::cls(this->libObjPtr())}; } @@ -1103,36 +1068,12 @@ public: return this->cls().size(); } - ConstField operator[](const std::uint64_t index) const noexcept - { - return ConstField {internal::CommonStructureFieldSpec::memberFieldByIndex( - this->libObjPtr(), index)}; - } - - CommonField operator[](const std::uint64_t index) noexcept + CommonField operator[](const std::uint64_t index) const noexcept { return CommonField {_Spec::memberFieldByIndex(this->libObjPtr(), index)}; } - nonstd::optional operator[](const char * const name) const noexcept - { - const auto libObjPtr = - internal::CommonStructureFieldSpec::memberFieldByName(this->libObjPtr(), - name); - - if (libObjPtr) { - return ConstField {libObjPtr}; - } - - return nonstd::nullopt; - } - - nonstd::optional operator[](const std::string& name) const noexcept - { - return (*this)[name.data()]; - } - - nonstd::optional> operator[](const char * const name) noexcept + nonstd::optional> operator[](const char * const name) const noexcept { const auto libObjPtr = _Spec::memberFieldByName(this->libObjPtr(), name); @@ -1143,7 +1084,7 @@ public: return nonstd::nullopt; } - nonstd::optional> operator[](const std::string& name) noexcept + nonstd::optional> operator[](const std::string& name) const noexcept { return (*this)[name.data()]; } @@ -1229,13 +1170,7 @@ public: return *this; } - ConstArrayFieldClass cls() const noexcept - { - return ConstArrayFieldClass { - internal::CommonFieldSpec::cls(this->libObjPtr())}; - } - - Class cls() noexcept + Class cls() const noexcept { return Class {internal::CommonFieldSpec::cls(this->libObjPtr())}; } @@ -1245,13 +1180,7 @@ public: return bt_field_array_get_length(this->libObjPtr()); } - ConstField operator[](const std::uint64_t index) const noexcept - { - return ConstField {internal::CommonArrayFieldSpec::elementFieldByIndex( - this->libObjPtr(), index)}; - } - - CommonField operator[](const std::uint64_t index) noexcept + CommonField operator[](const std::uint64_t index) const noexcept { return CommonField {_Spec::elementFieldByIndex(this->libObjPtr(), index)}; } @@ -1313,7 +1242,7 @@ public: return _ThisCommonArrayField::length(); } - void length(const std::uint64_t length) + void length(const std::uint64_t length) const { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); @@ -1400,18 +1329,12 @@ public: return *this; } - ConstOptionFieldClass cls() const noexcept - { - return ConstOptionFieldClass { - internal::CommonFieldSpec::cls(this->libObjPtr())}; - } - - Class cls() noexcept + Class cls() const noexcept { return Class {internal::CommonFieldSpec::cls(this->libObjPtr())}; } - void hasField(const bool hasField) noexcept + void hasField(const bool hasField) const noexcept { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); @@ -1423,19 +1346,7 @@ public: return this->field().has_value(); } - nonstd::optional field() const noexcept - { - const auto libObjPtr = - internal::CommonOptionFieldSpec::field(this->libObjPtr()); - - if (libObjPtr) { - return ConstField {libObjPtr}; - } - - return nonstd::nullopt; - } - - nonstd::optional> field() noexcept + nonstd::optional> field() const noexcept { const auto libObjPtr = _Spec::field(this->libObjPtr()); @@ -1522,31 +1433,19 @@ public: return *this; } - ConstVariantFieldClass cls() const noexcept - { - return ConstVariantFieldClass { - internal::CommonFieldSpec::cls(this->libObjPtr())}; - } - - Class cls() noexcept + Class cls() const noexcept { return Class {internal::CommonFieldSpec::cls(this->libObjPtr())}; } - void selectOption(const std::uint64_t index) noexcept + void selectOption(const std::uint64_t index) const noexcept { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); static_cast(bt_field_variant_select_option_by_index(this->libObjPtr(), index)); } - ConstField selectedOptionField() const noexcept - { - return ConstField {internal::CommonVariantFieldSpec::selectedOptionField( - this->libObjPtr())}; - } - - CommonField selectedOptionField() noexcept + CommonField selectedOptionField() const noexcept { return CommonField {_Spec::selectedOptionField(this->libObjPtr())}; }