soma-io  5.1.2
OptionsParser Class Reference

#include <soma-io/doc/getopt_doc.h>

Detailed Description

Generic commandline options parser

OptionsParser parses the commandline options and fills in parameter variables. It is generally used via "application" subclasses like CartoApplication.

Commandline parameters are declared and described using the addOption() or addOptionSeries() methods. These template methods allow to use arbitrary parameters types.

Once declared, options are parsed by calling parse(). parse() does not report errors for missing parameters: this is done by calling check() after parameters have been parsed.

Parameters types are handled by wrapper classes: OptionBase, specialized into SingleOption (by addOption) and OptionSeries (by addOptionSeries). Common types are understood (int, float and other scalar types, strings...), and other parameter types may be added by specializing the SingleOption template for the new types. This is done, for instance, for Reader and Writer classes in aims (and soon in cartobase).

On the commandline, parameter switches may have several names (see the alias() method). They may be omitted when they are non-ambiguous: for instance if the command cartoDummy accepts a "-i" parameter and a "-o" parameter, invoking it as:

cartoDummy -i file1 -o file2

is the same as invoking:

cartodummy file1 file2

But if the "-o" parameter is optional and if you need to pass a third, optional parameter "-x", then you have to specify it to avoid confusion with the missing "-o" parameter.


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