summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-04-20 14:13:40 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-04-20 14:13:40 +0200
commitab94a6be00ecd48575653e5d0ab3b2f21d131836 (patch)
tree8ded9c664c65a51f4a6c5f2fbf008facba67abf6 /Applications
parent5eedb2283488fafef98c20729bc6917c6de957e5 (diff)
downloadserenity-ab94a6be00ecd48575653e5d0ab3b2f21d131836.zip
AK: Add String::copy(BufferType) helper.
This will create a String from any BufferType that has data() and size().
Diffstat (limited to 'Applications')
-rw-r--r--Applications/IRCClient/IRCClient.cpp10
-rw-r--r--Applications/IRCClient/IRCClient.h3
-rw-r--r--Applications/Terminal/Terminal.cpp6
-rw-r--r--Applications/TextEditor/main.cpp2
4 files changed, 10 insertions, 11 deletions
diff --git a/Applications/IRCClient/IRCClient.cpp b/Applications/IRCClient/IRCClient.cpp
index 67f1854ba1..c83a5183c8 100644
--- a/Applications/IRCClient/IRCClient.cpp
+++ b/Applications/IRCClient/IRCClient.cpp
@@ -150,10 +150,10 @@ void IRCClient::process_line(ByteBuffer&& line)
}
}
if (!current_parameter.is_empty())
- msg.arguments.append(String(current_parameter.data(), current_parameter.size()));
- msg.prefix = String(prefix.data(), prefix.size());
- msg.command = String(command.data(), command.size());
- handle(msg, String(m_line_buffer.data(), m_line_buffer.size()));
+ msg.arguments.append(String::copy(current_parameter));
+ msg.prefix = String::copy(prefix);
+ msg.command = String::copy(command);
+ handle(msg);
}
void IRCClient::send(const String& text)
@@ -195,7 +195,7 @@ void IRCClient::send_whois(const String& nick)
send(String::format("WHOIS %s\r\n", nick.characters()));
}
-void IRCClient::handle(const Message& msg, const String&)
+void IRCClient::handle(const Message& msg)
{
#ifdef IRC_DEBUG
printf("IRCClient::execute: prefix='%s', command='%s', arguments=%d\n",
diff --git a/Applications/IRCClient/IRCClient.h b/Applications/IRCClient/IRCClient.h
index 2ee82d2bb2..4502cb0b5f 100644
--- a/Applications/IRCClient/IRCClient.h
+++ b/Applications/IRCClient/IRCClient.h
@@ -106,7 +106,7 @@ private:
void handle_rpl_namreply(const Message&);
void handle_privmsg(const Message&);
void handle_nick(const Message&);
- void handle(const Message&, const String& verbatim);
+ void handle(const Message&);
void handle_user_command(const String&);
void on_socket_connected();
@@ -117,7 +117,6 @@ private:
CTCPSocket* m_socket { nullptr };
String m_nickname;
- Vector<char> m_line_buffer;
OwnPtr<CNotifier> m_notifier;
HashMap<String, RetainPtr<IRCChannel>> m_channels;
HashMap<String, RetainPtr<IRCQuery>> m_queries;
diff --git a/Applications/Terminal/Terminal.cpp b/Applications/Terminal/Terminal.cpp
index 53ceef4cdf..b95ba07b30 100644
--- a/Applications/Terminal/Terminal.cpp
+++ b/Applications/Terminal/Terminal.cpp
@@ -393,13 +393,13 @@ void Terminal::execute_xterm_command()
{
m_final = '@';
bool ok;
- unsigned value = parse_uint(String((const char*)m_xterm_param1.data(), m_xterm_param1.size()), ok);
+ unsigned value = parse_uint(String::copy(m_xterm_param1), ok);
if (ok) {
switch (value) {
case 0:
case 1:
case 2:
- set_window_title(String((const char*)m_xterm_param2.data(), m_xterm_param2.size()));
+ set_window_title(String::copy(m_xterm_param2));
break;
default:
unimplemented_xterm_escape();
@@ -413,7 +413,7 @@ void Terminal::execute_xterm_command()
void Terminal::execute_escape_sequence(byte final)
{
m_final = final;
- auto paramparts = String((const char*)m_parameters.data(), m_parameters.size()).split(';');
+ auto paramparts = String::copy(m_parameters).split(';');
ParamVector params;
for (auto& parampart : paramparts) {
bool ok;
diff --git a/Applications/TextEditor/main.cpp b/Applications/TextEditor/main.cpp
index 9905731894..43dcb6411b 100644
--- a/Applications/TextEditor/main.cpp
+++ b/Applications/TextEditor/main.cpp
@@ -41,7 +41,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Opening %s: %s\n", path.characters(), file.error_string());
return 1;
}
- text_editor->set_text(String::from_byte_buffer(file.read_all()));
+ text_editor->set_text(String::copy(file.read_all()));
}
auto new_action = GAction::create("New document", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [] (const GAction&) {