soma-io  5.0.5
carto::CartoApplication Class Reference

Cartograph options parser. More...

#include <soma-io/getopt/getopt.h>

Inheritance diagram for carto::CartoApplication:
Collaboration diagram for carto::CartoApplication:

Public Member Functions

 CartoApplication (int argc, const char **argv, const std::string &documentation)
 
virtual ~CartoApplication ()
 
virtual void initialize ()
 Parse and check all parameters, and handle common options (such as the "--help" option). More...
 
- Public Member Functions inherited from carto::OptionsParser
 OptionsParser (int argc, const char **argv)
 
 ~OptionsParser ()
 
template<typename T >
void addOption (T &param, const std::string &token, const std::string &description, bool optional=false)
 Adds a single parameter to be parsed on the commandline. More...
 
template<typename T >
void addOptionSeries (T &param, const std::string &token, const std::string &description, unsigned minnum=0, unsigned maxnum=0)
 Adds a series of parameters to be parsed on the commandline. More...
 
void alias (const std::string &to, const std::string &from)
 Gives an alternative name (token) to to the parameter of token from. More...
 
void parse ()
 Parses the commandline arguments (argc, argv) and fills in the registered parameters variables. More...
 
void check ()
 Check all needed parameters are filled in, and series numbers are OK. More...
 

Additional Inherited Members

- Public Types inherited from carto::OptionsParser
typedef std::vector< std::string > CommandLineArguments
 
- Protected Types inherited from carto::OptionsParser
typedef std::vector< OptionBase *> OptionList
 
- Protected Member Functions inherited from carto::OptionsParser
void pushOption (OptionBase *)
 
- Protected Attributes inherited from carto::OptionsParser
CommandLineArguments cla
 
OptionList options
 
int insertIndex
 

Detailed Description

Cartograph options parser.

Common options such as "--help", "--info" and "--version" are added. CartoApplication also requires a (short) documentation.

Usage: instantiate CartoApplication, add options using addOption(), then call initialize() to parse commandline options.

initialize() should always been called within a try..catch block, and the exception carto::user_interruption should be catched because it is thrown whenever the help is required (–help option).

Definition at line 581 of file getopt.h.

Constructor & Destructor Documentation

◆ CartoApplication()

carto::CartoApplication::CartoApplication ( int  argc,
const char **  argv,
const std::string &  documentation 
)

◆ ~CartoApplication()

virtual carto::CartoApplication::~CartoApplication ( )
virtual

Member Function Documentation

◆ initialize()

virtual void carto::CartoApplication::initialize ( )
virtual

Parse and check all parameters, and handle common options (such as the "--help" option).

initialize() also triggers loading plugins because some functionalities provided as plugins may be needed to correctly handle some options.


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