2 * Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
4 * SPDX-License-Identifier: MIT
7 #ifndef BABELTRACE_CPP_COMMON_UUID_VIEW_HPP
8 #define BABELTRACE_CPP_COMMON_UUID_VIEW_HPP
14 #include "common/assert.h"
15 #include "common/uuid.h"
17 namespace bt2_common {
22 explicit UuidView(const std::uint8_t * const uuid) noexcept : _mUuid {uuid}
27 UuidView(const UuidView&) noexcept = default;
28 UuidView& operator=(const UuidView&) noexcept = default;
30 bool operator==(const UuidView& other) const noexcept
32 return bt_uuid_compare(_mUuid, other._mUuid) == 0;
35 bool operator!=(const UuidView& other) const noexcept
37 return !(*this == other);
40 std::string string() const
44 s.resize(BT_UUID_STR_LEN);
45 bt_uuid_to_str(_mUuid, &s[0]);
50 static constexpr std::size_t size() noexcept
55 const std::uint8_t *data() const noexcept
61 const std::uint8_t *_mUuid;
64 } /* namespace bt2_common */
66 #endif /* BABELTRACE_CPP_COMMON_UUID_VIEW_HPP */