#include <CmdLineOptionParser.hh>
|
int | value_ |
| The value of option.
|
|
Models an option that has an integer value.
Definition at line 117 of file CmdLineOptionParser.hh.
◆ IntegerCmdLineOptionParser() [1/2]
IntegerCmdLineOptionParser::IntegerCmdLineOptionParser |
( |
std::string |
name, |
|
|
std::string |
desc, |
|
|
std::string |
alias = "" |
|
) |
| |
Constructor.
- Parameters
-
name | The name of the option. |
desc | The description of the option. |
alias | The short name of the option. |
Definition at line 184 of file CmdLineOptionParser.cc.
188}
int value_
The value of option.
◆ ~IntegerCmdLineOptionParser()
IntegerCmdLineOptionParser::~IntegerCmdLineOptionParser |
( |
| ) |
|
|
virtual |
◆ IntegerCmdLineOptionParser() [2/2]
◆ copy()
OptionValue * IntegerCmdLineOptionParser::copy |
( |
| ) |
const |
|
virtual |
◆ integer()
int IntegerCmdLineOptionParser::integer |
( |
int |
index = 0 | ) |
const |
|
virtual |
Returns the value of integer option.
- Parameters
-
index | This must be zero for integer option. |
- Returns
- The value of integer option.
- Exceptions
-
Reimplemented from CmdLineOptionParser.
Definition at line 253 of file CmdLineOptionParser.cc.
253 {
256}
#define assert(condition)
References assert, and value_.
◆ operator=()
◆ parseValue()
bool IntegerCmdLineOptionParser::parseValue |
( |
std::string |
arguments, |
|
|
std::string |
prefix |
|
) |
| |
|
virtual |
Parses the integer option value.
- Parameters
-
arguments | The arguments of option. |
prefix | The prefix of option. |
- Returns
- True when parsing is ready.
- Exceptions
-
Implements CmdLineOptionParser.
Definition at line 219 of file CmdLineOptionParser.cc.
220 {
221 if (prefix != "") {
222 string msg = "Illegal prefix for integer option";
223 string method = "IntegerCmdLineOptionParser::parseValue()";
225 }
226
227 if (arguments == "") {
228 string msg = "Missing value for integer option.";
229 string method = "IntegerCmdLineOptionParser::parseValue()";
231 }
232
233 istringstream istream(arguments);
234 if((!(istream >>
value_)) || istream.peek() != EOF) {
235 string msg =
"Format of " +
longName() +
" option value was wrong: "
236 + arguments;
237 string method = "IntegerCmdLineOptionParser::parseValue()";
239 }
240
242 return true;
243}
std::string longName() const
References CmdLineOptionParser::longName(), CmdLineOptionParser::setDefined(), and value_.
◆ value_
int IntegerCmdLineOptionParser::value_ |
|
private |
The documentation for this class was generated from the following files: