From 82d339d7e94fbbc086a9a91623088bcd247f16a6 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 29 Feb 2024 14:17:18 -0500 Subject: [PATCH] cpp-common/bt2c: add `Uuid::Uuid(bt2c::CStringView)` 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 Reviewed-on: https://review.lttng.org/c/babeltrace/+/11953 Reviewed-by: Philippe Proulx Tested-by: jenkins --- src/cpp-common/bt2c/uuid.hpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/cpp-common/bt2c/uuid.hpp b/src/cpp-common/bt2c/uuid.hpp index 30ff54a8..30f30144 100644 --- a/src/cpp-common/bt2c/uuid.hpp +++ b/src/cpp-common/bt2c/uuid.hpp @@ -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()} { } -- 2.34.1