cpp-common/bt2: `User*Component`: pass query method data to user `_query` methods
[babeltrace.git] / src / cpp-common / bt2 / trace-ir.hpp
index 06d4ca53478bdaeca2b204e31ac21693d7e163aa..7171138d340ca309ab900c53198dbc954f6a604b 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <babeltrace2/babeltrace.h>
 
+#include "cpp-common/bt2c/c-string-view.hpp"
 #include "cpp-common/bt2s/optional.hpp"
 
 #include "borrowed-object.hpp"
@@ -444,7 +445,7 @@ public:
         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`.");
 
@@ -455,12 +456,7 @@ public:
         }
     }
 
-    void name(const std::string& name) const
-    {
-        this->name(name.data());
-    }
-
-    const char *name() const noexcept
+    bt2c::CStringView name() const noexcept
     {
         return bt_stream_get_name(this->libObjPtr());
     }
@@ -609,7 +605,7 @@ public:
 
     struct ConstEnvironmentEntry
     {
-        const char *name;
+        bt2c::CStringView name;
         ConstValue value;
     };
 
@@ -636,7 +632,7 @@ public:
 
     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`.");
 
@@ -647,12 +643,7 @@ public:
         }
     }
 
-    void name(const std::string& name) const
-    {
-        this->name(name.data());
-    }
-
-    const char *name() const noexcept
+    bt2c::CStringView name() const noexcept
     {
         return bt_trace_get_name(this->libObjPtr());
     }
@@ -688,7 +679,7 @@ public:
         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`.");
 
@@ -699,12 +690,7 @@ public:
         }
     }
 
-    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`.");
 
@@ -715,21 +701,6 @@ public:
         }
     }
 
-    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());
@@ -745,16 +716,11 @@ public:
         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);
     }
 
-    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
     {
@@ -941,7 +907,7 @@ public:
         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`.");
 
@@ -952,12 +918,7 @@ public:
         }
     }
 
-    void name(const std::string& name) const
-    {
-        this->name(name.data());
-    }
-
-    const char *name() const noexcept
+    bt2c::CStringView name() const noexcept
     {
         return bt_event_class_get_name(this->libObjPtr());
     }
@@ -973,16 +934,15 @@ public:
     bt2s::optional<LogLevel> logLevel() const noexcept
     {
         bt_event_class_log_level libLogLevel;
-        const auto avail = bt_event_class_get_log_level(this->libObjPtr(), &libLogLevel);
 
-        if (avail == BT_PROPERTY_AVAILABILITY_AVAILABLE) {
+        if (bt_event_class_get_log_level(this->libObjPtr(), &libLogLevel)) {
             return static_cast<LogLevel>(libLogLevel);
         }
 
         return bt2s::nullopt;
     }
 
-    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`.");
 
@@ -993,12 +953,7 @@ public:
         }
     }
 
-    void emfUri(const std::string& emfUri) const
-    {
-        this->emfUri(emfUri.data());
-    }
-
-    const char *emfUri() const noexcept
+    bt2c::CStringView emfUri() const noexcept
     {
         return bt_event_class_get_emf_uri(this->libObjPtr());
     }
@@ -1285,7 +1240,7 @@ public:
         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`.");
@@ -1297,12 +1252,7 @@ public:
         }
     }
 
-    void name(const std::string& name) const
-    {
-        this->name(name.data());
-    }
-
-    const char *name() const noexcept
+    bt2c::CStringView name() const noexcept
     {
         return bt_stream_class_get_name(this->libObjPtr());
     }
This page took 0.024563 seconds and 4 git commands to generate.