X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/f0ca04947cd23aa5f973f184941dc5af13b43744..96de268956cc995f7dfcf8ce1aae774d4deb95c3:/Server/src/command.cpp?ds=inline diff --git a/Server/src/command.cpp b/Server/src/command.cpp index 91d82ce..5087d9e 100644 --- a/Server/src/command.cpp +++ b/Server/src/command.cpp @@ -44,16 +44,23 @@ Command::~Command(void) { #endif // DEBUG } -Command::Command(const string& target, const string& command): - target(target), command(command) { +Command::Command(const string& _target, const string& _command) { #ifdef DEBUG cerr << __FILE__ << ": target = " << target << " | " << "command = " << command << endl; #endif // DEBUG + set_target(_target); + set_command(_command); } void Command::build(void) { - uri = string("/") + target + '/' + command + String::join(args, "/"); + uri = string("/") + target; + if (command.length()) { + uri += '/' + command; + if (args.size()) { + uri += '/' + String::join(args, "/"); + } + } #ifdef DEBUG cerr << __FILE__ << ": build() = " << uri << endl; #endif // DEBUG @@ -64,7 +71,7 @@ void Command::set_target(const std::string& _target) { build(); } -const std::string& Command::get_target(void) { +const std::string& Command::get_target(void) const { return target; } @@ -73,7 +80,7 @@ void Command::set_command(const std::string& _command) { build(); } -const std::string& Command::get_command(void) { +const std::string& Command::get_command(void) const { return command; } @@ -82,7 +89,7 @@ void Command::set_args(const Command::Arguments& _args) { build(); } -const Command::Arguments& Command::get_args(void) { +const Command::Arguments& Command::get_args(void) const { return args; } @@ -91,6 +98,15 @@ void Command::add_arg(const std::string& arg) { build(); } +void Command::add_arg(const unsigned& arg) { +#ifdef DEBUG + cerr << __FILE__ << ": add_arg(arg = " << arg << ") = " + << String().from(arg) << endl; +#endif // DEBUG + args.push_back(String().from(arg)); + build(); +} + istream& operator>>(istream& is, Command& command) { #ifdef DEBUG cerr << __FILE__ << ": operator>>()" << endl; @@ -108,7 +124,7 @@ istream& operator>>(istream& is, Command& command) { } else { command.target = ""; } - if (command.args.size() > 1) { + if (command.args.size() > 0) { command.command = command.args[0]; command.args.erase(command.args.begin()); } else {