X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fcpp-common%2Fbt2%2Fvalue.hpp;h=0dfe9dc614d42b8598b80365089700a3958d2ddf;hb=c7e1be4b771715840b4bc3d635f72eeaf1d2e984;hp=a065af6c0c8715dec1c129847c6afde4c9d2ccb2;hpb=45e0ded5cd688d00bd39feace0720cba4e63a298;p=babeltrace.git diff --git a/src/cpp-common/bt2/value.hpp b/src/cpp-common/bt2/value.hpp index a065af6c..0dfe9dc6 100644 --- a/src/cpp-common/bt2/value.hpp +++ b/src/cpp-common/bt2/value.hpp @@ -7,21 +7,22 @@ #ifndef BABELTRACE_CPP_COMMON_BT2_VALUE_HPP #define BABELTRACE_CPP_COMMON_BT2_VALUE_HPP -#include #include #include -#include +#include + #include #include "common/assert.h" #include "common/common.h" +#include "cpp-common/optional.hpp" +#include "cpp-common/string_view.hpp" + #include "common-iter.hpp" +#include "exc.hpp" #include "internal/borrowed-obj.hpp" #include "internal/shared-obj.hpp" #include "internal/utils.hpp" -#include "cpp-common/optional.hpp" -#include "cpp-common/string_view.hpp" -#include "lib-error.hpp" namespace bt2 { namespace internal { @@ -134,12 +135,12 @@ public: } template - CommonValue(const CommonValue& val) noexcept : _ThisBorrowedObj {val} + CommonValue(const CommonValue val) noexcept : _ThisBorrowedObj {val} { } template - _ThisCommonValue& operator=(const CommonValue& val) noexcept + _ThisCommonValue& operator=(const CommonValue val) noexcept { _ThisBorrowedObj::operator=(val); return *this; @@ -196,13 +197,13 @@ public: } template - bool operator==(const CommonValue& other) const noexcept + bool operator==(const CommonValue other) const noexcept { return static_cast(bt_value_is_equal(this->libObjPtr(), other.libObjPtr())); } template - bool operator!=(const CommonValue& other) const noexcept + bool operator!=(const CommonValue other) const noexcept { return !(*this == other); } @@ -271,12 +272,12 @@ public: } template - CommonNullValue(const CommonNullValue& val) noexcept : _ThisCommonValue {val} + CommonNullValue(const CommonNullValue val) noexcept : _ThisCommonValue {val} { } template - CommonNullValue& operator=(const CommonNullValue& val) noexcept + CommonNullValue& operator=(const CommonNullValue val) noexcept { _ThisCommonValue::operator=(val); return *this; @@ -328,7 +329,7 @@ public: } template - CommonBoolValue(const CommonBoolValue& val) noexcept : _ThisCommonValue {val} + CommonBoolValue(const CommonBoolValue val) noexcept : _ThisCommonValue {val} { } @@ -341,7 +342,7 @@ public: } template - CommonBoolValue& operator=(const CommonBoolValue& val) noexcept + CommonBoolValue& operator=(const CommonBoolValue val) noexcept { _ThisCommonValue::operator=(val); return *this; @@ -420,14 +421,14 @@ public: } template - CommonUnsignedIntegerValue(const CommonUnsignedIntegerValue& val) noexcept : + CommonUnsignedIntegerValue(const CommonUnsignedIntegerValue val) noexcept : _ThisCommonValue {val} { } template CommonUnsignedIntegerValue& - operator=(const CommonUnsignedIntegerValue& val) noexcept + operator=(const CommonUnsignedIntegerValue val) noexcept { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); @@ -506,14 +507,14 @@ public: } template - CommonSignedIntegerValue(const CommonSignedIntegerValue& val) noexcept : + CommonSignedIntegerValue(const CommonSignedIntegerValue val) noexcept : _ThisCommonValue {val} { } template CommonSignedIntegerValue& - operator=(const CommonSignedIntegerValue& val) noexcept + operator=(const CommonSignedIntegerValue val) noexcept { _ThisCommonValue::operator=(val); return *this; @@ -591,12 +592,12 @@ public: } template - CommonRealValue(const CommonRealValue& val) noexcept : _ThisCommonValue {val} + CommonRealValue(const CommonRealValue val) noexcept : _ThisCommonValue {val} { } template - CommonRealValue& operator=(const CommonRealValue& val) noexcept + CommonRealValue& operator=(const CommonRealValue val) noexcept { _ThisCommonValue::operator=(val); return *this; @@ -678,12 +679,12 @@ public: } template - CommonStringValue(const CommonStringValue& val) noexcept : _ThisCommonValue {val} + CommonStringValue(const CommonStringValue val) noexcept : _ThisCommonValue {val} { } template - CommonStringValue& operator=(const CommonStringValue& val) noexcept + CommonStringValue& operator=(const CommonStringValue val) noexcept { _ThisCommonValue::operator=(val); return *this; @@ -696,7 +697,7 @@ public: const auto status = bt_value_string_set(this->libObjPtr(), rawVal); if (status == BT_VALUE_STRING_SET_STATUS_MEMORY_ERROR) { - throw LibMemoryError {}; + throw MemoryError {}; } return *this; @@ -790,12 +791,12 @@ public: } template - CommonArrayValue(const CommonArrayValue& val) noexcept : _ThisCommonValue {val} + CommonArrayValue(const CommonArrayValue val) noexcept : _ThisCommonValue {val} { } template - CommonArrayValue& operator=(const CommonArrayValue& val) noexcept + CommonArrayValue& operator=(const CommonArrayValue val) noexcept { _ThisCommonValue::operator=(val); return *this; @@ -839,7 +840,7 @@ public: internal::CommonArrayValueSpec::elementByIndex(this->libObjPtr(), index)}; } - void append(const Value& val) + void append(const Value val) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); @@ -903,7 +904,7 @@ public: CommonArrayValue appendEmptyArray(); CommonMapValue appendEmptyMap(); - void operator+=(const Value& val) + void operator+=(const Value val) { this->append(val); } @@ -947,7 +948,7 @@ private: void _handleAppendLibStatus(const bt_value_array_append_element_status status) const { if (status == BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_MEMORY_ERROR) { - throw LibMemoryError {}; + throw MemoryError {}; } } }; @@ -1034,7 +1035,7 @@ struct CommonMapValueSpec final return; case BT_VALUE_MAP_FOREACH_ENTRY_STATUS_USER_ERROR: case BT_VALUE_MAP_FOREACH_ENTRY_STATUS_ERROR: - throw LibError {}; + throw Error {}; default: bt_common_abort(); } @@ -1067,7 +1068,7 @@ struct CommonMapValueSpec final return; case BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_USER_ERROR: case BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_ERROR: - throw LibError {}; + throw Error {}; default: bt_common_abort(); } @@ -1100,12 +1101,12 @@ public: } template - CommonMapValue(const CommonMapValue& val) noexcept : _ThisCommonValue {val} + CommonMapValue(const CommonMapValue val) noexcept : _ThisCommonValue {val} { } template - CommonMapValue& operator=(const CommonMapValue& val) noexcept + CommonMapValue& operator=(const CommonMapValue val) noexcept { _ThisCommonValue::operator=(val); return *this; @@ -1165,7 +1166,7 @@ public: return this->hasEntry(key.data()); } - void insert(const char * const key, const Value& val) + void insert(const char * const key, const Value val) { static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); @@ -1174,7 +1175,7 @@ public: this->_handleInsertLibStatus(status); } - void insert(const std::string& key, const Value& val) + void insert(const std::string& key, const Value val) { this->insert(key.data(), val); } @@ -1286,7 +1287,7 @@ private: void _handleInsertLibStatus(const bt_value_map_insert_entry_status status) const { if (status == BT_VALUE_MAP_INSERT_ENTRY_STATUS_MEMORY_ERROR) { - throw LibMemoryError {}; + throw MemoryError {}; } } };