Command line option parser.
More...
- Description:
- os::OptionParser is a utility class that can help you parse command line options. It also have members for automatic generation of a help text suitable for the "–help" option available in most command line commands. The help text feature will format the text according to the current terminal widht (or optionally a suplied with) performing necessarry word-wrapping to make the text as readable as possible.
- The rules for option parsing is mostly compatible with the GNU getopt() function. There is two kind of options. Short-options or flag start with a single "-" and ends with a single letter. Long options start with "–" and end with a string. Both short-options and long-options can have additional arguments. If a short-option take an additional argument it the next option will be used as the argument value. If a long-option take an additional argument it must be specified as "–opt=arg". All arguments that are not recognized as options will be added to a "file-list" that can later be iterated. If one of the arguments is "–" the option parsing will stop there and the rest of the arguments will be added unconditionally to the "file-list".
- Since
- 0.3.7
- Author
- Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)
OptionParser::OptionParser |
( |
int |
argc, |
|
|
const char *const * |
argv |
|
) |
| |
OptionParser::~OptionParser |
( |
| ) |
|
void OptionParser::AddArgMap |
( |
const argmap * |
pasMap | ) |
|
void OptionParser::AddArgMap |
( |
const String & |
cLongArg, |
|
|
char |
nShortArg, |
|
|
const String & |
cDesc |
|
) |
| |
const std::vector< String > & OptionParser::GetArgs |
( |
| ) |
const |
const std::vector< String > & OptionParser::GetFileArgs |
( |
| ) |
const |
int OptionParser::GetFileCount |
( |
| ) |
const |
String OptionParser::GetHelpText |
( |
int |
nWidth = 0 | ) |
const |
int OptionParser::GetOptionCount |
( |
| ) |
const |
String OptionParser::operator[] |
( |
int |
nIndex | ) |
const |
void OptionParser::ParseOptions |
( |
const char * |
pzOptions | ) |
|
References os::String::begin(), os::String::c_str(), os::String::const_str(), os::String::end(), os::OptionParser::option::has_value, os::OptionParser::option::long_name, os::OptionParser::Private::m_cArgs, os::OptionParser::Private::m_cFileArgs, os::OptionParser::Private::m_cOptionList, os::String::npos, os::OptionParser::option::opt, os::OptionParser::option::raw_opt, os::String::size(), and os::OptionParser::option::value.
void OptionParser::PrintHelpText |
( |
int |
nWidth = 0 | ) |
const |
void OptionParser::PrintHelpText |
( |
StreamableIO * |
pcStream, |
|
|
int |
nWidth = 0 |
|
) |
| const |
void OptionParser::RewindOptions |
( |
| ) |
|