1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 19:55:06 +00:00

copy: Stop using DeprecatedString

This commit is contained in:
Sam Atkins 2023-03-10 15:43:25 +00:00 committed by Andreas Kling
parent f7375d664c
commit b0ffb15e13

View file

@ -6,7 +6,7 @@
#include <AK/Assertions.h> #include <AK/Assertions.h>
#include <AK/ByteBuffer.h> #include <AK/ByteBuffer.h>
#include <AK/DeprecatedString.h> #include <AK/String.h>
#include <AK/StringBuilder.h> #include <AK/StringBuilder.h>
#include <LibCore/ArgsParser.h> #include <LibCore/ArgsParser.h>
#include <LibCore/File.h> #include <LibCore/File.h>
@ -16,7 +16,7 @@
#include <unistd.h> #include <unistd.h>
struct Options { struct Options {
DeprecatedString data; String data;
StringView type; StringView type;
bool clear; bool clear;
}; };
@ -24,7 +24,7 @@ struct Options {
static ErrorOr<Options> parse_options(Main::Arguments arguments) static ErrorOr<Options> parse_options(Main::Arguments arguments)
{ {
auto type = "text/plain"sv; auto type = "text/plain"sv;
Vector<DeprecatedString> text; Vector<StringView> text;
bool clear = false; bool clear = false;
Core::ArgsParser args_parser; Core::ArgsParser args_parser;
@ -46,12 +46,12 @@ static ErrorOr<Options> parse_options(Main::Arguments arguments)
auto buffer = TRY(c_stdin->read_until_eof()); auto buffer = TRY(c_stdin->read_until_eof());
dbgln("Read size {}", buffer.size()); dbgln("Read size {}", buffer.size());
dbgln("Read data: `{}`", StringView(buffer.bytes())); dbgln("Read data: `{}`", StringView(buffer.bytes()));
options.data = buffer.bytes(); options.data = TRY(String::from_utf8(StringView(buffer.bytes())));
} else { } else {
// Copy the rest of our command-line args. // Copy the rest of our command-line args.
StringBuilder builder; StringBuilder builder;
builder.join(' ', text); builder.join(' ', text);
options.data = builder.to_deprecated_string(); options.data = TRY(builder.to_string());
} }
return options; return options;