LLCommandLineParser Class Reference

Handle defining and parsing the command line. More...

#include <llcommandlineparser.h>

Inheritance diagram for LLCommandLineParser:

Inheritance graph
[legend]
Collaboration diagram for LLCommandLineParser:

Collaboration graph
[legend]

List of all members.

Public Types

typedef std::vector< std::string > token_vector_t
typedef boost::function1
< std::pair< std::string,
std::string >, const
std::string & > 
parser_func
 Add a custom parser func to the parser.

Public Member Functions

void addOptionDesc (const LLString &option_name, boost::function1< void, const token_vector_t & > notify_callback=0, unsigned int num_tokens=0, const LLString &description=LLString::null, const LLString &short_name=LLString::null, bool composing=false, bool positional=false, bool last_option=false)
 Add a value-less option to the command line description.
bool parseCommandLine (int argc, char **argv)
 Parse the command line given by argc/argv.
bool parseCommandLineString (const std::string &str)
 Parse the command line contained by the given file.
bool parseCommandLineFile (const std::basic_istream< char > &file)
 Parse the command line contained by the given file.
void notify ()
 Call callbacks associated with option descriptions.
std::ostream & printOptionsDesc (std::ostream &os) const
 Print a description of the configured options.
bool hasOption (const std::string &name) const
 Manual option setting accessors.
const token_vector_tgetOption (const std::string &name) const
void printOptions () const
 Print the list of configured options.
const std::string & getErrorMessage () const
void setCustomParser (parser_func f)

Private Member Functions

bool parseAndStoreResults (boost::program_options::command_line_parser &clp)

Private Attributes

std::string mErrorMsg
parser_func mExtraParser


Detailed Description

Handle defining and parsing the command line.

Definition at line 54 of file llcommandlineparser.h.


Member Typedef Documentation

typedef std::vector< std::string > LLCommandLineParser::token_vector_t

Definition at line 57 of file llcommandlineparser.h.

typedef boost::function1<std::pair<std::string, std::string>, const std::string&> LLCommandLineParser::parser_func

Add a custom parser func to the parser.

Use this method to add a custom parser for parsing values the the simple parser may not handle. it will be applied to each parameter before the default parser gets a chance. The parser_func takes an input string, and should return a name/value pair as the result.

Definition at line 129 of file llcommandlineparser.h.


Member Function Documentation

void LLCommandLineParser::addOptionDesc ( const LLString option_name,
boost::function1< void, const token_vector_t & >  notify_callback = 0,
unsigned int  num_tokens = 0,
const LLString description = LLString::null,
const LLString short_name = LLString::null,
bool  composing = false,
bool  positional = false,
bool  last_option = false 
)

Add a value-less option to the command line description.

Parameters:
option_name The long name of the cmd-line option.
description The text description of the option usage.

Definition at line 221 of file llcommandlineparser.cpp.

References d, gOptionsDesc, gPositionalOptions, LLStringBase< char >::null, LLCLPValue::setComposing(), LLCLPValue::setLastOption(), LLCLPValue::setMaxTokens(), LLCLPValue::setMinTokens(), and LLCLPValue::setNotifyCallback().

Referenced by LLControlGroupCLP::configure(), and LLAppViewerMacOSX::initParseCommandLine().

Here is the call graph for this function:

Here is the caller graph for this function:

bool LLCommandLineParser::parseCommandLine ( int  argc,
char **  argv 
)

Parse the command line given by argc/argv.

Definition at line 312 of file llcommandlineparser.cpp.

References parseAndStoreResults().

Referenced by LLAppViewerMacOSX::initParseCommandLine(), and LLAppViewerLinux::initParseCommandLine().

Here is the call graph for this function:

Here is the caller graph for this function:

bool LLCommandLineParser::parseCommandLineString ( const std::string &  str  ) 

Parse the command line contained by the given file.

Definition at line 318 of file llcommandlineparser.cpp.

References i, and parseAndStoreResults().

Referenced by LLAppViewerWin32::initParseCommandLine(), and parseCommandLineFile().

Here is the call graph for this function:

Here is the caller graph for this function:

bool LLCommandLineParser::parseCommandLineFile ( const std::basic_istream< char > &  file  ) 

Parse the command line contained by the given file.

Definition at line 340 of file llcommandlineparser.cpp.

References parseCommandLineString(), and read_file_into_string().

Referenced by LLAppViewerMacOSX::initParseCommandLine().

Here is the call graph for this function:

Here is the caller graph for this function:

void LLCommandLineParser::notify (  ) 

Call callbacks associated with option descriptions.

Use this to handle the results of parsing.

Definition at line 348 of file llcommandlineparser.cpp.

References gVariableMap.

Referenced by LLAppViewer::initConfiguration().

Here is the caller graph for this function:

std::ostream & LLCommandLineParser::printOptionsDesc ( std::ostream &  os  )  const

Print a description of the configured options.

Use this to print a description of options to the given ostream. Useful for displaying usage info.

Definition at line 369 of file llcommandlineparser.cpp.

References gOptionsDesc.

Referenced by operator<<().

Here is the caller graph for this function:

bool LLCommandLineParser::hasOption ( const std::string &  name  )  const

Manual option setting accessors.

Use these to retrieve get the values set for an option. getOption will return an empty value if the option isn't set.

Definition at line 374 of file llcommandlineparser.cpp.

References gVariableMap.

Referenced by getOption(), and LLAppViewer::initConfiguration().

Here is the caller graph for this function:

const LLCommandLineParser::token_vector_t & LLCommandLineParser::getOption ( const std::string &  name  )  const

Definition at line 379 of file llcommandlineparser.cpp.

References gEmptyValue, gVariableMap, and hasOption().

Referenced by LLAppViewer::initConfiguration().

Here is the call graph for this function:

Here is the caller graph for this function:

void LLCommandLineParser::printOptions (  )  const

Print the list of configured options.

Definition at line 353 of file llcommandlineparser.cpp.

References gVariableMap, i, and llinfos.

const std::string& LLCommandLineParser::getErrorMessage (  )  const [inline]

Get the error message, if it exists.

Definition at line 118 of file llcommandlineparser.h.

References mErrorMsg.

Referenced by LLAppViewer::initConfiguration().

Here is the caller graph for this function:

void LLCommandLineParser::setCustomParser ( parser_func  f  )  [inline]

Definition at line 130 of file llcommandlineparser.h.

References mExtraParser.

Referenced by LLAppViewerMacOSX::initParseCommandLine().

Here is the caller graph for this function:

bool LLCommandLineParser::parseAndStoreResults ( boost::program_options::command_line_parser clp  )  [private]

Referenced by parseCommandLine(), and parseCommandLineString().

Here is the caller graph for this function:


Member Data Documentation

std::string LLCommandLineParser::mErrorMsg [private]

Definition at line 134 of file llcommandlineparser.h.

Referenced by getErrorMessage().

Definition at line 135 of file llcommandlineparser.h.

Referenced by setCustomParser().


The documentation for this class was generated from the following files:

Generated on Fri May 16 08:43:06 2008 for SecondLife by  doxygen 1.5.5