mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
AK: Exclude StringBuilder String APIs from the Kernel
These APIs are only used by userland, and String is OOM-infallible, so let's just ifdef it out of the Kernel.
This commit is contained in:
parent
43e5c326e2
commit
8f093e91e0
Notes:
sideshowbarker
2024-07-17 18:40:01 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/8f093e91e0 Pull-request: https://github.com/SerenityOS/serenity/pull/12564 Reviewed-by: https://github.com/MaxWipfli
2 changed files with 15 additions and 2 deletions
|
@ -8,13 +8,16 @@
|
|||
#include <AK/Checked.h>
|
||||
#include <AK/PrintfImplementation.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/UnicodeUtils.h>
|
||||
#include <AK/Utf16View.h>
|
||||
#include <AK/Utf32View.h>
|
||||
|
||||
#ifndef KERNEL
|
||||
# include <AK/String.h>
|
||||
# include <AK/Utf16View.h>
|
||||
#endif
|
||||
|
||||
namespace AK {
|
||||
|
||||
inline ErrorOr<void> StringBuilder::will_append(size_t size)
|
||||
|
@ -87,6 +90,7 @@ ByteBuffer StringBuilder::to_byte_buffer() const
|
|||
return ByteBuffer::copy(data(), length()).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
#ifndef KERNEL
|
||||
String StringBuilder::to_string() const
|
||||
{
|
||||
if (is_empty())
|
||||
|
@ -98,6 +102,7 @@ String StringBuilder::build() const
|
|||
{
|
||||
return to_string();
|
||||
}
|
||||
#endif
|
||||
|
||||
StringView StringBuilder::string_view() const
|
||||
{
|
||||
|
@ -125,6 +130,7 @@ void StringBuilder::append_code_point(u32 code_point)
|
|||
MUST(try_append_code_point(code_point));
|
||||
}
|
||||
|
||||
#ifndef KERNEL
|
||||
ErrorOr<void> StringBuilder::try_append(Utf16View const& utf16_view)
|
||||
{
|
||||
for (size_t i = 0; i < utf16_view.length_in_code_units();) {
|
||||
|
@ -140,6 +146,7 @@ void StringBuilder::append(Utf16View const& utf16_view)
|
|||
{
|
||||
MUST(try_append(utf16_view));
|
||||
}
|
||||
#endif
|
||||
|
||||
ErrorOr<void> StringBuilder::try_append(Utf32View const& utf32_view)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,9 @@ public:
|
|||
~StringBuilder() = default;
|
||||
|
||||
ErrorOr<void> try_append(StringView);
|
||||
#ifndef KERNEL
|
||||
ErrorOr<void> try_append(Utf16View const&);
|
||||
#endif
|
||||
ErrorOr<void> try_append(Utf32View const&);
|
||||
ErrorOr<void> try_append_code_point(u32);
|
||||
ErrorOr<void> try_append(char);
|
||||
|
@ -35,7 +37,9 @@ public:
|
|||
ErrorOr<void> try_append(char const*, size_t);
|
||||
|
||||
void append(StringView);
|
||||
#ifndef KERNEL
|
||||
void append(Utf16View const&);
|
||||
#endif
|
||||
void append(Utf32View const&);
|
||||
void append(char);
|
||||
void append_code_point(u32);
|
||||
|
@ -52,8 +56,10 @@ public:
|
|||
MUST(vformat(*this, fmtstr.view(), variadic_format_params));
|
||||
}
|
||||
|
||||
#ifndef KERNEL
|
||||
[[nodiscard]] String build() const;
|
||||
[[nodiscard]] String to_string() const;
|
||||
#endif
|
||||
[[nodiscard]] ByteBuffer to_byte_buffer() const;
|
||||
|
||||
[[nodiscard]] StringView string_view() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue