1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-05 22:54:55 +00:00
serenity/AK/UUID.h
Liav A 7c0540a229 Everywhere: Move global Kernel pattern code to Kernel/Library directory
This has KString, KBuffer, DoubleBuffer, KBufferBuilder, IOWindow,
UserOrKernelBuffer and ScopedCritical classes being moved to the
Kernel/Library subdirectory.

Also, move the panic and assertions handling code to that directory.
2023-06-04 21:32:34 +02:00

55 lines
999 B
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>
#ifdef KERNEL
# include <Kernel/Library/KString.h>
#else
# include <AK/String.h>
#endif
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 = default;
#ifdef KERNEL
ErrorOr<NonnullOwnPtr<Kernel::KString>> to_string() const;
#else
ErrorOr<String> to_string() const;
#endif
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 {};
};
}
#if USING_AK_GLOBALLY
using AK::UUID;
#endif