cpp-common/bt2c: add bt2c::contains()
[babeltrace.git] / src / cpp-common / bt2 / clock-class.hpp
index bd127dfa673a0e58cde6f43597111884520d13a6..f8fc17e04cc727ef4848445738574819aa8061fa 100644 (file)
@@ -8,14 +8,13 @@
 #define BABELTRACE_CPP_COMMON_BT2_CLOCK_CLASS_HPP
 
 #include <cstdint>
-#include <string>
 #include <type_traits>
 
 #include <babeltrace2/babeltrace.h>
 
-#include "cpp-common/optional.hpp"
-#include "cpp-common/string_view.hpp"
-#include "cpp-common/uuid-view.hpp"
+#include "cpp-common/bt2c/c-string-view.hpp"
+#include "cpp-common/bt2c/uuid.hpp"
+#include "cpp-common/bt2s/optional.hpp"
 
 #include "borrowed-object.hpp"
 #include "exc.hpp"
@@ -92,13 +91,13 @@ class CommonClockClass final : public BorrowedObject<LibObjT>
 {
 private:
     using typename BorrowedObject<LibObjT>::_ThisBorrowedObject;
-    using typename BorrowedObject<LibObjT>::_LibObjPtr;
 
 public:
+    using typename BorrowedObject<LibObjT>::LibObjPtr;
     using Shared = SharedObject<CommonClockClass, LibObjT, internal::ClockClassRefFuncs>;
     using UserAttributes = internal::DepUserAttrs<LibObjT>;
 
-    explicit CommonClockClass(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr}
+    explicit CommonClockClass(const LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr}
     {
     }
 
@@ -173,7 +172,7 @@ public:
         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`.");
 
@@ -184,23 +183,12 @@ public:
         }
     }
 
-    void name(const std::string& name) const
+    bt2c::CStringView name() const noexcept
     {
-        this->name(name.data());
+        return bt_clock_class_get_name(this->libObjPtr());
     }
 
-    nonstd::optional<bpstd::string_view> name() const noexcept
-    {
-        const auto name = bt_clock_class_get_name(this->libObjPtr());
-
-        if (name) {
-            return name;
-        }
-
-        return nonstd::nullopt;
-    }
-
-    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`.");
 
@@ -211,20 +199,9 @@ public:
         }
     }
 
-    void description(const std::string& description) const
+    bt2c::CStringView description() const noexcept
     {
-        this->description(description.data());
-    }
-
-    nonstd::optional<bpstd::string_view> description() const noexcept
-    {
-        const auto description = bt_clock_class_get_description(this->libObjPtr());
-
-        if (description) {
-            return description;
-        }
-
-        return nonstd::nullopt;
+        return bt_clock_class_get_description(this->libObjPtr());
     }
 
     void uuid(const std::uint8_t * const uuid) const noexcept
@@ -232,15 +209,15 @@ public:
         bt_clock_class_set_uuid(this->libObjPtr(), uuid);
     }
 
-    nonstd::optional<bt2_common::UuidView> uuid() const noexcept
+    bt2s::optional<bt2c::UuidView> uuid() const noexcept
     {
         const auto uuid = bt_clock_class_get_uuid(this->libObjPtr());
 
         if (uuid) {
-            return bt2_common::UuidView {uuid};
+            return bt2c::UuidView {uuid};
         }
 
-        return nonstd::nullopt;
+        return bt2s::nullopt;
     }
 
     template <typename LibValT>
This page took 0.02511 seconds and 4 git commands to generate.