Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
Manager Class Reference

#include <elm/option/Manager.h>

+ Inheritance diagram for Manager:

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 Versionversion (void) const
 
cstring author (void) const
 
cstring copyright (void) const
 
cstring description (void) const
 
cstring freeArgumentDescription (void) const
 
cstring getProgram (void) const
 
const VersiongetVersion (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
 

Detailed Description

This class is used for managing the options of a command.

See also
Command Line Options

Constructor & Destructor Documentation

◆ Manager() [1/2]

Manager ( void  )

◆ Manager() [2/2]

Manager ( const Make maker)

Build a new option manager.

Parameters
makerInformation for initialization.

References Manager::description(), and Manager::info.

◆ ~Manager()

~Manager ( void  )
virtual

Member Function Documentation

◆ addOption()

void addOption ( Option option)

Add an option to the manager.

Parameters
optionOption to add.
Exceptions
OptionExceptionIf the short name or the long name is already used.

◆ author()

cstring author ( void  ) const
inline

References Manager::info.

◆ copyright()

cstring copyright ( void  ) const
inline

References Manager::info.

◆ description()

cstring description ( void  ) const
inline

References Manager::info.

Referenced by Manager::Manager().

◆ displayHelp()

◆ displayVersion()

void displayVersion ( void  )
virtual

Display version information on the standard output.

References elm::cout, elm::io::endl, and Manager::info.

◆ freeArgumentDescription()

cstring freeArgumentDescription ( void  ) const
inline

References Manager::info.

◆ freeArguments()

const Vector< string > & freeArguments ( ) const
inlineprotected
Returns
List of free arguments.

◆ getAuthor()

cstring getAuthor ( void  ) const
inline

References Manager::info.

◆ getCopyright()

cstring getCopyright ( void  ) const
inline

References Manager::info.

◆ getDescription()

cstring getDescription ( void  ) const
inline

References Manager::info.

◆ getFreeArgumentDescription()

cstring getFreeArgumentDescription ( void  ) const
inline

References Manager::info.

◆ getProgram()

cstring getProgram ( void  ) const
inline

References Manager::info.

◆ getVersion()

const Version& getVersion ( void  ) const
inline

References Manager::info.

◆ make_switch()

SwitchOption::Make make_switch ( void  )
inline

This function is a shortcut to SwitchOption::Make() to reduce the definition of options inside a @ef Manager class.

◆ make_value()

ValueOption<T>::Make make_value ( void  )
inline

◆ manage()

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:

int main(int argc, char **argv) {
return MyApplication.manager(argc, argv);
}
Parameters
argcArgument count.
argvArgument list.
Returns
Exit code.

References elm::cerr, Manager::displayHelp(), elm::io::endl, Exception::message(), MessageException::message(), Manager::parse(), and Manager::run().

◆ parse()

void parse ( int  argc,
argv_t  argv 
)

Parse the given options.

Parameters
argcArgument count.
argvArgument vector.
Exceptions
OptionExceptionThrown 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().

◆ process()

void process ( String  arg)
protectedvirtual

Called each time a free argumend (not tied to an option) is found.

Parameters
argFree argument value.

Reimplemented in ElmPlugin.

Referenced by Manager::parse().

◆ program()

cstring program ( void  ) const
inline

References Manager::info.

◆ removeOption()

void removeOption ( Option option)

Remove the option from the manager.

Parameters
optionOption to remove.

◆ run()

void run ( void  )
protectedvirtual

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.

Exceptions
elm::ExceptionFor any error during application run.

Reimplemented in ElmPlugin.

Referenced by Manager::manage().

◆ version()

const Version& version ( void  ) const
inline

References Manager::info.

Member Data Documentation

◆ argv_t

const typedef char* const * argv_t

◆ info


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