mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:57:44 +00:00
AK: Add String constructor from ReadonlyBytes.
This commit is contained in:
parent
42b4880653
commit
75cde94c6a
3 changed files with 23 additions and 0 deletions
17
AK/String.h
17
AK/String.h
|
@ -83,6 +83,11 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
explicit String(ReadonlyBytes bytes, ShouldChomp shouldChomp = NoChomp)
|
||||
: m_impl(StringImpl::create(bytes, shouldChomp))
|
||||
{
|
||||
}
|
||||
|
||||
String(const StringImpl& impl)
|
||||
: m_impl(const_cast<StringImpl&>(impl))
|
||||
{
|
||||
|
@ -196,6 +201,18 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
String& operator=(std::nullptr_t)
|
||||
{
|
||||
m_impl = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
String& operator=(ReadonlyBytes bytes)
|
||||
{
|
||||
m_impl = StringImpl::create(bytes);
|
||||
return *this;
|
||||
}
|
||||
|
||||
u32 hash() const
|
||||
{
|
||||
if (!m_impl)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue