serenity/AK/UUID.h
Liav A 308e54bc19 AK+Kernel: Implement UUID mixed endianness support
This is being used by GUID partitions so the first three dash-delimited
fields of the GUID are stored in little endian order but the last two
fields are stored in big endian order, hence it's a representation which
is mixed.
2022-01-29 13:35:54 +02:00

48 lines
1 KiB
C++

/*
* Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Array.h>
#include <AK/ByteBuffer.h>
#include <AK/StringView.h>
#include <AK/Types.h>
namespace AK {
class UUID {
public:
enum class Endianness {
Mixed,
Little
};
UUID() = default;
UUID(Array<u8, 16> uuid_buffer);
UUID(StringView, Endianness endianness = Endianness::Little);
~UUID() = default;
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:
void convert_string_view_to_little_endian_uuid(StringView);
void convert_string_view_to_mixed_endian_uuid(StringView);
Array<u8, 16> m_uuid_buffer {};
};
}
using AK::UUID;