using argv_t = vector<variant<arg_t, arg_pair_t>>;
explicit
- Server(string &&binary_, argv_t && args_ = {});
+ Server(string binary_ = "false", argv_t args_ = {});
~Server();
Server(const Server &s);
Server &operator = (const Server &s);
- Server &operator = (Server &&s) = default;
- Server(Server &&s) = default;
+ Server(Server &&s) {
+ *this = move(s);
+ };
+ Server &operator = (Server &&s) {
+ binary = exchange(s.binary, "false");
+ args = exchange(s.args, {});
+ pid = exchange(s.pid, 0);
+ status = exchange(s.status, 0);
+ signalled = exchange(s.signalled, {});
+ socket_or_port = exchange(s.socket_or_port, {});
+ return *this;
+ };
pid_t getPid() const;
vector<char *> createArgv();
optional<string> handleArg(vector<char *> &arr, const string &arg, const arg_func_t &next_arg);
};
+
+inline ostream &operator << (ostream &out, const socket_or_port_t sop) {
+ if (holds_alternative<string>(sop)) {
+ out << get<string>(sop);
+ } else {
+ out << get<int>(sop);
+ }
+ return out;
+}
+
+inline ostream &operator << (ostream &out, const Server &server) {
+ out << "Server{binary=" << server.getBinary() << ",pid=" << server.getPid() << ",conn=" << server.getSocketOrPort() << "}";
+ return out;
+}