#include <CommandLineOption.hpp>
Public Types | |
| enum | ArgumentsType { integer, real, string, end } |
Public Member Functions | |
| const std::string & | shortName () const |
| const std::string & | longName () const |
| const std::string & | description () const |
| const std::string | arguments () const |
| const int & | identifier () const |
| CommandLineOption (const int &id, const std::string &longName, const std::string &shortName, const std::string &description, ArgumentsType arguments[]=0) | |
| ~CommandLineOption () | |
Private Attributes | |
| const int | __identifier |
| const std::string | __longName |
| const std::string | __shortName |
| const std::string | __description |
| std::vector< ArgumentsType > | __arguments |
Definition at line 38 of file CommandLineOption.hpp.
| CommandLineOption::CommandLineOption | ( | const int & | id, | |
| const std::string & | longName, | |||
| const std::string & | shortName, | |||
| const std::string & | description, | |||
| ArgumentsType | arguments[] = 0 | |||
| ) | [inline] |
Constructor
Definition at line 132 of file CommandLineOption.hpp.
References __arguments, arguments(), and end.
00137 : __identifier(id), 00138 __longName(longName), 00139 __shortName(shortName), 00140 __description(description) 00141 { 00142 if (arguments != 0) { 00143 for (int i=0; arguments[i]!=CommandLineOption::end; ++i) { 00144 __arguments.push_back(arguments[i]); 00145 } 00146 } 00147 }

| CommandLineOption::~CommandLineOption | ( | ) | [inline] |
| const std::string& CommandLineOption::shortName | ( | ) | const [inline] |
Returns the short name of an option
Definition at line 64 of file CommandLineOption.hpp.
References __shortName.
Referenced by CommandLineParser::CommandLineParser().
00065 { 00066 return __shortName; 00067 }
| const std::string& CommandLineOption::longName | ( | ) | const [inline] |
Returns the long name of an option
Definition at line 74 of file CommandLineOption.hpp.
References __longName.
Referenced by CommandLineParser::CommandLineParser().
00075 { 00076 return __longName; 00077 }
| const std::string& CommandLineOption::description | ( | ) | const [inline] |
Returns the description of an option
Definition at line 84 of file CommandLineOption.hpp.
References __description.
00085 { 00086 return __description; 00087 }
| const std::string CommandLineOption::arguments | ( | ) | const [inline] |
Definition at line 89 of file CommandLineOption.hpp.
References __arguments, end, integer, real, string, and ErrorHandler::unexpected.
Referenced by CommandLineOption().
00090 { 00091 std::string argument; 00092 for (size_t i=0; i<__arguments.size(); ++i) { 00093 if (i!=0) argument += ','; 00094 switch (__arguments[i]) { 00095 case CommandLineOption::integer: { 00096 argument += "int"; 00097 break; 00098 } 00099 case CommandLineOption::real: { 00100 argument += "real"; 00101 break; 00102 } 00103 case CommandLineOption::string: { 00104 argument += "str"; 00105 break; 00106 } 00107 case CommandLineOption::end: 00108 default: { 00109 throw ErrorHandler(__FILE__,__LINE__, 00110 "unexpected command line option", 00111 ErrorHandler::unexpected); 00112 } 00113 } 00114 } 00115 return argument; 00116 }
| const int& CommandLineOption::identifier | ( | ) | const [inline] |
Returns option idetifier
Definition at line 123 of file CommandLineOption.hpp.
References __identifier.
Referenced by CommandLineParser::__treatOption().
00124 { 00125 return __identifier; 00126 }
const int CommandLineOption::__identifier [private] |
const std::string CommandLineOption::__longName [private] |
long name (--help for instance)
Definition at line 52 of file CommandLineOption.hpp.
Referenced by longName().
const std::string CommandLineOption::__shortName [private] |
short name (-h for instance)
Definition at line 53 of file CommandLineOption.hpp.
Referenced by shortName().
const std::string CommandLineOption::__description [private] |
Description of the option
Definition at line 54 of file CommandLineOption.hpp.
Referenced by description().
std::vector<ArgumentsType> CommandLineOption::__arguments [private] |
Arguments type
Definition at line 55 of file CommandLineOption.hpp.
Referenced by arguments(), and CommandLineOption().
1.5.6