/* * Copyright (c) 2021, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include namespace JS { namespace Detail { class Utf16StringImpl : public RefCounted { public: ~Utf16StringImpl() = default; static NonnullRefPtr create(); static NonnullRefPtr create(Vector); static NonnullRefPtr create(StringView); static NonnullRefPtr create(Utf16View const&); Vector const& string() const; Utf16View view() const; private: Utf16StringImpl() = default; explicit Utf16StringImpl(Vector string); Vector m_string; }; } class Utf16String { public: Utf16String(); explicit Utf16String(Vector); explicit Utf16String(StringView); explicit Utf16String(Utf16View const&); Vector 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; String to_utf8() const; u16 code_unit_at(size_t index) const; size_t length_in_code_units() const; bool is_empty() const; private: NonnullRefPtr m_string; }; }