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. | |
OptionGroup * | add (OptionGroup *group) |
Add an OptionGroup to this engine. | |
Engine * | add (Engine *o) |
Add a Engine to this engine. | |
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. | |
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. | |
OptionGroup * | createGroup (const std::string &description) |
Create an OptionGroup. | |
OptionGroup * | addGroup (const std::string &description) |
Create an OptionGroup and add it to this engine. | |
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. | |
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. | |
const std::vector< OptionGroup * > & | groups () const |
Get the OptionGroups that have been added to this engine. | |
const std::vector< Option * > & | options () const |
Get the Options that have been added to this engine. | |
const std::vector< Engine * > & | commands () const |
Get the Engines that have been added to this engine. | |
Engine * | command (const std::string &name) const |
bool | hasOptions () const |
Returns true if this Engine has options to parse. | |
Engine * | foundCommand () const |
Return the command that has been found in the commandline, or NULL if none have been found. | |
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'. | |
ArgList::iterator | parseKnownSwitches (ArgList &list, ArgList::iterator begin) |
Parse all known Options and leave the rest in list. | |
ArgList::iterator | parseList (ArgList &list) |
Parse the list of arguments, starting at the beginning and removing the arguments it successfully parses. | |
ArgList::iterator | parse (ArgList &list, ArgList::iterator begin) |
Parse all the switches in list, leaving only the non-switch arguments or the arguments following "--". | |
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 |
References m_aliases.
Referenced by add(), addEngine(), addGroup(), Engine2::Engine2(), and rebuild().
|
inline |
Create an option and add to this engine.
References add(), description, name(), and usage.
Add a Engine to this engine.
References m_commands.
OptionGroup * wibble::commandline::Engine::add | ( | OptionGroup * | group | ) |
Add an OptionGroup to this engine.
References m_groups.
|
inline |
Create a Engine and add it to this engine as a command.
References add(), createEngine(), description, longDescription, name(), and usage.
Referenced by Engine2::Engine2(), and wibble::commandline::StandardParserWithMandatoryCommand::StandardParserWithMandatoryCommand().
|
inline |
Create an OptionGroup and add it to this engine.
References add(), createGroup(), and description.
Referenced by wibble::commandline::StandardParser::StandardParser().
References addWithoutAna().
References m_long, and m_short.
Referenced by addWithoutAna(), and rebuild().
References m_aliases, and name().
Referenced by wibble::commandline::StandardParserWithMandatoryCommand::parse().
Get the Engines that have been added to this engine.
References m_commands.
|
inline |
Create an option.
References wibble::commandline::MemoryManager::add(), description, name(), and usage.
|
inline |
Create a Engine.
References wibble::commandline::MemoryManager::add(), description, longDescription, name(), and usage.
Referenced by addEngine().
|
inline |
Create an OptionGroup.
References wibble::commandline::MemoryManager::add(), and description.
Referenced by addGroup().
|
inline |
Return the command that has been found in the commandline, or NULL if none have been found.
References m_found_command.
Referenced by wibble::commandline::StandardParser::outputHelp(), and wibble::commandline::StandardParserWithMandatoryCommand::parse().
|
inline |
Get the OptionGroups that have been added to this engine.
References m_groups.
|
inline |
|
inline |
Referenced by add(), addEngine(), command(), create(), createEngine(), dump(), wibble::commandline::StandardParser::outputHelp(), wibble::commandline::StandardParser::parse(), wibble::commandline::StandardParserWithManpage::parse(), wibble::commandline::StandardParserWithMandatoryCommand::parse(), parseFirstIfKnown(), and wibble::commandline::StandardParserWithManpage::StandardParserWithManpage().
Get the Options that have been added to this engine.
References m_options.
|
protected |
Parse all the switches in list, leaving only the non-switch arguments or the arguments following "--".
References wibble::commandline::ArgList::isSwitch(), m_aliases, m_commands, m_found_command, no_switches_after_first_arg, parse(), parseKnownSwitches(), and rebuild().
Referenced by parse(), and 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::commandline::ArgList::eraseAndAdvance(), m_long, m_short, and name().
Referenced by parseKnownSwitches().
|
protected |
Parse all known Options and leave the rest in list.
References wibble::commandline::ArgList::isSwitch(), no_switches_after_first_arg, and parseFirstIfKnown().
Referenced by parse().
|
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 |
References add(), addWithoutAna(), m_aliases, m_commands, m_groups, m_long, m_options, and m_short.
std::vector<std::string> wibble::commandline::Engine::aliases |
Referenced by Engine2::Engine2().
std::string wibble::commandline::Engine::description |
Referenced by add(), addEngine(), addGroup(), create(), createEngine(), and createGroup().
std::string wibble::commandline::Engine::examples |
bool wibble::commandline::Engine::hidden |
std::string wibble::commandline::Engine::longDescription |
Referenced by addEngine(), and createEngine().
|
protected |
|
protected |
Referenced by add(), commands(), dump(), parse(), and rebuild().
|
protected |
Referenced by foundCommand(), and parse().
|
protected |
Referenced by add(), dump(), groups(), hasOptions(), and rebuild().
|
protected |
Referenced by addWithoutAna(), dump(), parseFirstIfKnown(), and rebuild().
|
protected |
Referenced by add(), dump(), hasOptions(), options(), and rebuild().
Referenced by addWithoutAna(), dump(), parseFirstIfKnown(), and rebuild().
bool wibble::commandline::Engine::no_switches_after_first_arg |
Referenced by parse(), and parseKnownSwitches().
std::string wibble::commandline::Engine::primaryAlias |
std::string wibble::commandline::Engine::usage |
Referenced by add(), addEngine(), create(), and createEngine().