28#ifndef __CMD_ARGUMENTS__
29#define __CMD_ARGUMENTS__
37#include "boost/smart_ptr.hpp"
38#include "boost/utility/value_init.hpp"
61 boost::value_initialized<T> value;
62 return getArg<T>(
name, value, isFatal);
76 T getArg(
const std::string
name,
T default_value,
bool isFatal =
false) {
77 T value = default_value;
79 value = this->arg<T>(
name);
82 std::ostringstream exe;
83 exe <<
"Fatal: argument \"";
85 exe <<
"\" not found!";
89 std::ostringstream
warn;
90 warn <<
"\033[01;35m";
91 warn <<
"Warning: argument \"";
93 warn <<
"\" not found! Using default value (";
94 warn << default_value;
97 std::cout <<
warn.str() << std::flush;
108 std::ostringstream oss;
113 "Argument '" +
name +
"' exists");
121 std::ostringstream oss;
167 void split(std::string &
name, std::string &value, std::string
arg);
192inline std::string CmdArguments::arg<std::string>(
const std::string
name) {
194 if(it != arguments_.end()) {
195 return arguments_[
name];
Inform & endl(Inform &inf)
boost::shared_ptr< CmdArguments > CmdArguments_t
constexpr double e
The value of.
std::string::iterator iterator
void split(std::string &name, std::string &value, std::string arg)
helper to split string
std::set< std::string > warned_
T arg(const std::string name)
std::map< std::string, std::string > arguments_
container for storing command line options
unsigned int getNumArguments() const
void addArguments(int argc, char **argv)
parse user arguments
T getArg(const std::string name, T default_value, bool isFatal=false)
char ** getArguments() const
void addArgument(const std::string &name, const T &value)
T getArg(const std::string name, bool isFatal=false)
CmdArguments(int argc, char **argv)
void replaceArgument(const std::string &name, const T &value)