Claw
1.7.3
|
A class to manage the arguments of your program. More...
#include <arguments.hpp>
Public Member Functions | |
arguments () | |
Constructor. | |
arguments (const std::string &prog_name) | |
Constructor. | |
arguments (int &argc, char **&argv) | |
Constructor. | |
arguments (int &argc, char **&argv, const claw::math::ordered_set< std::string > &allowed) | |
Constructor. | |
void | parse (int &argc, char **&argv) |
Parse arguments. | |
void | parse (int &argc, char **&argv, const claw::math::ordered_set< std::string > &allowed) |
Parse arguments. | |
bool | has_value (const std::string &arg_name) const |
Tell if a value is associated to an argument. | |
bool | only_integer_values (const std::string &arg_name) const |
Tell if only integer values are associated to an argument. | |
bool | only_real_values (const std::string &arg_name) const |
Tell if only real values are associated to an argument. | |
const std::string & | get_program_name () const |
Get the name of the program. | |
bool | get_bool (const std::string &arg_name) const |
Get the boolean state of an argument. | |
int | get_integer (const std::string &arg_name) const |
Get the integer value of an argument. | |
double | get_real (const std::string &arg_name) const |
Get the real value of an argument. | |
const std::string & | get_string (const std::string &arg_name) const |
Get the string value of an argument. | |
std::list< int > | get_all_of_integer (const std::string &arg_name) const |
Get all integer values of an argument. | |
std::list< double > | get_all_of_real (const std::string &arg_name) const |
Get all real values of an argument. | |
std::list< std::string > | get_all_of_string (const std::string &arg_name) const |
Get all string values of an argument. | |
void | add_argument (const std::string &arg) |
Add an argument in our list. |
A class to manage the arguments of your program.
This class will handle all arguments of type -l[=val] or –long[=val].
Definition at line 50 of file arguments.hpp.
|
explicit |
Constructor.
prog_name | Force the name of the program. |
Definition at line 52 of file arguments.cpp.
claw::arguments::arguments | ( | int & | argc, |
char **& | argv | ||
) |
Constructor.
argc | Number of arguments. |
argv | Arguments. |
You should construct an instance with the parameters given to your function main(). The constructor will remove all supported arguments from argv.
Definition at line 67 of file arguments.cpp.
claw::arguments::arguments | ( | int & | argc, |
char **& | argv, | ||
const claw::math::ordered_set< std::string > & | allowed | ||
) |
Constructor.
argc | Number of arguments. |
argv | Arguments. |
allowed | The set of allowed arguments. |
You should construct an instance with the parameters given to your function main(). The constructor will remove all supported arguments from argv.
Definition at line 82 of file arguments.cpp.
void claw::arguments::add_argument | ( | const std::string & | arg | ) |
Add an argument in our list.
You can use this method to set default values to the parameters of your program, before calling parse_arguments.
arg | The argument to add. |
Definition at line 325 of file arguments.cpp.
References CLAW_ASSERT.
std::list< int > claw::arguments::get_all_of_integer | ( | const std::string & | arg_name | ) | const |
Get all integer values of an argument.
arg_name | The name of the argument to get. |
Definition at line 248 of file arguments.cpp.
std::list< double > claw::arguments::get_all_of_real | ( | const std::string & | arg_name | ) | const |
Get all real values of an argument.
arg_name | The name of the argument to get. |
Definition at line 276 of file arguments.cpp.
std::list< std::string > claw::arguments::get_all_of_string | ( | const std::string & | arg_name | ) | const |
Get all string values of an argument.
arg_name | The name of the argument to get. |
Definition at line 304 of file arguments.cpp.
bool claw::arguments::get_bool | ( | const std::string & | arg_name | ) | const |
Get the boolean state of an argument.
arg_name | The name of the argument to get. |
Definition at line 186 of file arguments.cpp.
int claw::arguments::get_integer | ( | const std::string & | arg_name | ) | const |
Get the integer value of an argument.
arg_name | The name of the argument to get. |
Definition at line 197 of file arguments.cpp.
References CLAW_ASSERT.
double claw::arguments::get_real | ( | const std::string & | arg_name | ) | const |
Get the real value of an argument.
arg_name | The name of the argument to get. |
Definition at line 215 of file arguments.cpp.
References CLAW_ASSERT.
const std::string & claw::arguments::get_string | ( | const std::string & | arg_name | ) | const |
Get the string value of an argument.
arg_name | The name of the argument to get. |
Definition at line 234 of file arguments.cpp.
References CLAW_ASSERT.
bool claw::arguments::has_value | ( | const std::string & | arg_name | ) | const |
Tell if a value is associated to an argument.
arg_name | The name of the argument to test. |
Definition at line 123 of file arguments.cpp.
bool claw::arguments::only_integer_values | ( | const std::string & | arg_name | ) | const |
Tell if only integer values are associated to an argument.
arg_name | The name of the argument to test. |
Definition at line 133 of file arguments.cpp.
bool claw::arguments::only_real_values | ( | const std::string & | arg_name | ) | const |
Tell if only real values are associated to an argument.
arg_name | The name of the argument to test. |
Definition at line 155 of file arguments.cpp.
void claw::arguments::parse | ( | int & | argc, |
char **& | argv | ||
) |
Parse arguments.
argc | Number of arguments. |
argv | Arguments. |
All supported arguments will be removed from argv.
Definition at line 97 of file arguments.cpp.
void claw::arguments::parse | ( | int & | argc, |
char **& | argv, | ||
const claw::math::ordered_set< std::string > & | allowed | ||
) |
Parse arguments.
argc | Number of arguments. |
argv | Arguments. |
allowed | The set of allowed arguments. |
All supported arguments will be removed from argv.
Definition at line 112 of file arguments.cpp.