-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinput.cpp
More file actions
23 lines (20 loc) · 706 Bytes
/
input.cpp
File metadata and controls
23 lines (20 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <vector>
using namespace std;
#include "input.h"
InputParser::InputParser(const int &argc, char **argv) {
for (int i = 1; i < argc; ++i)
this->tokens.push_back(string(argv[i]));
}
const string& InputParser::getCmdOption(const string &option) const {
vector<string>::const_iterator itr;
itr = find(this->tokens.begin(), this->tokens.end(), option);
if (itr != this->tokens.end() && ++itr != this->tokens.end()){
return *itr;
}
static const string empty_string("");
return empty_string;
}
bool InputParser::cmdOptionExists(const string &option) const {
return find(this->tokens.begin(), this->tokens.end(), option)
!= this->tokens.end();
}