From what I saw, at -O2 with gcc, passing and returning CStringViews
generates the same code as passing and returning `const char *`. Change
the `cpp-common/bt2` code to take a return C strings using CStringViews
when possible, which is more convenient than `const char *`.
Since std::string is implicitly convertible to CStringView, there is
generaly no need to have separate overloads that take std::strings.
I left the `CommonStringField::append(const std::string &)` overload,
because this one has an advantage over the `CStringView` overload: it
uses the size of the `std::string`, which is cheaper than calling
`std::strlen`.
There are some cases where leaving the `const char *` overload is
necessary. For instance, when there is also a `bool` overload. In that
case, passing a `const char *` to the function would prefer the `bool`
overload over the `CStringView` overload, which is not what we want.
Change-Id: I4c995c995da3edd2f0e9f7034053d52cb1541bb0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11690
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
return static_cast<bool>(bt_clock_class_origin_is_unix_epoch(this->libObjPtr()));
}
return static_cast<bool>(bt_clock_class_origin_is_unix_epoch(this->libObjPtr()));
}
- void name(const char * const name) const
+ void name(const bt2c::CStringView name) const
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstClockClass`.");
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstClockClass`.");
- void name(const std::string& name) const
- {
- this->name(name.data());
- }
-
bt2c::CStringView name() const noexcept
{
return bt_clock_class_get_name(this->libObjPtr());
}
bt2c::CStringView name() const noexcept
{
return bt_clock_class_get_name(this->libObjPtr());
}
- void description(const char * const description) const
+ void description(const bt2c::CStringView description) const
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstClockClass`.");
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstClockClass`.");
- void description(const std::string& description) const
- {
- this->description(description.data());
- }
-
bt2c::CStringView description() const noexcept
{
return bt_clock_class_get_description(this->libObjPtr());
bt2c::CStringView description() const noexcept
{
return bt_clock_class_get_description(this->libObjPtr());
}
Port operator[](std::uint64_t index) const noexcept;
}
Port operator[](std::uint64_t index) const noexcept;
- Port operator[](const char *name) const noexcept;
- Port operator[](const std::string& name) const noexcept;
+ Port operator[](bt2c::CStringView name) const noexcept;
Iterator begin() const noexcept;
Iterator end() const noexcept;
};
Iterator begin() const noexcept;
Iterator end() const noexcept;
};
template <typename LibCompT, typename LibPortT>
typename ConstComponentPorts<LibCompT, LibPortT>::Port
template <typename LibCompT, typename LibPortT>
typename ConstComponentPorts<LibCompT, LibPortT>::Port
-ConstComponentPorts<LibCompT, LibPortT>::operator[](const char * const name) const noexcept
+ConstComponentPorts<LibCompT, LibPortT>::operator[](const bt2c::CStringView name) const noexcept
{
return Port {_Spec::portByName(this->libObjPtr(), name)};
}
{
return Port {_Spec::portByName(this->libObjPtr(), name)};
}
-template <typename LibCompT, typename LibPortT>
-typename ConstComponentPorts<LibCompT, LibPortT>::Port
-ConstComponentPorts<LibCompT, LibPortT>::operator[](const std::string& name) const noexcept
-{
- return (*this)[name.data()];
-}
-
template <typename LibCompT, typename LibPortT>
typename ConstComponentPorts<LibCompT, LibPortT>::Iterator
ConstComponentPorts<LibCompT, LibPortT>::begin() const noexcept
template <typename LibCompT, typename LibPortT>
typename ConstComponentPorts<LibCompT, LibPortT>::Iterator
ConstComponentPorts<LibCompT, LibPortT>::begin() const noexcept
this->libObjPtr(), index)};
}
this->libObjPtr(), index)};
}
- OptionalBorrowedObject<Mapping> operator[](const char * const label) const noexcept
+ OptionalBorrowedObject<Mapping> operator[](const bt2c::CStringView label) const noexcept
{
return internal::CommonEnumerationFieldClassSpec<MappingT>::mappingByLabel(
this->libObjPtr(), label);
}
{
return internal::CommonEnumerationFieldClassSpec<MappingT>::mappingByLabel(
this->libObjPtr(), label);
}
- OptionalBorrowedObject<Mapping> operator[](const std::string& label) const noexcept
- {
- return (*this)[label.data()];
- }
-
- void addMapping(const char * const label, const typename Mapping::RangeSet ranges) const
+ void addMapping(const bt2c::CStringView label, const typename Mapping::RangeSet ranges) const
{
const auto status = internal::CommonEnumerationFieldClassSpec<MappingT>::addMapping(
this->libObjPtr(), label, ranges.libObjPtr());
{
const auto status = internal::CommonEnumerationFieldClassSpec<MappingT>::addMapping(
this->libObjPtr(), label, ranges.libObjPtr());
- void addMapping(const std::string& label, const typename Mapping::RangeSet ranges) const
- {
- this->addMapping(label.data(), ranges);
- }
-
Iterator begin() const noexcept
{
return Iterator {*this, 0};
Iterator begin() const noexcept
{
return Iterator {*this, 0};
return CommonStructureFieldClass<const bt_field_class> {*this};
}
return CommonStructureFieldClass<const bt_field_class> {*this};
}
- void appendMember(const char * const name, const FieldClass fc) const
+ void appendMember(const bt2c::CStringView name, const FieldClass fc) const
{
static_assert(!std::is_const<LibObjT>::value,
"Not available with `bt2::ConstStructureFieldClass`.");
{
static_assert(!std::is_const<LibObjT>::value,
"Not available with `bt2::ConstStructureFieldClass`.");
- void appendMember(const std::string& name, const FieldClass fc) const
- {
- this->appendMember(name.data(), fc);
- }
-
std::uint64_t length() const noexcept
{
return bt_field_class_structure_get_member_count(this->libObjPtr());
std::uint64_t length() const noexcept
{
return bt_field_class_structure_get_member_count(this->libObjPtr());
this->libObjPtr(), index)};
}
this->libObjPtr(), index)};
}
- OptionalBorrowedObject<Member> operator[](const char * const name) const noexcept
+ OptionalBorrowedObject<Member> operator[](const bt2c::CStringView name) const noexcept
{
return internal::CommonStructureFieldClassSpec<LibObjT>::memberByName(this->libObjPtr(),
name);
}
{
return internal::CommonStructureFieldClassSpec<LibObjT>::memberByName(this->libObjPtr(),
name);
}
- OptionalBorrowedObject<Member> operator[](const std::string& name) const noexcept
- {
- return (*this)[name.data()];
- }
-
Shared shared() const noexcept
{
return Shared::createWithRef(*this);
Shared shared() const noexcept
{
return Shared::createWithRef(*this);
this->libObjPtr(), index)};
}
this->libObjPtr(), index)};
}
- OptionalBorrowedObject<Option> operator[](const char * const name) const noexcept
+ OptionalBorrowedObject<Option> operator[](const bt2c::CStringView name) const noexcept
{
return internal::CommonVariantFieldClassSpec<LibObjT>::optionByName(this->libObjPtr(),
name);
}
{
return internal::CommonVariantFieldClassSpec<LibObjT>::optionByName(this->libObjPtr(),
name);
}
- OptionalBorrowedObject<Option> operator[](const std::string& name) const noexcept
- {
- return (*this)[name.data()];
- }
-
Shared shared() const noexcept
{
return Shared::createWithRef(*this);
Shared shared() const noexcept
{
return Shared::createWithRef(*this);
+ void appendOption(const bt2c::CStringView name, const FieldClass fc) const
+ {
+ return this->appendOption(name.data(), fc);
+ }
+
void appendOption(const bt2s::optional<std::string>& name, const FieldClass fc) const
{
this->appendOption(name ? name->data() : nullptr, fc);
void appendOption(const bt2s::optional<std::string>& name, const FieldClass fc) const
{
this->appendOption(name ? name->data() : nullptr, fc);
return Option {_Spec::optionByIndex(this->libObjPtr(), index)};
}
return Option {_Spec::optionByIndex(this->libObjPtr(), index)};
}
- OptionalBorrowedObject<Option> operator[](const char * const name) const noexcept
+ OptionalBorrowedObject<Option> operator[](const bt2c::CStringView name) const noexcept
{
return _Spec::optionByName(this->libObjPtr(), name);
}
{
return _Spec::optionByName(this->libObjPtr(), name);
}
- OptionalBorrowedObject<Option> operator[](const std::string& name) const noexcept
- {
- return (*this)[name.data()];
- }
-
void appendOption(const char * const name, const FieldClass fc,
const typename Option::RangeSet ranges) const
{
void appendOption(const char * const name, const FieldClass fc,
const typename Option::RangeSet ranges) const
{
+ void appendOption(const bt2c::CStringView name, const FieldClass fc,
+ const typename Option::RangeSet ranges) const
+ {
+ return this->appendOption(name.data(), fc, ranges);
+ }
+
void appendOption(const bt2s::optional<std::string>& name, const FieldClass fc,
const typename Option::RangeSet ranges) const
{
void appendOption(const bt2s::optional<std::string>& name, const FieldClass fc,
const typename Option::RangeSet ranges) const
{
return CommonStringField<const bt_field> {*this};
}
return CommonStringField<const bt_field> {*this};
}
- RawStringValueProxy<CommonStringField> operator*() const noexcept
+ RawValueProxy<CommonStringField> operator*() const noexcept
- return RawStringValueProxy<CommonStringField> {*this};
+ return RawValueProxy<CommonStringField> {*this};
- void value(const Value& val) const
+ void value(const Value val) const
{
static_assert(!std::is_const<LibObjT>::value,
"Not available with `bt2::ConstStringField`.");
{
static_assert(!std::is_const<LibObjT>::value,
"Not available with `bt2::ConstStringField`.");
- void value(const char * const val) const
- {
- this->value(bt2c::CStringView {val});
- }
-
- void value(const std::string& val) const
- {
- this->value(bt2c::CStringView {val.data()});
- }
-
- void append(const char * const begin, const std::uint64_t len) const
+ void append(const bt2c::CStringView begin, const std::uint64_t len) const
{
static_assert(!std::is_const<LibObjT>::value,
"Not available with `bt2::ConstStringField`.");
{
static_assert(!std::is_const<LibObjT>::value,
"Not available with `bt2::ConstStringField`.");
- void append(const char * const val) const
+ void append(const bt2c::CStringView val) const
{
this->append(val, std::strlen(val));
}
{
this->append(val, std::strlen(val));
}
return CommonField<LibObjT> {_Spec::memberFieldByIndex(this->libObjPtr(), index)};
}
return CommonField<LibObjT> {_Spec::memberFieldByIndex(this->libObjPtr(), index)};
}
- OptionalBorrowedObject<CommonField<LibObjT>> operator[](const char * const name) const noexcept
+ OptionalBorrowedObject<CommonField<LibObjT>>
+ operator[](const bt2c::CStringView name) const noexcept
{
return _Spec::memberFieldByName(this->libObjPtr(), name);
}
{
return _Spec::memberFieldByName(this->libObjPtr(), name);
}
-
- OptionalBorrowedObject<CommonField<LibObjT>> operator[](const std::string& name) const noexcept
- {
- return (*this)[name.data()];
- }
};
using StructureField = CommonStructureField<bt_field>;
};
using StructureField = CommonStructureField<bt_field>;
namespace bt2 {
namespace internal {
namespace bt2 {
namespace internal {
-constexpr const char *unhandledExcLogStr() noexcept
+constexpr bt2c::CStringView unhandledExcLogStr() noexcept
{
return "Unhandled exception.";
}
{
return "Unhandled exception.";
}
-constexpr const char *unhandledExcLogTag() noexcept
+constexpr bt2c::CStringView unhandledExcLogTag() noexcept
{
return "PLUGIN-DEV-HPP";
}
{
return "PLUGIN-DEV-HPP";
}
public:
static Value::Shared query(const SelfComponentClass selfCompCls,
public:
static Value::Shared query(const SelfComponentClass selfCompCls,
- const PrivateQueryExecutor privQueryExec, const char * const obj,
- const ConstValue params)
+ const PrivateQueryExecutor privQueryExec,
+ const bt2c::CStringView obj, const ConstValue params)
{
return UserComponentT::_query(selfCompCls, privQueryExec, obj, params);
}
{
return UserComponentT::_query(selfCompCls, privQueryExec, obj, params);
}
protected:
/* Overloadable */
protected:
/* Overloadable */
- static Value::Shared _query(SelfComponentClass, PrivateQueryExecutor, const char *, ConstValue)
+ static Value::Shared _query(SelfComponentClass, PrivateQueryExecutor, bt2c::CStringView,
+ ConstValue)
{
throw UnknownObject {};
}
{
throw UnknownObject {};
}
}
template <typename DataT>
}
template <typename DataT>
- _OutputPorts::Port _addOutputPort(const char * const name, DataT * const data)
+ _OutputPorts::Port _addOutputPort(const bt2c::CStringView name, DataT * const data)
{
return this->_selfComp().addOutputPort(name, data);
}
{
return this->_selfComp().addOutputPort(name, data);
}
- _OutputPorts::Port _addOutputPort(const char *name)
- {
- return this->_selfComp().addOutputPort(name);
- }
-
- template <typename DataT>
- _OutputPorts::Port _addOutputPort(const std::string& name, DataT * const data)
- {
- return this->_selfComp().addOutputPort(name, data);
- }
-
- _OutputPorts::Port _addOutputPort(const std::string& name)
+ _OutputPorts::Port _addOutputPort(const bt2c::CStringView name)
{
return this->_selfComp().addOutputPort(name);
}
{
return this->_selfComp().addOutputPort(name);
}
public:
static Value::Shared query(const SelfComponentClass selfCompCls,
public:
static Value::Shared query(const SelfComponentClass selfCompCls,
- const PrivateQueryExecutor privQueryExec, const char * const obj,
- const ConstValue params)
+ const PrivateQueryExecutor privQueryExec,
+ const bt2c::CStringView obj, const ConstValue params)
{
return UserComponentT::_query(selfCompCls, privQueryExec, obj, params);
}
{
return UserComponentT::_query(selfCompCls, privQueryExec, obj, params);
}
protected:
/* Overloadable */
protected:
/* Overloadable */
- static Value::Shared _query(SelfComponentClass, PrivateQueryExecutor, const char *, ConstValue)
+ static Value::Shared _query(SelfComponentClass, PrivateQueryExecutor, bt2c::CStringView,
+ ConstValue)
{
throw UnknownObject {};
}
{
throw UnknownObject {};
}
}
template <typename DataT>
}
template <typename DataT>
- _OutputPorts::Port _addInputPort(const char * const name, DataT * const data)
- {
- return this->_selfComp().addInputPort(name, data);
- }
-
- _InputPorts::Port _addInputPort(const char *name)
- {
- return this->_selfComp().addInputPort(name);
- }
-
- template <typename DataT>
- _InputPorts::Port _addInputPort(const std::string& name, DataT * const data)
+ _OutputPorts::Port _addInputPort(const bt2c::CStringView name, DataT * const data)
{
return this->_selfComp().addInputPort(name, data);
}
{
return this->_selfComp().addInputPort(name, data);
}
- _InputPorts::Port _addInputPort(const std::string& name)
+ _InputPorts::Port _addInputPort(const bt2c::CStringView name)
{
return this->_selfComp().addInputPort(name);
}
{
return this->_selfComp().addInputPort(name);
}
}
template <typename DataT>
}
template <typename DataT>
- _OutputPorts::Port _addOutputPort(const char * const name, DataT * const data)
+ _OutputPorts::Port _addOutputPort(const bt2c::CStringView name, DataT * const data)
{
return this->_selfComp().addOutputPort(name, data);
}
{
return this->_selfComp().addOutputPort(name, data);
}
- _OutputPorts::Port _addOutputPort(const char *name)
- {
- return this->_selfComp().addOutputPort(name);
- }
-
- template <typename DataT>
- _OutputPorts::Port _addOutputPort(const std::string& name, DataT * const data)
- {
- return this->_selfComp().addOutputPort(name, data);
- }
-
- _OutputPorts::Port _addOutputPort(const std::string& name)
+ _OutputPorts::Port _addOutputPort(const bt2c::CStringView name)
{
return this->_selfComp().addOutputPort(name);
}
{
return this->_selfComp().addOutputPort(name);
}
public:
static Value::Shared query(const SelfComponentClass selfCompCls,
public:
static Value::Shared query(const SelfComponentClass selfCompCls,
- const PrivateQueryExecutor privQueryExec, const char * const obj,
- const ConstValue params)
+ const PrivateQueryExecutor privQueryExec,
+ const bt2c::CStringView obj, const ConstValue params)
{
return UserComponentT::_query(selfCompCls, privQueryExec, obj, params);
}
{
return UserComponentT::_query(selfCompCls, privQueryExec, obj, params);
}
protected:
/* Overloadable */
protected:
/* Overloadable */
- static Value::Shared _query(SelfComponentClass, PrivateQueryExecutor, const char *, ConstValue)
+ static Value::Shared _query(SelfComponentClass, PrivateQueryExecutor, bt2c::CStringView,
+ ConstValue)
{
throw UnknownObject {};
}
{
throw UnknownObject {};
}
}
template <typename DataT>
}
template <typename DataT>
- _InputPorts::Port _addInputPort(const char * const name, DataT * const data)
- {
- return this->_selfComp().addInputPort(name, data);
- }
-
- _InputPorts::Port _addInputPort(const char *name)
- {
- return this->_selfComp().addInputPort(name);
- }
-
- template <typename DataT>
- _InputPorts::Port _addInputPort(const std::string& name, DataT * const data)
+ _InputPorts::Port _addInputPort(const bt2c::CStringView name, DataT * const data)
{
return this->_selfComp().addInputPort(name, data);
}
{
return this->_selfComp().addInputPort(name, data);
}
- _InputPorts::Port _addInputPort(const std::string& name)
+ _InputPorts::Port _addInputPort(const bt2c::CStringView name)
{
return this->_selfComp().addInputPort(name);
}
{
return this->_selfComp().addInputPort(name);
}
-template <typename ObjT>
-class RawStringValueProxy final : public RawValueProxy<ObjT>
-{
-public:
- explicit RawStringValueProxy(const ObjT obj) : RawValueProxy<ObjT> {obj}
- {
- }
-
- RawStringValueProxy& operator=(const char * const rawVal)
- {
- RawValueProxy<ObjT>::operator=(bt2c::CStringView {rawVal});
- return *this;
- }
-
- RawStringValueProxy& operator=(const std::string& rawVal)
- {
- RawValueProxy<ObjT>::operator=(bt2c::CStringView {rawVal.data()});
- return *this;
- }
-};
-
} /* namespace bt2 */
#endif /* BABELTRACE_CPP_COMMON_BT2_RAW_VALUE_PROXY_HPP */
} /* namespace bt2 */
#endif /* BABELTRACE_CPP_COMMON_BT2_RAW_VALUE_PROXY_HPP */
}
Port operator[](std::uint64_t index) const noexcept;
}
Port operator[](std::uint64_t index) const noexcept;
- Port operator[](const char *name) const noexcept;
- Port operator[](const std::string& name) const noexcept;
+ Port operator[](bt2c::CStringView name) const noexcept;
Iterator begin() const noexcept;
Iterator end() const noexcept;
Port front() const noexcept;
Iterator begin() const noexcept;
Iterator end() const noexcept;
Port front() const noexcept;
}
template <typename DataT>
}
template <typename DataT>
- OutputPorts::Port addOutputPort(const char *name, DataT& data) const;
+ OutputPorts::Port addOutputPort(bt2c::CStringView name, DataT& data) const;
- OutputPorts::Port addOutputPort(const char *name) const;
+ OutputPorts::Port addOutputPort(bt2c::CStringView name) const;
- template <typename DataT>
- OutputPorts::Port addOutputPort(const std::string& name, DataT& data) const;
-
- OutputPorts::Port addOutputPort(const std::string& name) const;
OutputPorts outputPorts() const noexcept;
private:
OutputPorts outputPorts() const noexcept;
private:
}
template <typename DataT>
}
template <typename DataT>
- InputPorts::Port addInputPort(const char *name, DataT& data) const;
-
- InputPorts::Port addInputPort(const char *name) const;
+ InputPorts::Port addInputPort(bt2c::CStringView name, DataT& data) const;
- template <typename DataT>
- InputPorts::Port addInputPort(const std::string& name, DataT& data) const;
+ InputPorts::Port addInputPort(bt2c::CStringView name) const;
- InputPorts::Port addInputPort(const std::string& name) const;
InputPorts inputPorts() const noexcept;
template <typename DataT>
InputPorts inputPorts() const noexcept;
template <typename DataT>
- OutputPorts::Port addOutputPort(const char *name, DataT& data) const;
-
- OutputPorts::Port addOutputPort(const char *name) const;
+ OutputPorts::Port addOutputPort(bt2c::CStringView name, DataT& data) const;
- template <typename DataT>
- OutputPorts::Port addOutputPort(const std::string& name, DataT& data) const;
+ OutputPorts::Port addOutputPort(bt2c::CStringView name) const;
- OutputPorts::Port addOutputPort(const std::string& name) const;
OutputPorts outputPorts() const noexcept;
private:
OutputPorts outputPorts() const noexcept;
private:
}
template <typename DataT>
}
template <typename DataT>
- InputPorts::Port addInputPort(const char *name, DataT& data) const;
+ InputPorts::Port addInputPort(bt2c::CStringView name, DataT& data) const;
- InputPorts::Port addInputPort(const char *name) const;
+ InputPorts::Port addInputPort(bt2c::CStringView name) const;
- template <typename DataT>
- InputPorts::Port addInputPort(const std::string& name, DataT& data) const;
-
- InputPorts::Port addInputPort(const std::string& name) const;
InputPorts inputPorts() const noexcept;
private:
InputPorts inputPorts() const noexcept;
private:
template <typename LibSelfCompT, typename LibSelfCompPortT, typename LibPortT>
typename SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::Port
SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::operator[](
template <typename LibSelfCompT, typename LibSelfCompPortT, typename LibPortT>
typename SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::Port
SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::operator[](
- const char * const name) const noexcept
+ const bt2c::CStringView name) const noexcept
{
return Port {_Spec::portByName(this->libObjPtr(), name)};
}
{
return Port {_Spec::portByName(this->libObjPtr(), name)};
}
-template <typename LibSelfCompT, typename LibSelfCompPortT, typename LibPortT>
-typename SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::Port
-SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::operator[](
- const std::string& name) const noexcept
-{
- return (*this)[name.data()];
-}
-
template <typename LibSelfCompT, typename LibSelfCompPortT, typename LibPortT>
typename SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::Iterator
SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::begin() const noexcept
template <typename LibSelfCompT, typename LibSelfCompPortT, typename LibPortT>
typename SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::Iterator
SelfComponentPorts<LibSelfCompT, LibSelfCompPortT, LibPortT>::begin() const noexcept
}
template <typename DataT>
}
template <typename DataT>
-SelfSourceComponent::OutputPorts::Port SelfSourceComponent::addOutputPort(const char * const name,
- DataT& data) const
+SelfSourceComponent::OutputPorts::Port
+SelfSourceComponent::addOutputPort(const bt2c::CStringView name, DataT& data) const
{
return this->_addOutputPort(name, &data);
}
inline SelfSourceComponent::OutputPorts::Port
{
return this->_addOutputPort(name, &data);
}
inline SelfSourceComponent::OutputPorts::Port
-SelfSourceComponent::addOutputPort(const char * const name) const
+SelfSourceComponent::addOutputPort(const bt2c::CStringView name) const
{
return this->_addOutputPort<void>(name, nullptr);
}
{
return this->_addOutputPort<void>(name, nullptr);
}
-template <typename DataT>
-SelfSourceComponent::OutputPorts::Port SelfSourceComponent::addOutputPort(const std::string& name,
- DataT& data) const
-{
- return this->_addOutputPort(name.data(), &data);
-}
-
-inline SelfSourceComponent::OutputPorts::Port
-SelfSourceComponent::addOutputPort(const std::string& name) const
-{
- return this->_addOutputPort<void>(name.data(), nullptr);
-}
-
inline SelfSourceComponent::OutputPorts SelfSourceComponent::outputPorts() const noexcept
{
return OutputPorts {this->libObjPtr()};
inline SelfSourceComponent::OutputPorts SelfSourceComponent::outputPorts() const noexcept
{
return OutputPorts {this->libObjPtr()};
}
template <typename DataT>
}
template <typename DataT>
-SelfFilterComponent::OutputPorts::Port SelfFilterComponent::addOutputPort(const char * const name,
- DataT& data) const
+SelfFilterComponent::OutputPorts::Port
+SelfFilterComponent::addOutputPort(const bt2c::CStringView name, DataT& data) const
{
return this->_addOutputPort(name, &data);
}
inline SelfFilterComponent::OutputPorts::Port
{
return this->_addOutputPort(name, &data);
}
inline SelfFilterComponent::OutputPorts::Port
-SelfFilterComponent::addOutputPort(const char * const name) const
+SelfFilterComponent::addOutputPort(const bt2c::CStringView name) const
{
return this->_addOutputPort<void>(name, nullptr);
}
{
return this->_addOutputPort<void>(name, nullptr);
}
-template <typename DataT>
-SelfFilterComponent::OutputPorts::Port SelfFilterComponent::addOutputPort(const std::string& name,
- DataT& data) const
-{
- return this->_addOutputPort(name.data(), &data);
-}
-
-inline SelfFilterComponent::OutputPorts::Port
-SelfFilterComponent::addOutputPort(const std::string& name) const
-{
- return this->_addOutputPort<void>(name.data(), nullptr);
-}
-
inline SelfFilterComponent::OutputPorts SelfFilterComponent::outputPorts() const noexcept
{
return OutputPorts {this->libObjPtr()};
inline SelfFilterComponent::OutputPorts SelfFilterComponent::outputPorts() const noexcept
{
return OutputPorts {this->libObjPtr()};
}
template <typename DataT>
}
template <typename DataT>
-SelfFilterComponent::InputPorts::Port SelfFilterComponent::addInputPort(const char * const name,
- DataT& data) const
+SelfFilterComponent::InputPorts::Port
+SelfFilterComponent::addInputPort(const bt2c::CStringView name, DataT& data) const
{
return this->_addInputPort(name, &data);
}
inline SelfFilterComponent::InputPorts::Port
{
return this->_addInputPort(name, &data);
}
inline SelfFilterComponent::InputPorts::Port
-SelfFilterComponent::addInputPort(const char * const name) const
+SelfFilterComponent::addInputPort(const bt2c::CStringView name) const
{
return this->_addInputPort<void>(name, nullptr);
}
{
return this->_addInputPort<void>(name, nullptr);
}
-template <typename DataT>
-SelfFilterComponent::InputPorts::Port SelfFilterComponent::addInputPort(const std::string& name,
- DataT& data) const
-{
- return this->_addInputPort(name.data(), &data);
-}
-
-inline SelfFilterComponent::InputPorts::Port
-SelfFilterComponent::addInputPort(const std::string& name) const
-{
- return this->_addInputPort<void>(name.data(), nullptr);
-}
-
inline SelfFilterComponent::InputPorts SelfFilterComponent::inputPorts() const noexcept
{
return InputPorts {this->libObjPtr()};
inline SelfFilterComponent::InputPorts SelfFilterComponent::inputPorts() const noexcept
{
return InputPorts {this->libObjPtr()};
}
template <typename DataT>
}
template <typename DataT>
-SelfSinkComponent::InputPorts::Port SelfSinkComponent::addInputPort(const char * const name,
+SelfSinkComponent::InputPorts::Port SelfSinkComponent::addInputPort(const bt2c::CStringView name,
DataT& data) const
{
return this->_addInputPort(name, &data);
}
inline SelfSinkComponent::InputPorts::Port
DataT& data) const
{
return this->_addInputPort(name, &data);
}
inline SelfSinkComponent::InputPorts::Port
-SelfSinkComponent::addInputPort(const char * const name) const
+SelfSinkComponent::addInputPort(const bt2c::CStringView name) const
{
return this->_addInputPort<void>(name, nullptr);
}
{
return this->_addInputPort<void>(name, nullptr);
}
-template <typename DataT>
-SelfSinkComponent::InputPorts::Port SelfSinkComponent::addInputPort(const std::string& name,
- DataT& data) const
-{
- return this->_addInputPort(name.data(), &data);
-}
-
-inline SelfSinkComponent::InputPorts::Port
-SelfSinkComponent::addInputPort(const std::string& name) const
-{
- return this->_addInputPort<void>(name.data(), nullptr);
-}
-
inline SelfSinkComponent::InputPorts SelfSinkComponent::inputPorts() const noexcept
{
return InputPorts {this->libObjPtr()};
inline SelfSinkComponent::InputPorts SelfSinkComponent::inputPorts() const noexcept
{
return InputPorts {this->libObjPtr()};
return bt_stream_get_id(this->libObjPtr());
}
return bt_stream_get_id(this->libObjPtr());
}
- void name(const char * const name) const
+ void name(const bt2c::CStringView name) const
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstStream`.");
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstStream`.");
- void name(const std::string& name) const
- {
- this->name(name.data());
- }
-
bt2c::CStringView name() const noexcept
{
return bt_stream_get_name(this->libObjPtr());
bt2c::CStringView name() const noexcept
{
return bt_stream_get_name(this->libObjPtr());
Class cls() const noexcept;
Class cls() const noexcept;
- void name(const char * const name) const
+ void name(const bt2c::CStringView name) const
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTrace`.");
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTrace`.");
- void name(const std::string& name) const
- {
- this->name(name.data());
- }
-
bt2c::CStringView name() const noexcept
{
return bt_trace_get_name(this->libObjPtr());
bt2c::CStringView name() const noexcept
{
return bt_trace_get_name(this->libObjPtr());
return _Spec::streamById(this->libObjPtr(), id);
}
return _Spec::streamById(this->libObjPtr(), id);
}
- void environmentEntry(const char * const name, const std::int64_t val) const
+ void environmentEntry(const bt2c::CStringView name, const std::int64_t val) const
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTrace`.");
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTrace`.");
- void environmentEntry(const std::string& name, const std::int64_t val) const
- {
- this->environmentEntry(name.data(), val);
- }
-
- void environmentEntry(const char * const name, const char * const val) const
+ void environmentEntry(const bt2c::CStringView name, const bt2c::CStringView val) const
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTrace`.");
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstTrace`.");
- void environmentEntry(const std::string& name, const char * const val) const
- {
- this->environmentEntry(name.data(), val);
- }
-
- void environmentEntry(const char * const name, const std::string& val) const
- {
- this->environmentEntry(name, val.data());
- }
-
- void environmentEntry(const std::string& name, const std::string& val) const
- {
- this->environmentEntry(name.data(), val.data());
- }
-
std::uint64_t environmentSize() const noexcept
{
return bt_trace_get_environment_entry_count(this->libObjPtr());
std::uint64_t environmentSize() const noexcept
{
return bt_trace_get_environment_entry_count(this->libObjPtr());
return ConstEnvironmentEntry {name, ConstValue {libObjPtr}};
}
return ConstEnvironmentEntry {name, ConstValue {libObjPtr}};
}
- OptionalBorrowedObject<ConstValue> environmentEntry(const char * const name) const noexcept
+ OptionalBorrowedObject<ConstValue> environmentEntry(const bt2c::CStringView name) const noexcept
{
return bt_trace_borrow_environment_entry_value_by_name_const(this->libObjPtr(), name);
}
{
return bt_trace_borrow_environment_entry_value_by_name_const(this->libObjPtr(), name);
}
- OptionalBorrowedObject<ConstValue> environmentEntry(const std::string& name) const noexcept
- {
- return this->environmentEntry(name.data());
- }
-
template <typename LibValT>
void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
{
template <typename LibValT>
void userAttributes(const CommonMapValue<LibValT> userAttrs) const noexcept
{
return bt_event_class_get_id(this->libObjPtr());
}
return bt_event_class_get_id(this->libObjPtr());
}
- void name(const char * const name) const
+ void name(const bt2c::CStringView name) const
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
- void name(const std::string& name) const
- {
- this->name(name.data());
- }
-
bt2c::CStringView name() const noexcept
{
return bt_event_class_get_name(this->libObjPtr());
bt2c::CStringView name() const noexcept
{
return bt_event_class_get_name(this->libObjPtr());
- void emfUri(const char * const emfUri) const
+ void emfUri(const bt2c::CStringView emfUri) const
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstEventClass`.");
- void emfUri(const std::string& emfUri) const
- {
- this->emfUri(emfUri.data());
- }
-
bt2c::CStringView emfUri() const noexcept
{
return bt_event_class_get_emf_uri(this->libObjPtr());
bt2c::CStringView emfUri() const noexcept
{
return bt_event_class_get_emf_uri(this->libObjPtr());
return bt_stream_class_get_id(this->libObjPtr());
}
return bt_stream_class_get_id(this->libObjPtr());
}
- void name(const char * const name) const
+ void name(const bt2c::CStringView name) const
{
static_assert(!std::is_const<LibObjT>::value,
"Not available with `bt2::ConstStreamClass`.");
{
static_assert(!std::is_const<LibObjT>::value,
"Not available with `bt2::ConstStreamClass`.");
- void name(const std::string& name) const
- {
- this->name(name.data());
- }
-
bt2c::CStringView name() const noexcept
{
return bt_stream_class_get_name(this->libObjPtr());
bt2c::CStringView name() const noexcept
{
return bt_stream_class_get_name(this->libObjPtr());
CommonValueRawValueProxy& operator=(std::uint64_t rawVal) noexcept;
CommonValueRawValueProxy& operator=(double rawVal) noexcept;
CommonValueRawValueProxy& operator=(const char *rawVal);
CommonValueRawValueProxy& operator=(std::uint64_t rawVal) noexcept;
CommonValueRawValueProxy& operator=(double rawVal) noexcept;
CommonValueRawValueProxy& operator=(const char *rawVal);
- CommonValueRawValueProxy& operator=(const std::string& rawVal);
+ CommonValueRawValueProxy& operator=(bt2c::CStringView rawVal);
operator bool() const noexcept;
operator std::int64_t() const noexcept;
operator std::uint64_t() const noexcept;
operator double() const noexcept;
operator bool() const noexcept;
operator std::int64_t() const noexcept;
operator std::uint64_t() const noexcept;
operator double() const noexcept;
- operator const char *() const noexcept;
operator bt2c::CStringView() const noexcept;
private:
operator bt2c::CStringView() const noexcept;
private:
this->asMap().insert(std::forward<KeyT>(key), std::forward<ValT>(val));
}
this->asMap().insert(std::forward<KeyT>(key), std::forward<ValT>(val));
}
- 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;
+ CommonArrayValue<bt_value> insertEmptyArray(bt2c::CStringView key) const;
+ CommonMapValue<bt_value> insertEmptyMap(bt2c::CStringView key) const;
Shared shared() const noexcept
{
Shared shared() const noexcept
{
template <typename ValueObjT>
CommonValueRawValueProxy<ValueObjT>&
template <typename ValueObjT>
CommonValueRawValueProxy<ValueObjT>&
-CommonValueRawValueProxy<ValueObjT>::operator=(const std::string& rawVal)
+CommonValueRawValueProxy<ValueObjT>::operator=(const bt2c::CStringView rawVal)
{
_mObj.asString().value(rawVal);
return *this;
{
_mObj.asString().value(rawVal);
return *this;
return _mObj.asReal().value();
}
return _mObj.asReal().value();
}
-template <typename ValueObjT>
-CommonValueRawValueProxy<ValueObjT>::operator const char *() const noexcept
-{
- return _mObj.asString().value();
-}
-
template <typename ValueObjT>
CommonValueRawValueProxy<ValueObjT>::operator bt2c::CStringView() const noexcept
{
template <typename ValueObjT>
CommonValueRawValueProxy<ValueObjT>::operator bt2c::CStringView() const noexcept
{
BT_ASSERT_DBG(this->isString());
}
BT_ASSERT_DBG(this->isString());
}
- static Shared create(const char * const rawVal = "")
+ static Shared create(const bt2c::CStringView rawVal = "")
{
const auto libObjPtr = bt_value_string_create_init(rawVal);
{
const auto libObjPtr = bt_value_string_create_init(rawVal);
return CommonStringValue::Shared::createWithoutRef(libObjPtr);
}
return CommonStringValue::Shared::createWithoutRef(libObjPtr);
}
- static Shared create(const std::string& rawVal)
- {
- return CommonStringValue::create(rawVal.data());
- }
-
template <typename OtherLibObjT>
CommonStringValue(const CommonStringValue<OtherLibObjT> val) noexcept : _ThisCommonValue {val}
{
template <typename OtherLibObjT>
CommonStringValue(const CommonStringValue<OtherLibObjT> val) noexcept : _ThisCommonValue {val}
{
return CommonStringValue<const bt_value> {*this};
}
return CommonStringValue<const bt_value> {*this};
}
- RawStringValueProxy<CommonStringValue> operator*() const noexcept
+ RawValueProxy<CommonStringValue> operator*() const noexcept
- return RawStringValueProxy<CommonStringValue> {*this};
+ return RawValueProxy<CommonStringValue> {*this};
}
void value(const Value val) const
}
void value(const Value val) const
- void value(const char * const val) const
- {
- this->value(bt2c::CStringView {val});
- }
-
- void value(const std::string& val) const
- {
- this->value(bt2c::CStringView {val.data()});
- }
-
Value value() const noexcept
{
return bt_value_string_get(this->libObjPtr());
Value value() const noexcept
{
return bt_value_string_get(this->libObjPtr());
this->_handleAppendLibStatus(status);
}
this->_handleAppendLibStatus(status);
}
- void append(const std::string& rawVal) const
+ void append(const bt2c::CStringView rawVal) const
{
this->append(rawVal.data());
}
{
this->append(rawVal.data());
}
- void operator+=(const std::string& rawVal) const
+ void operator+=(const bt2c::CStringView rawVal) const
{
this->append(rawVal);
}
{
this->append(rawVal);
}
return this->length() == 0;
}
return this->length() == 0;
}
- OptionalBorrowedObject<CommonValue<LibObjT>> operator[](const char * const key) const noexcept
+ OptionalBorrowedObject<CommonValue<LibObjT>>
+ operator[](const bt2c::CStringView key) const noexcept
{
return internal::CommonMapValueSpec<LibObjT>::entryByKey(this->libObjPtr(), key);
}
{
return internal::CommonMapValueSpec<LibObjT>::entryByKey(this->libObjPtr(), key);
}
- OptionalBorrowedObject<CommonValue<LibObjT>> operator[](const std::string& key) const noexcept
- {
- return (*this)[key.data()];
- }
-
- bool hasEntry(const char * const key) const noexcept
+ bool hasEntry(const bt2c::CStringView key) const noexcept
{
return static_cast<bool>(bt_value_map_has_entry(this->libObjPtr(), key));
}
{
return static_cast<bool>(bt_value_map_has_entry(this->libObjPtr(), key));
}
- bool hasEntry(const std::string& key) const noexcept
- {
- return this->hasEntry(key.data());
- }
-
- void insert(const char * const key, const Value val) const
+ void insert(const bt2c::CStringView key, const Value val) const
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
this->_handleInsertLibStatus(status);
}
this->_handleInsertLibStatus(status);
}
- void insert(const std::string& key, const Value val) const
- {
- this->insert(key.data(), val);
- }
-
- void insert(const char * const key, const bool rawVal) const
+ void insert(const bt2c::CStringView key, const bool rawVal) const
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
this->_handleInsertLibStatus(status);
}
this->_handleInsertLibStatus(status);
}
- 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) const
+ void insert(const bt2c::CStringView key, const std::uint64_t rawVal) const
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
this->_handleInsertLibStatus(status);
}
this->_handleInsertLibStatus(status);
}
-
- 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) const
+ void insert(const bt2c::CStringView key, const std::int64_t rawVal) const
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
this->_handleInsertLibStatus(status);
}
this->_handleInsertLibStatus(status);
}
- 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) const
+ void insert(const bt2c::CStringView key, const double rawVal) const
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
this->_handleInsertLibStatus(status);
}
this->_handleInsertLibStatus(status);
}
- 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) const
+ void insert(const bt2c::CStringView key, const char *rawVal) const
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
this->_handleInsertLibStatus(status);
}
this->_handleInsertLibStatus(status);
}
- void insert(const char * const key, const std::string& rawVal) const
+ void insert(const bt2c::CStringView key, const bt2c::CStringView rawVal) const
- this->insert(key, rawVal.data());
+ return this->insert(key, rawVal.data());
- 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) const
- {
- this->insert(key.data(), rawVal.data());
- }
-
- 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;
+ CommonArrayValue<bt_value> insertEmptyArray(bt2c::CStringView key) const;
+ CommonMapValue<bt_value> insertEmptyMap(bt2c::CStringView key) const;
void forEach(const internal::CommonMapValueForEachUserFunc<CommonValue<LibObjT>>& func) const
{
void forEach(const internal::CommonMapValueForEachUserFunc<CommonValue<LibObjT>>& func) const
{
}
template <typename LibObjT>
}
template <typename LibObjT>
-ArrayValue CommonValue<LibObjT>::insertEmptyArray(const char * const key) const
-{
- return this->asMap().insertEmptyArray(key);
-}
-
-template <typename LibObjT>
-ArrayValue CommonValue<LibObjT>::insertEmptyArray(const std::string& key) const
+ArrayValue CommonValue<LibObjT>::insertEmptyArray(const bt2c::CStringView key) const
{
return this->asMap().insertEmptyArray(key);
}
template <typename LibObjT>
{
return this->asMap().insertEmptyArray(key);
}
template <typename LibObjT>
-MapValue CommonValue<LibObjT>::insertEmptyMap(const char * const key) const
-{
- return this->asMap().insertEmptyMap(key);
-}
-
-template <typename LibObjT>
-MapValue CommonValue<LibObjT>::insertEmptyMap(const std::string& key) const
+MapValue CommonValue<LibObjT>::insertEmptyMap(const bt2c::CStringView key) const
{
return this->asMap().insertEmptyMap(key);
}
{
return this->asMap().insertEmptyMap(key);
}
}
template <typename LibObjT>
}
template <typename LibObjT>
-ArrayValue CommonMapValue<LibObjT>::insertEmptyArray(const char * const key) const
+ArrayValue CommonMapValue<LibObjT>::insertEmptyArray(const bt2c::CStringView key) const
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
}
template <typename LibObjT>
}
template <typename LibObjT>
-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) const
+MapValue CommonMapValue<LibObjT>::insertEmptyMap(const bt2c::CStringView key) const
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
{
static_assert(!std::is_const<LibObjT>::value, "Not available with `bt2::ConstMapValue`.");
return MapValue {libEntryPtr};
}
return MapValue {libEntryPtr};
}
-template <typename LibObjT>
-MapValue CommonMapValue<LibObjT>::insertEmptyMap(const std::string& key) const
-{
- return this->insertEmptyMap(key.data());
-}
-
inline BoolValue::Shared createValue(const bool rawVal)
{
return BoolValue::create(rawVal);
inline BoolValue::Shared createValue(const bool rawVal)
{
return BoolValue::create(rawVal);
return StringValue::create(rawVal);
}
return StringValue::create(rawVal);
}
-inline StringValue::Shared createValue(const std::string& rawVal)
+inline StringValue::Shared createValue(const bt2c::CStringView rawVal)
{
return StringValue::create(rawVal);
}
{
return StringValue::create(rawVal);
}