1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:37:35 +00:00

AK: Add String::from_stream method

The caller is responsible for determining how long the string is that
they want to read.
This commit is contained in:
Andrew Kaster 2023-02-19 18:34:29 -07:00 committed by Linus Groh
parent 7ac7a73758
commit 0ea697ace5
3 changed files with 84 additions and 0 deletions

View file

@ -64,6 +64,9 @@ public:
// Creates a new String from a sequence of UTF-8 encoded code points.
static ErrorOr<String> from_utf8(StringView);
// Creates a new String by reading byte_count bytes from a UTF-8 encoded Stream.
static ErrorOr<String> from_stream(Stream&, size_t byte_count);
// Creates a new String from a short sequence of UTF-8 encoded code points. If the provided string
// does not fit in the short string storage, a compilation error will be emitted.
static AK_SHORT_STRING_CONSTEVAL String from_utf8_short_string(StringView string)