Parse command line options.
More...
#include <util/options/GetLongOpt.h>
|
enum | OptType { NoValue,
OptionalValue,
MandatoryValue
} |
| Used by the enroll member to specify whether or not a value is expected or optional.
|
|
|
| GetLongOpt (const char optmark='-') |
| Initialize the object. More...
|
|
int | parse (int argc, char *const *argv) |
| Parse command line options. More...
|
|
int | parse (char *const str, char *const p) |
| Parse options in a string. More...
|
|
int | enroll (const char *const opt, const OptType t, const char *const desc, const char *const val) |
| Enroll an option. More...
|
|
const char * | retrieve (const char *const opt) const |
| Retrieve an option. More...
|
|
void | usage (std::ostream &outfile=std::cout) const |
| Print usage information. More...
|
|
void | usage (const char *str) |
| Initialize usage synopsis. More...
|
|
Parse command line options.
◆ GetLongOpt()
sc::GetLongOpt::GetLongOpt |
( |
const char |
optmark = '-' | ) |
|
Initialize the object.
- Parameters
-
optmark | the option flag marker (default is - ). |
◆ enroll()
int sc::GetLongOpt::enroll |
( |
const char *const |
opt, |
|
|
const OptType |
t, |
|
|
const char *const |
desc, |
|
|
const char *const |
val |
|
) |
| |
Enroll an option.
- Parameters
-
opt | the option name |
t | whether or not a value is expected |
desc | a description of the option |
val | a default value for the option with an optional value |
◆ parse() [1/2]
int sc::GetLongOpt::parse |
( |
char *const |
str, |
|
|
char *const |
p |
|
) |
| |
Parse options in a string.
- Parameters
-
str | the string to be parsed |
p | a prefix that will be prefixed to error messages |
- Returns
- the index to the start of arguments that were not processed (an error occurred if the return value is < 1)
◆ parse() [2/2]
int sc::GetLongOpt::parse |
( |
int |
argc, |
|
|
char *const * |
argv |
|
) |
| |
Parse command line options.
- Parameters
-
argc | the number of arguments, as passed to main |
argv | the arguments, as passed to main |
- Returns
- the index to the start of arguments that were not processed (an error occurred if the return value is < 1)
◆ retrieve()
const char* sc::GetLongOpt::retrieve |
( |
const char *const |
opt | ) |
const |
Retrieve an option.
- Parameters
-
opt | the name of the option |
◆ usage() [1/2]
void sc::GetLongOpt::usage |
( |
const char * |
str | ) |
|
|
inline |
Initialize usage synopsis.
- Parameters
-
◆ usage() [2/2]
void sc::GetLongOpt::usage |
( |
std::ostream & |
outfile = std::cout | ) |
const |
Print usage information.
- Parameters
-
outfile | stream to use for printing (default: std::cout ) |
The documentation for this class was generated from the following file: