#include <optionparser.h>
Public Methods | |
OptionParser (int argc, const char *const *argv) | |
~OptionParser () | |
void | AddArgMap (const argmap *pasMap) |
void | AddArgMap (const std::string &cLongArg, char nShortArg, const std::string &cDesc) |
void | ParseOptions (const char *pzOptions) |
int | GetOptionCount () const |
int | GetFileCount () const |
const option * | FindOption (char nOpt) const |
const option * | FindOption (const std::string &cLongName) const |
const option * | GetNextOption () |
void | RewindOptions () |
const option * | GetOption (uint nIndex) const |
const std::vector< std::string > & | GetArgs () const |
const std::vector< std::string > & | GetFileArgs () const |
std::string | GetHelpText (int nWidth=0) const |
void | PrintHelpText (int nWidth=0) const |
void | PrintHelpText (FILE *hStream, int nWidth=0) const |
std::string | operator[] (int nIndex) const |
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".
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|