mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
StringView: Make it easy to construct from a ByteBuffer.
This commit is contained in:
parent
53479f9356
commit
50677a58d4
Notes:
sideshowbarker
2024-07-19 13:27:14 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/50677a58d4d
2 changed files with 10 additions and 1 deletions
|
@ -10,6 +10,12 @@ StringView::StringView(const String& string)
|
|||
{
|
||||
}
|
||||
|
||||
StringView::StringView(const ByteBuffer& buffer)
|
||||
: m_characters((const char*)buffer.data())
|
||||
, m_length(buffer.size())
|
||||
{
|
||||
}
|
||||
|
||||
Vector<StringView> StringView::split_view(const char separator) const
|
||||
{
|
||||
if (is_empty())
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
namespace AK {
|
||||
|
||||
class ByteBuffer;
|
||||
class String;
|
||||
class StringImpl;
|
||||
|
||||
|
@ -28,7 +29,9 @@ public:
|
|||
++m_length;
|
||||
}
|
||||
}
|
||||
StringView(const String& string);
|
||||
|
||||
StringView(const ByteBuffer&);
|
||||
StringView(const String&);
|
||||
|
||||
bool is_null() const { return !m_characters; }
|
||||
bool is_empty() const { return m_length == 0; }
|
||||
|
|
Loading…
Reference in a new issue