Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

os::OptionParser Class Reference

Command line option parser. More...

#include <optionparser.h>

List of all members.

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 optionFindOption (char nOpt) const
const optionFindOption (const std::string &cLongName) const
const optionGetNextOption ()
void RewindOptions ()
const optionGetOption (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


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 "--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@atheos.cx)


Constructor & Destructor Documentation

OptionParser::OptionParser int argc,
const char *const * argv
 

OptionParser::~OptionParser
 


Member Function Documentation

void OptionParser::AddArgMap const std::string & cLongArg,
char nShortArg,
const std::string & cDescription
 

void OptionParser::AddArgMap const argmap * pasMap
 

const OptionParser::option * OptionParser::FindOption const std::string & cLongName const
 

const OptionParser::option * OptionParser::FindOption char nOpt const
 

const std::vector< std::string > & OptionParser::GetArgs const
 

const std::vector< std::string > & OptionParser::GetFileArgs const
 

int OptionParser::GetFileCount const
 

std::string OptionParser::GetHelpText int nWidth = 0 const
 

const OptionParser::option * OptionParser::GetNextOption
 

const OptionParser::option * OptionParser::GetOption uint nIndex const
 

int OptionParser::GetOptionCount const
 

void OptionParser::ParseOptions const char * pzOptions
 

void OptionParser::PrintHelpText FILE * hStream,
int nWidth = 0
const
 

void OptionParser::PrintHelpText int nWidth = 0 const
 

void OptionParser::RewindOptions
 

std::string OptionParser::operator[] int nIndex const
 


Generated at Mon Oct 8 23:38:00 2001 for AtheOS higlevel API by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001