mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:27:35 +00:00
AK+LibJS+LibRegex: Define an alias for UTF-16 string data storage
Instead of writing out "Vector<u16, 1>" everywhere, let's have a name for it.
This commit is contained in:
parent
39bda0073e
commit
425c168ded
10 changed files with 37 additions and 34 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2021-2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -10,6 +10,7 @@
|
|||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Utf16View.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
namespace JS {
|
||||
|
@ -20,18 +21,18 @@ public:
|
|||
~Utf16StringImpl() = default;
|
||||
|
||||
static NonnullRefPtr<Utf16StringImpl> create();
|
||||
static NonnullRefPtr<Utf16StringImpl> create(Vector<u16, 1>);
|
||||
static NonnullRefPtr<Utf16StringImpl> create(Utf16Data);
|
||||
static NonnullRefPtr<Utf16StringImpl> create(StringView);
|
||||
static NonnullRefPtr<Utf16StringImpl> create(Utf16View const&);
|
||||
|
||||
Vector<u16, 1> const& string() const;
|
||||
Utf16Data const& string() const;
|
||||
Utf16View view() const;
|
||||
|
||||
private:
|
||||
Utf16StringImpl() = default;
|
||||
explicit Utf16StringImpl(Vector<u16, 1> string);
|
||||
explicit Utf16StringImpl(Utf16Data string);
|
||||
|
||||
Vector<u16, 1> m_string;
|
||||
Utf16Data m_string;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -39,11 +40,11 @@ private:
|
|||
class Utf16String {
|
||||
public:
|
||||
Utf16String();
|
||||
explicit Utf16String(Vector<u16, 1>);
|
||||
explicit Utf16String(Utf16Data);
|
||||
explicit Utf16String(StringView);
|
||||
explicit Utf16String(Utf16View const&);
|
||||
|
||||
Vector<u16, 1> const& string() const;
|
||||
Utf16Data const& string() const;
|
||||
Utf16View view() const;
|
||||
Utf16View substring_view(size_t code_unit_offset, size_t code_unit_length) const;
|
||||
Utf16View substring_view(size_t code_unit_offset) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue