mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Protect Utf8View against inclusion in the Kernel
It will soon be included in the Kernel by way of String.h. Utf8View includes DeprecatedString, which is not allowed in the Kernel.
This commit is contained in:
parent
c4d78c29a2
commit
434ca78425
Notes:
sideshowbarker
2024-07-17 02:06:40 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/434ca78425 Pull-request: https://github.com/SerenityOS/serenity/pull/17699 Reviewed-by: https://github.com/linusg ✅
1 changed files with 16 additions and 7 deletions
|
@ -7,11 +7,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
#ifndef KERNEL
|
||||
# include <AK/DeprecatedString.h>
|
||||
#endif
|
||||
|
||||
namespace AK {
|
||||
|
||||
class Utf8View;
|
||||
|
@ -61,19 +64,21 @@ public:
|
|||
|
||||
Utf8View() = default;
|
||||
|
||||
explicit Utf8View(DeprecatedString& string)
|
||||
: m_string(string.view())
|
||||
{
|
||||
}
|
||||
|
||||
explicit constexpr Utf8View(StringView string)
|
||||
: m_string(string)
|
||||
{
|
||||
}
|
||||
|
||||
~Utf8View() = default;
|
||||
#ifndef KERNEL
|
||||
explicit Utf8View(DeprecatedString& string)
|
||||
: m_string(string.view())
|
||||
{
|
||||
}
|
||||
|
||||
explicit Utf8View(DeprecatedString&&) = delete;
|
||||
#endif
|
||||
|
||||
~Utf8View() = default;
|
||||
|
||||
StringView as_string() const { return m_string; }
|
||||
|
||||
|
@ -224,6 +229,7 @@ private:
|
|||
mutable bool m_have_length { false };
|
||||
};
|
||||
|
||||
#ifndef KERNEL
|
||||
class DeprecatedStringCodePointIterator {
|
||||
public:
|
||||
Optional<u32> next()
|
||||
|
@ -257,6 +263,7 @@ private:
|
|||
DeprecatedString m_string;
|
||||
Utf8CodePointIterator m_it;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<>
|
||||
struct Formatter<Utf8View> : Formatter<StringView> {
|
||||
|
@ -266,7 +273,9 @@ struct Formatter<Utf8View> : Formatter<StringView> {
|
|||
}
|
||||
|
||||
#if USING_AK_GLOBALLY
|
||||
# ifndef KERNEL
|
||||
using AK::DeprecatedStringCodePointIterator;
|
||||
# endif
|
||||
using AK::Utf8CodePointIterator;
|
||||
using AK::Utf8View;
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue