Added webserver, parse args, A1066
This commit is contained in:
28
inc/args.hpp
Normal file
28
inc/args.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
class InputParser {
|
||||
public:
|
||||
InputParser (int &argc, char **argv){
|
||||
for (int i=1; i < argc; ++i)
|
||||
this->tokens.push_back(std::string(argv[i]));
|
||||
}
|
||||
/// @author iain
|
||||
const std::string& getCmdOption(const std::string &option) const{
|
||||
std::vector<std::string>::const_iterator itr;
|
||||
itr = std::find(this->tokens.begin(), this->tokens.end(), option);
|
||||
if (itr != this->tokens.end() && ++itr != this->tokens.end()){
|
||||
return *itr;
|
||||
}
|
||||
static const std::string empty_string("");
|
||||
return empty_string;
|
||||
}
|
||||
/// @author iain
|
||||
bool cmdOptionExists(const std::string &option) const{
|
||||
return std::find(this->tokens.begin(), this->tokens.end(), option) != this->tokens.end();
|
||||
}
|
||||
private:
|
||||
std::vector <std::string> tokens;
|
||||
};
|
||||
Reference in New Issue
Block a user