#include <babeltrace2/babeltrace.h>
+#include "cpp-common/bt2c/c-string-view.hpp"
#include "cpp-common/bt2c/uuid.hpp"
#include "cpp-common/bt2s/optional.hpp"
this->name(name.data());
}
- const char *name() const noexcept
+ bt2c::CStringView name() const noexcept
{
return bt_clock_class_get_name(this->libObjPtr());
}
this->description(description.data());
}
- const char *description() const noexcept
+ bt2c::CStringView description() const noexcept
{
return bt_clock_class_get_description(this->libObjPtr());
}
#include "logging.hpp"
+#include "cpp-common/bt2c/c-string-view.hpp"
+
#include "borrowed-object-iterator.hpp"
#include "borrowed-object.hpp"
#include "shared-object.hpp"
return static_cast<bool>(bt_component_is_sink(this->libObjPtr()));
}
- const char *name() const noexcept
+ bt2c::CStringView name() const noexcept
{
return bt_component_get_name(this->libObjPtr());
}
}
public:
- const char *name() const noexcept
+ bt2c::CStringView name() const noexcept
{
return this->_constComponent().name();
}
{
}
- const char *name() const noexcept
+ bt2c::CStringView name() const noexcept
{
return bt_port_get_name(this->_libConstPortPtr());
}
#include <babeltrace2/babeltrace.h>
#include "common/assert.h"
+#include "cpp-common/bt2c/c-string-view.hpp"
#include "cpp-common/bt2s/optional.hpp"
#include "borrowed-object-iterator.hpp"
internal::ConstEnumerationFieldClassMappingSpec<LibObjT>::ranges(this->libObjPtr())};
}
- const char *label() const noexcept
+ bt2c::CStringView label() const noexcept
{
return internal::ConstEnumerationFieldClassMappingSpec<LibObjT>::label(this->libObjPtr());
}
return CommonStructureFieldClassMember<const bt_field_class_structure_member> {*this};
}
- const char *name() const noexcept
+ bt2c::CStringView name() const noexcept
{
return bt_field_class_structure_member_get_name(this->libObjPtr());
}
return CommonVariantFieldClassOption<const bt_field_class_variant_option> {*this};
}
- const char *name() const noexcept
+ bt2c::CStringView name() const noexcept
{
return bt_field_class_variant_option_get_name(this->libObjPtr());
}
return ConstVariantFieldClassOption {_Spec::asBaseOption(this->libObjPtr())};
}
- const char *name() const noexcept
+ bt2c::CStringView name() const noexcept
{
return this->asBaseOption().name();
}
#include <babeltrace2/babeltrace.h>
#include "common/assert.h"
+#include "cpp-common/bt2c/c-string-view.hpp"
#include "borrowed-object.hpp"
#include "field-class.hpp"
return _mLen;
}
- const char *operator[](const std::uint64_t index) const noexcept
+ bt2c::CStringView operator[](const std::uint64_t index) const noexcept
{
return _mLabels[index];
}
public:
using typename CommonField<LibObjT>::LibObjPtr;
- using Value = const char *;
+ using Value = bt2c::CStringView;
explicit CommonStringField(const LibObjPtr libObjPtr) noexcept : _ThisCommonField {libObjPtr}
{
return RawStringValueProxy<CommonStringField> {*this};
}
- void value(const char * const val) const
+ void value(const Value& val) const
{
static_assert(!std::is_const<LibObjT>::value,
"Not available with `bt2::ConstStringField`.");
- const auto status = bt_field_string_set_value(this->libObjPtr(), val);
+ const auto status = bt_field_string_set_value(this->libObjPtr(), *val);
if (status == BT_FIELD_STRING_SET_VALUE_STATUS_MEMORY_ERROR) {
throw MemoryError {};
}
}
+ void value(const char * const val) const
+ {
+ this->value(bt2c::CStringView {val});
+ }
+
void value(const std::string& val) const
{
- this->value(val.data());
+ this->value(bt2c::CStringView {val.data()});
}
void append(const char * const begin, const std::uint64_t len) const
}
}
+ void append(const char * const val) const
+ {
+ this->append(val, std::strlen(val));
+ }
+
void append(const std::string& val) const
{
this->append(val.data(), val.size());
bt_field_string_clear(this->libObjPtr());
}
- const char *value() const noexcept
+ Value value() const noexcept
{
return bt_field_string_get_value(this->libObjPtr());
}
#include <babeltrace2/babeltrace.h>
+#include "cpp-common/bt2c/c-string-view.hpp"
#include "cpp-common/bt2c/logging.hpp"
#include "cpp-common/vendor/fmt/core.h"
}
protected:
- const char *_name() const noexcept
+ bt2c::CStringView _name() const noexcept
{
return _mSelfComp.name();
}
#include <string>
+#include "cpp-common/bt2c/c-string-view.hpp"
+
namespace bt2 {
template <typename ObjT>
{
}
+ RawStringValueProxy& operator=(const char * const rawVal)
+ {
+ RawValueProxy<ObjT>::operator=(bt2c::CStringView {rawVal});
+ return *this;
+ }
+
RawStringValueProxy& operator=(const std::string& rawVal)
{
- RawValueProxy<ObjT>::operator=(rawVal.data());
+ RawValueProxy<ObjT>::operator=(bt2c::CStringView {rawVal.data()});
return *this;
}
};
#include <babeltrace2/babeltrace.h>
+#include "cpp-common/bt2c/c-string-view.hpp"
+
#include "borrowed-object.hpp"
namespace bt2 {
{
}
- const char *name() const noexcept
+ bt2c::CStringView name() const noexcept
{
return bt_component_class_get_name(this->_libCompClsPtr());
}
- const char *description() const noexcept
+ bt2c::CStringView description() const noexcept
{
return bt_component_class_get_description(this->_libCompClsPtr());
}
- const char *help() const noexcept
+ bt2c::CStringView help() const noexcept
{
return bt_component_class_get_help(this->_libCompClsPtr());
}
#include "logging.hpp"
#include "common/assert.h"
+#include "cpp-common/bt2c/c-string-view.hpp"
#include "borrowed-object-iterator.hpp"
#include "borrowed-object.hpp"
return this->asConstComponent().isSink();
}
- const char *name() const noexcept
+ bt2c::CStringView name() const noexcept
{
return this->asConstComponent().name();
}
}
public:
- const char *name() const noexcept
+ bt2c::CStringView name() const noexcept
{
return this->_selfComponent().name();
}
internal::SelfComponentPortSpec<LibSelfCompPortT>::asConstPort(this->libObjPtr())};
}
- const char *name() const noexcept
+ bt2c::CStringView name() const noexcept
{
return this->asConstPort().name();
}
#include <babeltrace2/babeltrace.h>
+#include "cpp-common/bt2c/c-string-view.hpp"
#include "cpp-common/bt2s/optional.hpp"
#include "borrowed-object.hpp"
this->name(name.data());
}
- const char *name() const noexcept
+ bt2c::CStringView name() const noexcept
{
return bt_stream_get_name(this->libObjPtr());
}
struct ConstEnvironmentEntry
{
- const char *name;
+ bt2c::CStringView name;
ConstValue value;
};
this->name(name.data());
}
- const char *name() const noexcept
+ bt2c::CStringView name() const noexcept
{
return bt_trace_get_name(this->libObjPtr());
}
this->name(name.data());
}
- const char *name() const noexcept
+ bt2c::CStringView name() const noexcept
{
return bt_event_class_get_name(this->libObjPtr());
}
this->emfUri(emfUri.data());
}
- const char *emfUri() const noexcept
+ bt2c::CStringView emfUri() const noexcept
{
return bt_event_class_get_emf_uri(this->libObjPtr());
}
this->name(name.data());
}
- const char *name() const noexcept
+ bt2c::CStringView name() const noexcept
{
return bt_stream_class_get_name(this->libObjPtr());
}
#include "common/assert.h"
#include "common/common.h"
+#include "cpp-common/bt2c/c-string-view.hpp"
#include "borrowed-object-iterator.hpp"
#include "borrowed-object.hpp"
operator std::uint64_t() const noexcept;
operator double() const noexcept;
operator const char *() const noexcept;
+ operator bt2c::CStringView() const noexcept;
private:
ValueObjT _mObj;
CommonValueRawValueProxy<ValueObjT>&
CommonValueRawValueProxy<ValueObjT>::operator=(const std::string& rawVal)
{
- return *this = rawVal.data();
+ _mObj.asString().value(rawVal);
+ return *this;
}
template <typename ValueObjT>
return _mObj.asString().value();
}
+template <typename ValueObjT>
+CommonValueRawValueProxy<ValueObjT>::operator bt2c::CStringView() const noexcept
+{
+ return _mObj.asString().value();
+}
+
namespace internal {
struct ValueTypeDescr
public:
using typename CommonValue<LibObjT>::LibObjPtr;
using Shared = SharedValue<CommonStringValue<LibObjT>, LibObjT>;
- using Value = const char *;
+ using Value = bt2c::CStringView;
explicit CommonStringValue(const LibObjPtr libObjPtr) noexcept : _ThisCommonValue {libObjPtr}
{
static_assert(!std::is_const<LibObjT>::value,
"Not available with `bt2::ConstStringValue`.");
- const auto status = bt_value_string_set(this->libObjPtr(), val);
+ const auto status = bt_value_string_set(this->libObjPtr(), *val);
if (status == BT_VALUE_STRING_SET_STATUS_MEMORY_ERROR) {
throw MemoryError {};
}
}
+ void value(const char * const val) const
+ {
+ this->value(bt2c::CStringView {val});
+ }
+
void value(const std::string& val) const
{
- this->value(val.data());
+ this->value(bt2c::CStringView {val.data()});
}
- const char *value() const noexcept
+ Value value() const noexcept
{
return bt_value_string_get(this->libObjPtr());
}
* First argument is the entry's key, second is its value.
*/
template <typename ObjT>
-using CommonMapValueForEachUserFunc = std::function<void(const char *, ObjT)>;
+using CommonMapValueForEachUserFunc = std::function<void(bt2c::CStringView, ObjT)>;
/*
* Template of a function to be passed to bt_value_map_foreach_entry()