#include <llcommandlineparser.h>
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_t & | getOption (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 |
Definition at line 54 of file llcommandlineparser.h.
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.
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.
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().
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().
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().
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().
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().
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<<().
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().
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().
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().
void LLCommandLineParser::setCustomParser | ( | parser_func | f | ) | [inline] |
Definition at line 130 of file llcommandlineparser.h.
References mExtraParser.
Referenced by LLAppViewerMacOSX::initParseCommandLine().
bool LLCommandLineParser::parseAndStoreResults | ( | boost::program_options::command_line_parser & | clp | ) | [private] |
Referenced by parseCommandLine(), and parseCommandLineString().
std::string LLCommandLineParser::mErrorMsg [private] |
parser_func LLCommandLineParser::mExtraParser [private] |