-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommand.cpp
More file actions
42 lines (36 loc) · 744 Bytes
/
Command.cpp
File metadata and controls
42 lines (36 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "Server.hpp"
using std::string;
using std::cout;
using std::cerr;
using std::endl;
Command::~Command(){}
Command::Command(string cmd)
{
string s;
_name = cmd.substr(0, cmd.find(' '));
to_upper(_name);
if (cmd.find(' ') == std::string::npos)
return ;
cmd.erase(0, cmd.find(' ') + 1);
std::istringstream cmd_istr(cmd);
while (getline(cmd_istr, s, ' '))
{
_args.push_back(s);
if (cmd_istr.peek() == ':')
{
cmd_istr.get();
std::istreambuf_iterator<char> eos;
std::string s(std::istreambuf_iterator<char>(cmd_istr), eos);
_args.push_back(s);
break;
}
}
}
std::string Command::getName() const
{
return (_name);
}
std::vector<std::string> Command::getArgs() const
{
return (_args);
}