TTTT Analysis  0.1
argparse.hpp
Go to the documentation of this file.
1 
34 #ifndef argparse_hpp
35 #define argparse_hpp
36 #include <algorithm>
37 #include <string>
38 #include <vector>
39 namespace fv::util{
40 class ArgParser{
41  private:
42  std::vector <std::string> tokens;
43  std::string empty_string;
44  public:
45  ArgParser (int &argc, char **argv){
46  for (int i=1; i < argc; ++i)
47  this->tokens.push_back(std::string(argv[i]));
48  }
50  const std::string& getCmdOption(const std::string &option) const{
51  std::vector<std::string>::const_iterator itr;
52  itr = std::find(this->tokens.begin(), this->tokens.end(), option);
53  if (itr != this->tokens.end() && ++itr != this->tokens.end()){
54  return *itr;
55  }
56  return empty_string;
57  }
59  bool cmdOptionExists(const std::string &option) const{
60  return std::find(this->tokens.begin(), this->tokens.end(), option)
61  != this->tokens.end();
62  }
63 };
64 }
65 #endif // argparse_hpp
Definition: argparse.hpp:39