struct ValueRefFuncs final
{
- static void get(const bt_value * const libObjPtr)
+ static void get(const bt_value * const libObjPtr) noexcept
{
bt_value_get_ref(libObjPtr);
}
- static void put(const bt_value * const libObjPtr)
+ static void put(const bt_value * const libObjPtr) noexcept
{
bt_value_put_ref(libObjPtr);
}
MAP = BT_VALUE_TYPE_MAP,
};
-template <typename LibObjT>
-class CommonClockClass;
-
-template <typename LibObjT>
-class CommonFieldClass;
-
-template <typename LibObjT>
-class CommonTraceClass;
-
-template <typename LibObjT>
-class CommonStreamClass;
-
-template <typename LibObjT>
-class CommonEventClass;
-
-template <typename LibObjT>
-class CommonStream;
-
template <typename LibObjT>
class CommonValue : public BorrowedObject<LibObjT>
{
- /* Allow append() to call `val.libObjPtr()` */
- friend class CommonArrayValue<bt_value>;
-
- /* Allow insert() to call `val.libObjPtr()` */
- friend class CommonMapValue<bt_value>;
-
- /* Allow userAttributes() to call `val.libObjPtr()` */
- friend class CommonClockClass<bt_clock_class>;
- friend class CommonFieldClass<bt_field_class>;
- friend class CommonTraceClass<bt_trace_class>;
- friend class CommonStreamClass<bt_stream_class>;
- friend class CommonEventClass<bt_event_class>;
- friend class CommonStream<bt_stream>;
-
- /* Allow operator==() to call `other.libObjPtr()` */
- friend class CommonValue<bt_value>;
- friend class CommonValue<const bt_value>;
-
private:
using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
return *this;
}
+ CommonValue<const bt_value> asConst() const noexcept
+ {
+ return CommonValue<const bt_value> {*this};
+ }
+
ValueType type() const noexcept
{
return static_cast<ValueType>(bt_value_get_type(this->libObjPtr()));
return *this;
}
+ CommonNullValue<const bt_value> asConst() const noexcept
+ {
+ return CommonNullValue<const bt_value> {*this};
+ }
+
Shared shared() const noexcept
{
return Shared::createWithRef(*this);
return *this;
}
- CommonBoolValue<LibObjT>& operator=(const Value rawVal) noexcept
+ CommonBoolValue<const bt_value> asConst() const noexcept
+ {
+ return CommonBoolValue<const bt_value> {*this};
+ }
+
+ CommonBoolValue<LibObjT> operator=(const Value rawVal) const noexcept
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstBoolValue`.");
bt_value_bool_set(this->libObjPtr(), static_cast<bt_bool>(rawVal));
return *this;
CommonUnsignedIntegerValue<LibObjT>&
operator=(const CommonUnsignedIntegerValue<OtherLibObjT> val) noexcept
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value,
+ "Not available with `bt2::ConstUnsignedIntegerValue`.");
_ThisCommonValue::operator=(val);
return *this;
}
- CommonUnsignedIntegerValue<LibObjT>& operator=(const Value rawVal) noexcept
+ CommonUnsignedIntegerValue<const bt_value> asConst() const noexcept
+ {
+ return CommonUnsignedIntegerValue<const bt_value> {*this};
+ }
+
+ CommonUnsignedIntegerValue<LibObjT> operator=(const Value rawVal) const noexcept
{
bt_value_integer_unsigned_set(this->libObjPtr(), rawVal);
return *this;
}
template <typename OtherLibObjT>
- CommonSignedIntegerValue<LibObjT>&
+ CommonSignedIntegerValue<LibObjT>
operator=(const CommonSignedIntegerValue<OtherLibObjT> val) noexcept
{
_ThisCommonValue::operator=(val);
return *this;
}
- CommonSignedIntegerValue<LibObjT>& operator=(const Value rawVal) noexcept
+ CommonSignedIntegerValue<const bt_value> asConst() const noexcept
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ return CommonSignedIntegerValue<const bt_value> {*this};
+ }
+
+ CommonSignedIntegerValue<LibObjT> operator=(const Value rawVal) const noexcept
+ {
+ static_assert(!std::is_const<LibObjT>::value,
+ "Not available with `bt2::ConstSignedIntegerValue`.");
bt_value_integer_signed_set(this->libObjPtr(), rawVal);
return *this;
return *this;
}
- CommonRealValue<LibObjT>& operator=(const Value rawVal) noexcept
+ CommonRealValue<const bt_value> asConst() const noexcept
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ return CommonRealValue<const bt_value> {*this};
+ }
+
+ CommonRealValue<LibObjT> operator=(const Value rawVal) const noexcept
+ {
+ static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstRealValue`.");
bt_value_real_set(this->libObjPtr(), rawVal);
return *this;
return *this;
}
- CommonStringValue<LibObjT>& operator=(const char * const rawVal)
+ CommonStringValue<const bt_value> asConst() const noexcept
+ {
+ return CommonStringValue<const bt_value> {*this};
+ }
+
+ CommonStringValue<LibObjT> operator=(const char * const rawVal) const
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value,
+ "Not available with `bt2::ConstStringValue`.");
const auto status = bt_value_string_set(this->libObjPtr(), rawVal);
return *this;
}
- CommonStringValue<LibObjT>& operator=(const std::string& rawVal) noexcept
+ CommonStringValue<LibObjT> operator=(const std::string& rawVal) const noexcept
{
return *this = rawVal.data();
}
return *this;
}
- std::uint64_t length() const noexcept
+ CommonArrayValue<const bt_value> asConst() const noexcept
{
- return bt_value_array_get_length(this->libObjPtr());
+ return CommonArrayValue<const bt_value> {*this};
}
- /* Required by the `CommonIterator` template class */
- std::uint64_t size() const noexcept
+ std::uint64_t length() const noexcept
{
- return this->length();
+ return bt_value_array_get_length(this->libObjPtr());
}
Iterator begin() const noexcept
return this->length() == 0;
}
- ConstValue operator[](const std::uint64_t index) const noexcept
- {
- return ConstValue {internal::CommonArrayValueSpec<const bt_value>::elementByIndex(
- this->libObjPtr(), index)};
- }
-
- CommonValue<LibObjT> operator[](const std::uint64_t index) noexcept
+ CommonValue<LibObjT> operator[](const std::uint64_t index) const noexcept
{
return CommonValue<LibObjT> {
internal::CommonArrayValueSpec<LibObjT>::elementByIndex(this->libObjPtr(), index)};
}
- void append(const Value val)
+ void append(const Value val) const
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstArrayValue`.");
const auto status = bt_value_array_append_element(this->libObjPtr(), val.libObjPtr());
this->_handleAppendLibStatus(status);
}
- void append(const bool rawVal)
+ void append(const bool rawVal) const
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstArrayValue`.");
const auto status =
bt_value_array_append_bool_element(this->libObjPtr(), static_cast<bt_bool>(rawVal));
this->_handleAppendLibStatus(status);
}
- void append(const std::uint64_t rawVal)
+ void append(const std::uint64_t rawVal) const
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstArrayValue`.");
const auto status =
bt_value_array_append_unsigned_integer_element(this->libObjPtr(), rawVal);
this->_handleAppendLibStatus(status);
}
- void append(const std::int64_t rawVal)
+ void append(const std::int64_t rawVal) const
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstArrayValue`.");
const auto status = bt_value_array_append_signed_integer_element(this->libObjPtr(), rawVal);
this->_handleAppendLibStatus(status);
}
- void append(const double rawVal)
+ void append(const double rawVal) const
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstArrayValue`.");
const auto status = bt_value_array_append_real_element(this->libObjPtr(), rawVal);
this->_handleAppendLibStatus(status);
}
- void append(const char * const rawVal)
+ void append(const char * const rawVal) const
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstArrayValue`.");
const auto status = bt_value_array_append_string_element(this->libObjPtr(), rawVal);
this->_handleAppendLibStatus(status);
}
- void append(const std::string& rawVal)
+ void append(const std::string& rawVal) const
{
this->append(rawVal.data());
}
- CommonArrayValue<bt_value> appendEmptyArray();
- CommonMapValue<bt_value> appendEmptyMap();
+ CommonArrayValue<bt_value> appendEmptyArray() const;
+ CommonMapValue<bt_value> appendEmptyMap() const;
- void operator+=(const Value val)
+ void operator+=(const Value val) const
{
this->append(val);
}
- void operator+=(const bool rawVal)
+ void operator+=(const bool rawVal) const
{
this->append(rawVal);
}
- void operator+=(const std::uint64_t rawVal)
+ void operator+=(const std::uint64_t rawVal) const
{
this->append(rawVal);
}
- void operator+=(const std::int64_t rawVal)
+ void operator+=(const std::int64_t rawVal) const
{
this->append(rawVal);
}
- void operator+=(const double rawVal)
+ void operator+=(const double rawVal) const
{
this->append(rawVal);
}
- void operator+=(const char * const rawVal)
+ void operator+=(const char * const rawVal) const
{
this->append(rawVal);
}
- void operator+=(const std::string& rawVal)
+ void operator+=(const std::string& rawVal) const
{
this->append(rawVal);
}
return *this;
}
- std::uint64_t size() const noexcept
+ CommonMapValue<const bt_value> asConst() const noexcept
{
- return bt_value_map_get_size(this->libObjPtr());
+ return CommonMapValue<const bt_value> {*this};
}
- bool isEmpty() const noexcept
- {
- return this->size() == 0;
- }
-
- nonstd::optional<ConstValue> operator[](const char * const key) const noexcept
+ std::uint64_t length() const noexcept
{
- const auto libObjPtr =
- internal::CommonMapValueSpec<const bt_value>::entryByKey(this->libObjPtr(), key);
-
- if (!libObjPtr) {
- return nonstd::nullopt;
- }
-
- return ConstValue {libObjPtr};
+ return bt_value_map_get_size(this->libObjPtr());
}
- nonstd::optional<ConstValue> operator[](const std::string& key) const noexcept
+ bool isEmpty() const noexcept
{
- return (*this)[key.data()];
+ return this->length() == 0;
}
- nonstd::optional<CommonValue<LibObjT>> operator[](const char * const key) noexcept
+ nonstd::optional<CommonValue<LibObjT>> operator[](const char * const key) const noexcept
{
const auto libObjPtr =
internal::CommonMapValueSpec<LibObjT>::entryByKey(this->libObjPtr(), key);
return CommonValue<LibObjT> {libObjPtr};
}
- nonstd::optional<CommonValue<LibObjT>> operator[](const std::string& key) noexcept
+ nonstd::optional<CommonValue<LibObjT>> operator[](const std::string& key) const noexcept
{
return (*this)[key.data()];
}
return this->hasEntry(key.data());
}
- void insert(const char * const key, const Value val)
+ void insert(const char * const key, const Value val) const
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
const auto status = bt_value_map_insert_entry(this->libObjPtr(), key, val.libObjPtr());
this->_handleInsertLibStatus(status);
}
- void insert(const std::string& key, const Value val)
+ void insert(const std::string& key, const Value val) const
{
this->insert(key.data(), val);
}
- void insert(const char * const key, const bool rawVal)
+ void insert(const char * const key, const bool rawVal) const
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
const auto status =
bt_value_map_insert_bool_entry(this->libObjPtr(), key, static_cast<bt_bool>(rawVal));
this->_handleInsertLibStatus(status);
}
- void insert(const std::string& key, const bool rawVal)
+ void insert(const std::string& key, const bool rawVal) const
{
this->insert(key.data(), rawVal);
}
- void insert(const char * const key, const std::uint64_t rawVal)
+ void insert(const char * const key, const std::uint64_t rawVal) const
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
const auto status =
bt_value_map_insert_unsigned_integer_entry(this->libObjPtr(), key, rawVal);
this->_handleInsertLibStatus(status);
}
- void insert(const std::string& key, const std::uint64_t rawVal)
+ void insert(const std::string& key, const std::uint64_t rawVal) const
{
this->insert(key.data(), rawVal);
}
- void insert(const char * const key, const std::int64_t rawVal)
+ void insert(const char * const key, const std::int64_t rawVal) const
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
const auto status =
bt_value_map_insert_signed_integer_entry(this->libObjPtr(), key, rawVal);
this->_handleInsertLibStatus(status);
}
- void insert(const std::string& key, const std::int64_t rawVal)
+ void insert(const std::string& key, const std::int64_t rawVal) const
{
this->insert(key.data(), rawVal);
}
- void insert(const char * const key, const double rawVal)
+ void insert(const char * const key, const double rawVal) const
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
const auto status = bt_value_map_insert_real_entry(this->libObjPtr(), key, rawVal);
this->_handleInsertLibStatus(status);
}
- void insert(const std::string& key, const double rawVal)
+ void insert(const std::string& key, const double rawVal) const
{
this->insert(key.data(), rawVal);
}
- void insert(const char * const key, const char * const rawVal)
+ void insert(const char * const key, const char * const rawVal) const
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
const auto status = bt_value_map_insert_string_entry(this->libObjPtr(), key, rawVal);
this->_handleInsertLibStatus(status);
}
- void insert(const char * const key, const std::string& rawVal)
+ void insert(const char * const key, const std::string& rawVal) const
{
this->insert(key, rawVal.data());
}
- void insert(const std::string& key, const char * const rawVal)
+ void insert(const std::string& key, const char * const rawVal) const
{
this->insert(key.data(), rawVal);
}
- void insert(const std::string& key, const std::string& rawVal)
+ void insert(const std::string& key, const std::string& rawVal) const
{
this->insert(key.data(), rawVal.data());
}
- CommonArrayValue<bt_value> insertEmptyArray(const char *key);
- CommonArrayValue<bt_value> insertEmptyArray(const std::string& key);
- CommonMapValue<bt_value> insertEmptyMap(const char *key);
- CommonMapValue<bt_value> insertEmptyMap(const std::string& key);
-
- void forEach(const internal::CommonMapValueForEachUserFunc<ConstValue>& func) const
- {
- internal::CommonMapValueSpec<const bt_value>::forEach(this->libObjPtr(), func);
- }
+ CommonArrayValue<bt_value> insertEmptyArray(const char *key) const;
+ CommonArrayValue<bt_value> insertEmptyArray(const std::string& key) const;
+ CommonMapValue<bt_value> insertEmptyMap(const char *key) const;
+ CommonMapValue<bt_value> insertEmptyMap(const std::string& key) const;
- void forEach(const internal::CommonMapValueForEachUserFunc<CommonValue<LibObjT>>& func)
+ void forEach(const internal::CommonMapValueForEachUserFunc<CommonValue<LibObjT>>& func) const
{
internal::CommonMapValueSpec<LibObjT>::forEach(this->libObjPtr(), func);
}
}
template <typename LibObjT>
-ArrayValue CommonArrayValue<LibObjT>::appendEmptyArray()
+ArrayValue CommonArrayValue<LibObjT>::appendEmptyArray() const
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstArrayValue`.");
bt_value *libElemPtr;
const auto status = bt_value_array_append_empty_array_element(this->libObjPtr(), &libElemPtr);
}
template <typename LibObjT>
-MapValue CommonArrayValue<LibObjT>::appendEmptyMap()
+MapValue CommonArrayValue<LibObjT>::appendEmptyMap() const
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstArrayValue`.");
bt_value *libElemPtr;
const auto status = bt_value_array_append_empty_map_element(this->libObjPtr(), &libElemPtr);
}
template <typename LibObjT>
-ArrayValue CommonMapValue<LibObjT>::insertEmptyArray(const char * const key)
+ArrayValue CommonMapValue<LibObjT>::insertEmptyArray(const char * const key) const
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
bt_value *libEntryPtr;
const auto status = bt_value_map_insert_empty_array_entry(this->libObjPtr(), key, &libEntryPtr);
}
template <typename LibObjT>
-ArrayValue CommonMapValue<LibObjT>::insertEmptyArray(const std::string& key)
+ArrayValue CommonMapValue<LibObjT>::insertEmptyArray(const std::string& key) const
{
return this->insertEmptyArray(key.data());
}
template <typename LibObjT>
-MapValue CommonMapValue<LibObjT>::insertEmptyMap(const char * const key)
+MapValue CommonMapValue<LibObjT>::insertEmptyMap(const char * const key) const
{
- static_assert(!std::is_const<LibObjT>::value, "`LibObjT` must NOT be `const`.");
+ static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
bt_value *libEntryPtr;
const auto status = bt_value_map_insert_empty_map_entry(this->libObjPtr(), key, &libEntryPtr);
}
template <typename LibObjT>
-MapValue CommonMapValue<LibObjT>::insertEmptyMap(const std::string& key)
+MapValue CommonMapValue<LibObjT>::insertEmptyMap(const std::string& key) const
{
return this->insertEmptyMap(key.data());
}