2020-12-31 09:38:12 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
|
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-12-31 09:38:12 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Array.h>
|
|
|
|
#include <AK/ByteBuffer.h>
|
|
|
|
#include <AK/StringView.h>
|
|
|
|
#include <AK/Types.h>
|
|
|
|
|
|
|
|
namespace AK {
|
|
|
|
|
|
|
|
class UUID {
|
|
|
|
public:
|
2022-01-28 18:21:40 +00:00
|
|
|
enum class Endianness {
|
|
|
|
Mixed,
|
|
|
|
Little
|
|
|
|
};
|
|
|
|
|
2021-09-16 06:20:31 +00:00
|
|
|
UUID() = default;
|
2020-12-31 09:38:12 +00:00
|
|
|
UUID(Array<u8, 16> uuid_buffer);
|
2022-01-28 18:21:40 +00:00
|
|
|
UUID(StringView, Endianness endianness = Endianness::Little);
|
2021-01-10 23:29:28 +00:00
|
|
|
~UUID() = default;
|
2020-12-31 09:38:12 +00:00
|
|
|
|
|
|
|
bool operator==(const UUID&) const;
|
|
|
|
bool operator!=(const UUID& other) const { return !(*this == other); }
|
|
|
|
bool operator<=(const UUID&) const = delete;
|
|
|
|
bool operator>=(const UUID&) const = delete;
|
|
|
|
bool operator<(const UUID&) const = delete;
|
|
|
|
bool operator>(const UUID&) const = delete;
|
|
|
|
|
|
|
|
String to_string() const;
|
|
|
|
bool is_zero() const;
|
|
|
|
|
|
|
|
private:
|
2022-01-28 18:21:40 +00:00
|
|
|
void convert_string_view_to_little_endian_uuid(StringView);
|
|
|
|
void convert_string_view_to_mixed_endian_uuid(StringView);
|
2020-12-31 09:38:12 +00:00
|
|
|
|
|
|
|
Array<u8, 16> m_uuid_buffer {};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
using AK::UUID;
|