AK: Add support for the new FlyString to StringView

This commit is contained in:
Timothy Flynn 2023-01-28 08:26:22 -05:00 committed by Linus Groh
parent b61f8cd130
commit e96c64cdb4
Notes: sideshowbarker 2024-07-17 09:49:48 +09:00
2 changed files with 10 additions and 1 deletions

View file

@ -15,6 +15,7 @@
#ifndef KERNEL #ifndef KERNEL
# include <AK/DeprecatedFlyString.h> # include <AK/DeprecatedFlyString.h>
# include <AK/DeprecatedString.h> # include <AK/DeprecatedString.h>
# include <AK/FlyString.h>
# include <AK/String.h> # include <AK/String.h>
#endif #endif
@ -27,6 +28,12 @@ StringView::StringView(String const& string)
{ {
} }
StringView::StringView(FlyString const& string)
: m_characters(reinterpret_cast<char const*>(string.bytes().data()))
, m_length(string.bytes().size())
{
}
StringView::StringView(DeprecatedString const& string) StringView::StringView(DeprecatedString const& string)
: m_characters(string.characters()) : m_characters(string.characters())
, m_length(string.length()) , m_length(string.length())

View file

@ -49,6 +49,7 @@ public:
StringView(ByteBuffer const&); StringView(ByteBuffer const&);
#ifndef KERNEL #ifndef KERNEL
StringView(String const&); StringView(String const&);
StringView(FlyString const&);
StringView(DeprecatedString const&); StringView(DeprecatedString const&);
StringView(DeprecatedFlyString const&); StringView(DeprecatedFlyString const&);
#endif #endif
@ -56,11 +57,12 @@ public:
explicit StringView(ByteBuffer&&) = delete; explicit StringView(ByteBuffer&&) = delete;
#ifndef KERNEL #ifndef KERNEL
explicit StringView(String&&) = delete; explicit StringView(String&&) = delete;
explicit StringView(FlyString&&) = delete;
explicit StringView(DeprecatedString&&) = delete; explicit StringView(DeprecatedString&&) = delete;
explicit StringView(DeprecatedFlyString&&) = delete; explicit StringView(DeprecatedFlyString&&) = delete;
#endif #endif
template<OneOf<String, DeprecatedString, DeprecatedFlyString, ByteBuffer> StringType> template<OneOf<String, FlyString, DeprecatedString, DeprecatedFlyString, ByteBuffer> StringType>
StringView& operator=(StringType&&) = delete; StringView& operator=(StringType&&) = delete;
[[nodiscard]] constexpr bool is_null() const [[nodiscard]] constexpr bool is_null() const