Commit 9b8ed31d authored by Dominik Charousset's avatar Dominik Charousset

use string for s_last_line rather than any_tuple

parent 6bad5f98
...@@ -11,11 +11,9 @@ ...@@ -11,11 +11,9 @@
#include <set> #include <set>
#include <map> #include <map>
#include <vector> #include <vector>
#include <dlfcn.h>
#include <iostream>
#include <sstream>
#include <time.h>
#include <cstdlib> #include <cstdlib>
#include <sstream>
#include <iostream>
#include "cppa/opt.hpp" #include "cppa/opt.hpp"
#include "cppa/cppa.hpp" #include "cppa/cppa.hpp"
...@@ -31,17 +29,17 @@ istream& operator>>(istream& is, line& l) { ...@@ -31,17 +29,17 @@ istream& operator>>(istream& is, line& l) {
return is; return is;
} }
any_tuple s_last_line; string s_last_line;
any_tuple split_line(const line& l) { any_tuple split_line(const line& l) {
vector<string> result; istringstream strs(l.str);
stringstream strs(l.str); s_last_line = move(l.str);
string tmp; string tmp;
vector<string> result;
while (getline(strs, tmp, ' ')) { while (getline(strs, tmp, ' ')) {
if (!tmp.empty()) result.push_back(std::move(tmp)); if (!tmp.empty()) result.push_back(std::move(tmp));
} }
s_last_line = any_tuple::view(std::move(result)); return any_tuple::view(std::move(result));
return s_last_line;
} }
class client : public event_based_actor { class client : public event_based_actor {
...@@ -152,13 +150,8 @@ int main(int argc, char** argv) { ...@@ -152,13 +150,8 @@ int main(int argc, char** argv) {
" /help print this text\n" << flush; " /help print this text\n" << flush;
}, },
others() >> [&] { others() >> [&] {
if (s_last_line.size() > 0) { if (!s_last_line.empty()) {
string msg = s_last_line.get_as<string>(0); send(client_actor, atom("broadcast"), s_last_line);
for (size_t i = 1; i < s_last_line.size(); ++i) {
msg += " ";
msg += s_last_line.get_as<string>(i);
}
send(client_actor, atom("broadcast"), msg);
} }
} }
); );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment