20#ifndef HEADER_COMMAND_LINE_HPP
21#define HEADER_COMMAND_LINE_HPP
23#include "utils/string_utils.hpp"
49 static std::vector<std::string>
m_argv;
63 static bool has(
const std::string &option,
void *t,
const char*
const format)
65 if(
m_argv.size()==0)
return false;
67 std::string equal=option+
"="+format;
68 std::vector<std::string>::iterator i;
71 if(sscanf(i->c_str(), equal.c_str(), t)==1)
81 static void init(
unsigned int argc,
char *argv[]);
82 static void addArgsFromUserConfig();
84 static bool has(
const std::string &option);
93 template<
typename T>
static bool has(
const std::string& option, T* value)
95 std::string equal = option +
"=";
96 std::vector<std::string>::iterator i;
99 if (i->compare(0, equal.size(), equal) == 0)
102 i->substr(equal.size(), std::string::npos);
103 if (StringUtils::fromString(result, *value))
121 static bool has(
const std::string& option, std::string* value)
123 std::string equal = option +
"=";
124 std::vector<std::string>::iterator i;
127 if (i->compare(0, equal.size(), equal) == 0)
129 *value = i->substr(equal.size(), std::string::npos);
A small class to manage the 'argv' parameters of a program.
Definition: command_line.hpp:46
static void init(unsigned int argc, char *argv[])
The constructor takes the standard C arguments argc and argv and stores the information internally.
Definition: command_line.cpp:37
static bool has(const std::string &option, T *value)
Searches for an option 'option=XX'.
Definition: command_line.hpp:93
static bool has(const std::string &option, void *t, const char *const format)
Searches for an option 'option=XX'.
Definition: command_line.hpp:63
static const std::string & getExecName()
Returns the name of the executable.
Definition: command_line.hpp:138
static std::vector< std::string > m_argv
The array with all command line options.
Definition: command_line.hpp:49
static void reportInvalidParameters()
Reports any parameters that have not been handled yet to be an error.
Definition: command_line.cpp:86
static bool has(const std::string &option, std::string *value)
Searches for an option 'option=XX'.
Definition: command_line.hpp:121
static std::string m_exec_name
Name of the executable.
Definition: command_line.hpp:52