summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-01-28 08:26:22 -0500
committerLinus Groh <mail@linusgroh.de>2023-01-28 15:24:55 +0000
commite96c64cdb44745512f6babbc555b04fad5b0f2a0 (patch)
treec7703aa1a37b4443c213776619ecf4aad446acc3 /AK
parentb61f8cd13088c7b8d32fc6d700a971cdbc7856be (diff)
downloadserenity-e96c64cdb44745512f6babbc555b04fad5b0f2a0.zip
AK: Add support for the new FlyString to StringView
Diffstat (limited to 'AK')
-rw-r--r--AK/StringView.cpp7
-rw-r--r--AK/StringView.h4
2 files changed, 10 insertions, 1 deletions
diff --git a/AK/StringView.cpp b/AK/StringView.cpp
index 1d8e6fe152..4252dcea35 100644
--- a/AK/StringView.cpp
+++ b/AK/StringView.cpp
@@ -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())
diff --git a/AK/StringView.h b/AK/StringView.h
index 6e0c497a64..3bcd0072a2 100644
--- a/AK/StringView.h
+++ b/AK/StringView.h
@@ -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