![]() |
Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/option/Manager.h>
Classes | |
class | Make |
Public Member Functions | |
SwitchOption::Make | make_switch (void) |
template<class T > | |
ValueOption< T >::Make | make_value (void) |
Manager (void) | |
Manager (const Make &maker) | |
virtual | ~Manager (void) |
void | addOption (Option *option) |
void | removeOption (Option *option) |
void | parse (int argc, argv_t argv) |
int | manage (int artc, argv_t argv) |
virtual void | displayHelp (void) |
virtual void | displayVersion (void) |
cstring | program (void) const |
const Version & | version (void) const |
cstring | author (void) const |
cstring | copyright (void) const |
cstring | description (void) const |
cstring | freeArgumentDescription (void) const |
cstring | getProgram (void) const |
const Version & | getVersion (void) const |
cstring | getAuthor (void) const |
cstring | getCopyright (void) const |
cstring | getDescription (void) const |
cstring | getFreeArgumentDescription (void) const |
Public Attributes | |
const typedef char *const * | argv_t |
Protected Member Functions | |
virtual void | process (String arg) |
virtual void | run (void) |
const Vector< string > & | freeArguments () const |
Protected Attributes | |
Make | info |
This class is used for managing the options of a command.
Build a new option manager.
maker | Information for initialization. |
References Manager::description(), and Manager::info.
Add an option to the manager.
option | Option to add. |
OptionException | If the short name or the long name is already used. |
References Manager::info.
References Manager::info.
References Manager::info.
Referenced by Manager::Manager().
Display the help text to standard error.
References Vector< T, E, A >::add(), elm::option::arg_none, elm::option::arg_optional, elm::option::arg_required, Option::argDescription(), elm::cerr, Vector< T, E, A >::contains(), Option::description(), elm::io::endl, Manager::info, elm::iter(), Option::usage(), and Version::ZERO.
Referenced by Manager::manage().
Display version information on the standard output.
References elm::cout, elm::io::endl, and Manager::info.
References Manager::info.
References Manager::info.
References Manager::info.
References Manager::info.
References Manager::info.
References Manager::info.
References Manager::info.
|
inline |
This function is a shortcut to SwitchOption::Make() to reduce the definition of options inside a @ef Manager class.
|
inline |
int manage | ( | int | argc, |
argv_t | argv | ||
) |
Call to a complete management of the application by the option manager. It will parse the given parameters and call the run method. In case of error, it will display it and provide an exit code.
It is able to make the main program code very simple:
argc | Argument count. |
argv | Argument list. |
References elm::cerr, Manager::displayHelp(), elm::io::endl, Exception::message(), MessageException::message(), Manager::parse(), and Manager::run().
Parse the given options.
argc | Argument count. |
argv | Argument vector. |
OptionException | Thrown if the syntax contains an error. |
References elm::_, Vector< T, E, A >::add(), String::indexOf(), String::length(), elm::io::p(), Manager::process(), and String::substring().
Referenced by Manager::manage().
Called each time a free argumend (not tied to an option) is found.
arg | Free argument value. |
Reimplemented in ElmPlugin.
Referenced by Manager::parse().
References Manager::info.
Remove the option from the manager.
option | Option to remove. |
Function called to run the application after the command line parse. It is called by Manager::manage() and can be overridden to provide its own behaviour to the application.
The default implementation do nothing.
elm::Exception | For any error during application run. |
Reimplemented in ElmPlugin.
Referenced by Manager::manage().
References Manager::info.
const typedef char* const * argv_t |
|
protected |
Referenced by Manager::author(), Manager::copyright(), Manager::description(), Manager::displayHelp(), Manager::displayVersion(), Manager::freeArgumentDescription(), Manager::getAuthor(), Manager::getCopyright(), Manager::getDescription(), Manager::getFreeArgumentDescription(), Manager::getProgram(), Manager::getVersion(), Manager::Manager(), Manager::program(), and Manager::version().