wibble
1.1
|
Parse commandline options. More...
#include <engine.h>
Public Member Functions | |
const std::string & | name () const |
Option * | add (Option *o) |
Add an Option to this engine. More... | |
OptionGroup * | add (OptionGroup *group) |
Add an OptionGroup to this engine. More... | |
Engine * | add (Engine *o) |
Add a Engine to this engine. More... | |
template<typename T > | |
T * | create (const std::string &name, char shortName, const std::string &longName, const std::string &usage=std::string(), const std::string &description=std::string()) |
Create an option. More... | |
template<typename T > | |
T * | add (const std::string &name, char shortName, const std::string &longName, const std::string &usage=std::string(), const std::string &description=std::string()) |
Create an option and add to this engine. More... | |
OptionGroup * | createGroup (const std::string &description) |
Create an OptionGroup. More... | |
OptionGroup * | addGroup (const std::string &description) |
Create an OptionGroup and add it to this engine. More... | |
Engine * | createEngine (const std::string &name, const std::string &usage=std::string(), const std::string &description=std::string(), const std::string &longDescription=std::string()) |
Create a Engine. More... | |
Engine * | addEngine (const std::string &name, const std::string &usage=std::string(), const std::string &description=std::string(), const std::string &longDescription=std::string()) |
Create a Engine and add it to this engine as a command. More... | |
const std::vector< OptionGroup * > & | groups () const |
Get the OptionGroups that have been added to this engine. More... | |
const std::vector< Option * > & | options () const |
Get the Options that have been added to this engine. More... | |
const std::vector< Engine * > & | commands () const |
Get the Engines that have been added to this engine. More... | |
Engine * | command (const std::string &name) const |
bool | hasOptions () const |
Returns true if this Engine has options to parse. More... | |
Engine * | foundCommand () const |
Return the command that has been found in the commandline, or NULL if none have been found. More... | |
void | dump (std::ostream &out, const std::string &prefix=std::string()) |
![]() | |
virtual | ~Managed () |
Public Attributes | |
std::string | primaryAlias |
std::vector< std::string > | aliases |
std::string | usage |
std::string | description |
std::string | longDescription |
std::string | examples |
bool | hidden |
bool | no_switches_after_first_arg |
Protected Member Functions | |
void | addWithoutAna (Option *o) |
void | addWithoutAna (const std::vector< Option * > &o) |
void | add (const std::string &alias, Engine *o) |
void | rebuild () |
std::pair< ArgList::iterator, bool > | parseFirstIfKnown (ArgList &list, ArgList::iterator begin) |
Handle the commandline switch at 'begin'. More... | |
ArgList::iterator | parseKnownSwitches (ArgList &list, ArgList::iterator begin) |
Parse all known Options and leave the rest in list. More... | |
ArgList::iterator | parseList (ArgList &list) |
Parse the list of arguments, starting at the beginning and removing the arguments it successfully parses. More... | |
ArgList::iterator | parse (ArgList &list, ArgList::iterator begin) |
Parse all the switches in list, leaving only the non-switch arguments or the arguments following "--". More... | |
Engine (MemoryManager *mman=0, const std::string &name=std::string(), const std::string &usage=std::string(), const std::string &description=std::string(), const std::string &longDescription=std::string()) | |
Protected Attributes | |
std::vector< OptionGroup * > | m_groups |
std::vector< Option * > | m_options |
std::vector< Engine * > | m_commands |
std::map< char, Option * > | m_short |
std::map< std::string, Option * > | m_long |
std::map< std::string, Engine * > | m_aliases |
Engine * | m_found_command |
Friends | |
class | Parser |
Parse commandline options.
Normally it parses short or long switches all starting with '-'
If other engines are added, then looks in the commandline for a non-switch command to select the operation mode. This allow to have a custom set of commandline options for every non-switch command.
|
inlineprotected |
Referenced by createEngine().
|
protected |
References wibble::iterator().
Referenced by add(), addEngine(), addGroup(), and withCommands().
OptionGroup * Engine::add | ( | OptionGroup * | group) |
Add an OptionGroup to this engine.
|
inline |
Create an option and add to this engine.
References add(), description, name(), and usage.
|
inline |
Create a Engine and add it to this engine as a command.
References add(), createEngine(), description, longDescription, and usage.
Referenced by TestCommandlineDoc::basic(), wibble::commandline::StandardParserWithMandatoryCommand::StandardParserWithMandatoryCommand(), and withCommands().
|
inline |
Create an OptionGroup and add it to this engine.
References add(), and createGroup().
Referenced by TestCommandlineDoc::basic(), and wibble::commandline::StandardParser::StandardParser().
|
protected |
|
protected |
|
inline |
References m_aliases.
|
inline |
Get the Engines that have been added to this engine.
References m_commands.
Referenced by wibble::commandline::Manpage::output(), and wibble::commandline::Help::outputHelp().
|
inline |
Create an option.
References wibble::commandline::MemoryManager::add(), description, and usage.
|
inline |
Create a Engine.
References wibble::commandline::MemoryManager::add(), description, Engine(), longDescription, and usage.
Referenced by addEngine().
|
inline |
Create an OptionGroup.
References wibble::commandline::MemoryManager::add().
Referenced by addGroup().
void Engine::dump | ( | std::ostream & | out, |
const std::string & | prefix = std::string() |
||
) |
|
inline |
Return the command that has been found in the commandline, or NULL if none have been found.
References m_found_command.
Referenced by withCommands().
|
inline |
Get the OptionGroups that have been added to this engine.
References m_groups.
Referenced by wibble::commandline::Help::outputOptions().
|
inline |
Returns true if this Engine has options to parse.
References m_groups, and m_options.
Referenced by wibble::commandline::Help::outputHelp().
|
inline |
|
inline |
Get the Options that have been added to this engine.
References m_options.
Referenced by wibble::commandline::Help::outputOptions().
|
protected |
Parse all the switches in list, leaving only the non-switch arguments or the arguments following "--".
References wibble::list::begin(), wibble::commandline::ArgList::isSwitch(), and wibble::iterator().
Referenced by parseList().
|
protected |
Handle the commandline switch at 'begin'.
If the switch at 'begin' cannot be handled, the list is untouched and 'begin',false is returned. Else, the switch is removed and the new begin is returned.
References wibble::list::begin(), wibble::commandline::ArgList::eraseAndAdvance(), and wibble::iterator().
|
protected |
Parse all known Options and leave the rest in list.
References wibble::list::begin(), wibble::commandline::ArgList::isSwitch(), and wibble::iterator().
|
inlineprotected |
Parse the list of arguments, starting at the beginning and removing the arguments it successfully parses.
References parse().
Referenced by wibble::commandline::Parser::parse().
|
protected |
|
friend |
std::vector<std::string> wibble::commandline::Engine::aliases |
Referenced by wibble::commandline::Help::outputHelp().
std::string wibble::commandline::Engine::description |
std::string wibble::commandline::Engine::examples |
bool wibble::commandline::Engine::hidden |
std::string wibble::commandline::Engine::longDescription |
Referenced by addEngine(), createEngine(), wibble::commandline::Manpage::output(), and withCommands().
|
protected |
Referenced by command().
|
protected |
Referenced by commands().
|
protected |
Referenced by foundCommand().
|
protected |
Referenced by groups(), and hasOptions().
|
protected |
|
protected |
Referenced by hasOptions(), and options().
|
protected |
bool wibble::commandline::Engine::no_switches_after_first_arg |
std::string wibble::commandline::Engine::primaryAlias |
Referenced by wibble::commandline::Help::outputHelp().
std::string wibble::commandline::Engine::usage |