From c0b73c6309f7b6a0d488e49c62f145293d7e12e0 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Fri, 3 Nov 2023 12:03:02 -0400 Subject: [PATCH] cpp-common/bt2: use the "length" term everywhere instead of "size" Signed-off-by: Philippe Proulx Change-Id: I25ce7709679d016dff6b23aa323a0ca5ec738190 Reviewed-on: https://review.lttng.org/c/babeltrace/+/11231 Reviewed-by: Simon Marchi --- src/cpp-common/bt2/common-iterator.hpp | 2 +- src/cpp-common/bt2/field-class.hpp | 14 +++++++------- src/cpp-common/bt2/field-path.hpp | 4 ++-- src/cpp-common/bt2/field.hpp | 12 ++++++------ src/cpp-common/bt2/integer-range-set.hpp | 10 +++++----- src/cpp-common/bt2/trace-ir.hpp | 6 +++--- src/cpp-common/bt2/value.hpp | 10 ++-------- 7 files changed, 26 insertions(+), 32 deletions(-) diff --git a/src/cpp-common/bt2/common-iterator.hpp b/src/cpp-common/bt2/common-iterator.hpp index 51b8d8e2..99332d65 100644 --- a/src/cpp-common/bt2/common-iterator.hpp +++ b/src/cpp-common/bt2/common-iterator.hpp @@ -77,7 +77,7 @@ public: private: void _updateCurrentValue() noexcept { - if (_mIdx < _mContainer.size()) { + if (_mIdx < _mContainer.length()) { _mCurrVal = _mContainer[_mIdx]; } else { _mCurrVal = nonstd::nullopt; diff --git a/src/cpp-common/bt2/field-class.hpp b/src/cpp-common/bt2/field-class.hpp index ae2c52a3..3d3c4795 100644 --- a/src/cpp-common/bt2/field-class.hpp +++ b/src/cpp-common/bt2/field-class.hpp @@ -785,7 +785,7 @@ public: return *this; } - std::uint64_t size() const noexcept + std::uint64_t length() const noexcept { return bt_field_class_enumeration_get_mapping_count(this->libObjPtr()); } @@ -875,7 +875,7 @@ public: Iterator end() const noexcept { - return Iterator {*this, this->size()}; + return Iterator {*this, this->length()}; } Shared shared() const noexcept @@ -1145,7 +1145,7 @@ public: this->appendMember(name.data(), fc); } - std::uint64_t size() const noexcept + std::uint64_t length() const noexcept { return bt_field_class_structure_get_member_count(this->libObjPtr()); } @@ -1157,7 +1157,7 @@ public: Iterator end() const noexcept { - return Iterator {*this, this->size()}; + return Iterator {*this, this->length()}; } Member operator[](const std::uint64_t index) const noexcept @@ -2121,7 +2121,7 @@ public: return *this; } - std::uint64_t size() const noexcept + std::uint64_t length() const noexcept { return bt_field_class_variant_get_option_count(this->libObjPtr()); } @@ -2133,7 +2133,7 @@ public: Iterator end() const noexcept { - return Iterator {*this, this->size()}; + return Iterator {*this, this->length()}; } Option operator[](const std::uint64_t index) const noexcept @@ -2472,7 +2472,7 @@ public: Iterator end() const noexcept { - return Iterator {*this, this->size()}; + return Iterator {*this, this->length()}; } Shared shared() const noexcept diff --git a/src/cpp-common/bt2/field-path.hpp b/src/cpp-common/bt2/field-path.hpp index eea27e12..8f20405d 100644 --- a/src/cpp-common/bt2/field-path.hpp +++ b/src/cpp-common/bt2/field-path.hpp @@ -158,7 +158,7 @@ public: return static_cast(bt_field_path_get_root_scope(this->libObjPtr())); } - std::uint64_t size() const noexcept + std::uint64_t length() const noexcept { return bt_field_path_get_item_count(this->libObjPtr()); } @@ -176,7 +176,7 @@ public: Iterator end() const noexcept { - return Iterator {*this, this->size()}; + return Iterator {*this, this->length()}; } Shared shared() const noexcept diff --git a/src/cpp-common/bt2/field.hpp b/src/cpp-common/bt2/field.hpp index 241c1776..d5048b6e 100644 --- a/src/cpp-common/bt2/field.hpp +++ b/src/cpp-common/bt2/field.hpp @@ -570,7 +570,7 @@ public: explicit EnumerationFieldClassMappingLabels( const bt_field_class_enumeration_mapping_label_array labels, const std::uint64_t size) : _mLabels {labels}, - _mSize {size} + _mLen {size} { } @@ -580,9 +580,9 @@ public: EnumerationFieldClassMappingLabels& operator=(const EnumerationFieldClassMappingLabels&) noexcept = default; - std::uint64_t size() const noexcept + std::uint64_t length() const noexcept { - return _mSize; + return _mLen; } bpstd::string_view operator[](const std::uint64_t index) const noexcept @@ -592,7 +592,7 @@ public: private: bt_field_class_enumeration_mapping_label_array _mLabels; - std::uint64_t _mSize; + std::uint64_t _mLen; }; template @@ -1063,9 +1063,9 @@ public: return Class {internal::CommonFieldSpec::cls(this->libObjPtr())}; } - std::uint64_t size() const noexcept + std::uint64_t length() const noexcept { - return this->cls().size(); + return this->cls().length(); } CommonField operator[](const std::uint64_t index) const noexcept diff --git a/src/cpp-common/bt2/integer-range-set.hpp b/src/cpp-common/bt2/integer-range-set.hpp index f7ef1aaf..d50fe285 100644 --- a/src/cpp-common/bt2/integer-range-set.hpp +++ b/src/cpp-common/bt2/integer-range-set.hpp @@ -60,7 +60,7 @@ struct CommonIntegerRangeSetSpec; template <> struct CommonIntegerRangeSetSpec final { - static std::uint64_t size(const bt_integer_range_set_unsigned * const libRangePtr) noexcept + static std::uint64_t length(const bt_integer_range_set_unsigned * const libRangePtr) noexcept { return bt_integer_range_set_get_range_count( bt_integer_range_set_unsigned_as_range_set_const(libRangePtr)); @@ -97,7 +97,7 @@ struct CommonIntegerRangeSetSpec final template <> struct CommonIntegerRangeSetSpec final { - static std::uint64_t size(const bt_integer_range_set_signed * const libRangePtr) noexcept + static std::uint64_t length(const bt_integer_range_set_signed * const libRangePtr) noexcept { return bt_integer_range_set_get_range_count( bt_integer_range_set_signed_as_range_set_const(libRangePtr)); @@ -202,9 +202,9 @@ public: } } - std::uint64_t size() const noexcept + std::uint64_t length() const noexcept { - return _Spec::size(this->libObjPtr()); + return _Spec::length(this->libObjPtr()); } Range operator[](const std::uint64_t index) const noexcept @@ -219,7 +219,7 @@ public: Iterator end() const noexcept { - return Iterator {*this, this->size()}; + return Iterator {*this, this->length()}; } Shared shared() const noexcept diff --git a/src/cpp-common/bt2/trace-ir.hpp b/src/cpp-common/bt2/trace-ir.hpp index efdf0ba0..5ee98960 100644 --- a/src/cpp-common/bt2/trace-ir.hpp +++ b/src/cpp-common/bt2/trace-ir.hpp @@ -720,7 +720,7 @@ public: return nonstd::nullopt; } - std::uint64_t size() const noexcept + std::uint64_t length() const noexcept { return bt_trace_get_stream_count(this->libObjPtr()); } @@ -1514,7 +1514,7 @@ public: return nonstd::nullopt; } - std::uint64_t size() const noexcept + std::uint64_t length() const noexcept { return bt_stream_class_get_event_class_count(this->libObjPtr()); } @@ -1996,7 +1996,7 @@ public: bt_trace_class_assigns_automatic_stream_class_id(this->libObjPtr())); } - std::uint64_t size() const noexcept + std::uint64_t length() const noexcept { return bt_trace_class_get_stream_class_count(this->libObjPtr()); } diff --git a/src/cpp-common/bt2/value.hpp b/src/cpp-common/bt2/value.hpp index 1051cedf..c8e3dc79 100644 --- a/src/cpp-common/bt2/value.hpp +++ b/src/cpp-common/bt2/value.hpp @@ -771,12 +771,6 @@ public: return bt_value_array_get_length(this->libObjPtr()); } - /* Required by the `CommonIterator` template class */ - std::uint64_t size() const noexcept - { - return this->length(); - } - Iterator begin() const noexcept { return Iterator {*this, 0}; @@ -1070,14 +1064,14 @@ public: return *this; } - std::uint64_t size() const noexcept + std::uint64_t length() const noexcept { return bt_value_map_get_size(this->libObjPtr()); } bool isEmpty() const noexcept { - return this->size() == 0; + return this->length() == 0; } nonstd::optional> operator[](const char * const key) const noexcept -- 2.34.1