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
12 #include "common/assert.h"
13 #include "common/uuid.h"
15 namespace bt2_common {
20 explicit UuidView(const std::uint8_t * const uuid) noexcept : _mUuid {uuid}
25 UuidView(const UuidView&) noexcept = default;
26 UuidView& operator=(const UuidView&) noexcept = default;
28 bool operator==(const UuidView& other) const noexcept
30 return bt_uuid_compare(_mUuid, other._mUuid) == 0;
33 bool operator!=(const UuidView& other) const noexcept
35 return !(*this == other);
38 std::string string() const
42 s.resize(BT_UUID_STR_LEN);
43 bt_uuid_to_str(_mUuid, s.data());
48 static std::size_t size() noexcept
53 const std::uint8_t *data() const noexcept
59 const std::uint8_t *_mUuid;
62 } /* namespace bt2_common */
64 #endif /* BABELTRACE_CPP_COMMON_UUID_VIEW_HPP */