command_line_parser.cpp
Go to the documentation of this file.
00001 //
00002 // Created by acslab on 8/10/17.
00003 //
00004 
00005 #include "command_line_parser.h"
00006 #include <string>
00007 #include <iostream>
00008 
00009 CommandLineParser::CommandLineParser(int _argc, char **_argv): argc(_argc), argv(_argv){}
00010 
00011 bool CommandLineParser::operator[] (std::string param)
00012 {
00013   int idx = -1;
00014   for (int i = 0; i < argc && idx == -1; i++)
00015   {
00016     if (std::string(argv[i]) == param)
00017     {
00018       idx = i;
00019     }
00020   }
00021 
00022   return (idx != -1);
00023 }
00024 
00025 std::string CommandLineParser::operator() (std::string param, std::string def_value)
00026 {
00027   int idx = -1;
00028   for (int i = 0; i < argc && idx == -1; i++)
00029   {
00030     if (std::string(argv[i]) == param)
00031     {
00032       idx = i;
00033     }
00034   }
00035 
00036   if (idx == -1)
00037   {
00038     return def_value;
00039   }
00040   else
00041   {
00042     return argv[idx + 1];
00043   }
00044 }


pheeno_ros
Author(s): Zahi Kakish, Sean Wilson
autogenerated on Thu Jun 6 2019 21:26:16