cpp-common/bt2c: add `Uuid::Uuid(bt2c::CStringView)`
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 29 Feb 2024 19:17:18 +0000 (14:17 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 26 Mar 2024 18:56:36 +0000 (14:56 -0400)
Add a `Uuid` constructor that takes `bt2c::CStringView` and remove those
that take a `const char *` and `const std::string &`.  The implicit
conversions to `bt2c::CStringView` should be able to handle all those
types.

Change-Id: I1714fd2aa38c18a047b097908af7b52afebeab72
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11953
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
src/cpp-common/bt2c/uuid.hpp

index 30ff54a86b59a1908af1e2a68a8df5b9533209bf..30f301447a2be7bbde5a38ba71e980d70c070c80 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "common/assert.h"
 #include "common/uuid.h"
+#include "cpp-common/bt2c/c-string-view.hpp"
 
 namespace bt2c {
 
@@ -134,16 +135,12 @@ public:
         this->_setFromPtr(uuid);
     }
 
-    explicit Uuid(const char * const str) noexcept
+    explicit Uuid(const bt2c::CStringView str) noexcept
     {
-        const auto ret = bt_uuid_from_str(str, _mUuid.data());
+        const auto ret = bt_uuid_from_str(str.data(), _mUuid.data());
         BT_ASSERT(ret == 0);
     }
 
-    explicit Uuid(const std::string& str) noexcept : Uuid {str.c_str()}
-    {
-    }
-
     explicit Uuid(const UuidView& view) noexcept : Uuid {view.data()}
     {
     }
This page took 0.024794 seconds and 4 git commands to generate.