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
2 changed files with 10 additions and 1 deletions

View file

@ -15,6 +15,7 @@
#ifndef KERNEL
# include <AK/DeprecatedFlyString.h>
# include <AK/DeprecatedString.h>
# include <AK/FlyString.h>
# include <AK/String.h>
#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)
: m_characters(string.characters())
, m_length(string.length())

View file

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