Pyro higlevel API
Classes | Public Member Functions | List of all members
os::OptionParser Class Reference

Command line option parser. More...

Classes

struct  argmap
 
struct  option
 
class  Private
 

Public Member Functions

 OptionParser (int argc, const char *const *argv)
 
 ~OptionParser ()
 
void AddArgMap (const argmap *pasMap)
 
void AddArgMap (const String &cLongArg, char nShortArg, const String &cDesc)
 
void ParseOptions (const char *pzOptions)
 
int GetOptionCount () const
 
int GetFileCount () const
 
const optionFindOption (char nOpt) const
 
const optionFindOption (const String &cLongName) const
 
const optionGetNextOption ()
 
void RewindOptions ()
 
const optionGetOption (uint nIndex) const
 
const std::vector< String > & GetArgs () const
 
const std::vector< String > & GetFileArgs () const
 
String GetHelpText (int nWidth=0) const
 
void PrintHelpText (int nWidth=0) const
 
void PrintHelpText (StreamableIO *pcStream, int nWidth=0) const
 
String operator[] (int nIndex) const
 

Detailed Description

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 "&ndash;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 "&ndash;" 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 "&ndash;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 "&ndash;" 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)

Constructor & Destructor Documentation

OptionParser::OptionParser ( int  argc,
const char *const *  argv 
)
OptionParser::~OptionParser ( )

Member Function Documentation

void OptionParser::AddArgMap ( const argmap pasMap)
void OptionParser::AddArgMap ( const String cLongArg,
char  nShortArg,
const String cDesc 
)
const OptionParser::option * OptionParser::FindOption ( char  nOpt) const
const OptionParser::option * OptionParser::FindOption ( const String cLongName) const
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
const OptionParser::option * OptionParser::GetNextOption ( )
const OptionParser::option * OptionParser::GetOption ( uint  nIndex) const
int OptionParser::GetOptionCount ( ) const
String OptionParser::operator[] ( int  nIndex) const
void OptionParser::ParseOptions ( const char *  pzOptions)
void OptionParser::PrintHelpText ( int  nWidth = 0) const

References GetHelpText().

void OptionParser::PrintHelpText ( StreamableIO pcStream,
int  nWidth = 0 
) const
void OptionParser::RewindOptions ( )