mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
6e19ab2bbc
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
54 lines
1,002 B
C++
54 lines
1,002 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/KString.h>
|
|
#else
|
|
# include <AK/DeprecatedString.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
|
|
DeprecatedString 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
|