#include <Arguments.hh>
Collaboration diagram for Arguments:
Public Member Functions | |
Arguments (int argc, char **argv, std::string usage="") | |
~Arguments () | |
std::string | getCommand () |
std::string | getOption (const std::string) const |
std::string | getArgument (const unsigned int) const |
unsigned int | getNbOfArgs () |
unsigned int | getNbOfOptions () |
void | usage (void) |
Private Attributes | |
std::string | command |
std::map< const std::string, std::string > | stringKeyMap |
std::map< const unsigned int, std::string > | orderKeyMap |
std::string | pUsage |
Distinguish command, arguments and options
Command name is not include in arguments list but can be accessed via getCommand() method
Options: words after a "-string": Examples : command -f option. : command -option1 option1. Option are not mandatory, and order in which they arrive does not matter. Access option with getOption("-string") method
Arguments are mandatory, and order in which they arrive is take in account Access argument with getArgument(order) method
Definition at line 27 of file Arguments.hh.
Arguments::Arguments | ( | int | argc, | |
char ** | argv, | |||
std::string | usage = "" | |||
) |
Arguments::~Arguments | ( | ) |
std::string Arguments::getCommand | ( | ) | [inline] |
std::string Arguments::getOption | ( | const std::string | ) | const |
Referenced by main().
string Arguments::getArgument | ( | const unsigned | int | ) | const |
Definition at line 48 of file Arguments.cpp.
Referenced by main().
00049 { 00050 00051 map<const unsigned int, string>::const_iterator it = orderKeyMap.find(key); 00052 if ( it != orderKeyMap.end() ) { return orderKeyMap.find(key)->second; } 00053 return string(""); 00054 }
unsigned int Arguments::getNbOfArgs | ( | ) | [inline] |
Definition at line 37 of file Arguments.hh.
Referenced by main().
00037 { return orderKeyMap.size(); }
unsigned int Arguments::getNbOfOptions | ( | ) | [inline] |
Definition at line 38 of file Arguments.hh.
Referenced by main().
00038 { return stringKeyMap.size(); }
void Arguments::usage | ( | void | ) |
Definition at line 57 of file Arguments.cpp.
Referenced by main().
00058 { 00059 cout << "usage: " << pUsage << endl; 00060 }
std::string Arguments::command [private] |
std::map<const std::string , std::string> Arguments::stringKeyMap [private] |
std::map< const unsigned int , std::string> Arguments::orderKeyMap [private] |
std::string Arguments::pUsage [private] |