Serenity Operating System
at master 54 lines 991 B view raw
1/* 2 * Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#pragma once 8 9#include <AK/Array.h> 10#include <AK/ByteBuffer.h> 11#include <AK/StringView.h> 12#include <AK/Types.h> 13 14#ifdef KERNEL 15# include <Kernel/KString.h> 16#else 17# include <AK/String.h> 18#endif 19 20namespace AK { 21 22class UUID { 23public: 24 enum class Endianness { 25 Mixed, 26 Little 27 }; 28 29 UUID() = default; 30 UUID(Array<u8, 16> uuid_buffer); 31 UUID(StringView, Endianness endianness = Endianness::Little); 32 ~UUID() = default; 33 34 bool operator==(const UUID&) const = default; 35 36#ifdef KERNEL 37 ErrorOr<NonnullOwnPtr<Kernel::KString>> to_string() const; 38#else 39 ErrorOr<String> to_string() const; 40#endif 41 bool is_zero() const; 42 43private: 44 void convert_string_view_to_little_endian_uuid(StringView); 45 void convert_string_view_to_mixed_endian_uuid(StringView); 46 47 Array<u8, 16> m_uuid_buffer {}; 48}; 49 50} 51 52#if USING_AK_GLOBALLY 53using AK::UUID; 54#endif