command_line_parser.cpp
Go to the documentation of this file.
1 //
2 // Created by acslab on 8/10/17.
3 //
4 
6 #include <string>
7 #include <iostream>
8 
9 CommandLineParser::CommandLineParser(int _argc, char **_argv): argc(_argc), argv(_argv){}
10 
11 bool CommandLineParser::operator[] (std::string param)
12 {
13  int idx = -1;
14  for (int i = 0; i < argc && idx == -1; i++)
15  {
16  if (std::string(argv[i]) == param)
17  {
18  idx = i;
19  }
20  }
21 
22  return (idx != -1);
23 }
24 
25 std::string CommandLineParser::operator() (std::string param, std::string def_value)
26 {
27  int idx = -1;
28  for (int i = 0; i < argc && idx == -1; i++)
29  {
30  if (std::string(argv[i]) == param)
31  {
32  idx = i;
33  }
34  }
35 
36  if (idx == -1)
37  {
38  return def_value;
39  }
40  else
41  {
42  return argv[idx + 1];
43  }
44 }
std::string operator()(std::string param, std::string def_value="-1")
CommandLineParser(int _argc, char **_argv)
bool operator[](std::string param)


pheeno_ros_sim
Author(s): Zahi Kakish
autogenerated on Mon Jun 10 2019 14:25:55