Stellarium 0.15.2
List of all members | Static Public Member Functions
CLIProcessor Class Reference

Static Public Member Functions

static bool argsGetOption (const QStringList &argList, QString shortOpt, QString longOpt)
 Check if a QStringList has a CLI-style option in it (before the first –). More...
 
static QVariant argsGetOptionWithArg (const QStringList &argList, QString shortOpt, QString longOpt, QVariant defaultValue)
 Retrieve the argument to an option from a QStringList. More...
 
static int argsGetYesNoOption (const QStringList &argList, QString shortOpt, QString longOpt, int defaultValue)
 Check if a QStringList has a yes/no CLI-style option in it, and find out the argument to that parameter. More...
 
static void parseCLIArgsPreConfig (const QStringList &argList)
 Processing of command line options which is to be done before config file is read. More...
 
static void parseCLIArgsPostConfig (const QStringList &argList, QSettings *conf)
 Processing of command line options which is to be done after the config file is read. More...
 

Detailed Description

Definition at line 28 of file CLIProcessor.hpp.

Member Function Documentation

static bool CLIProcessor::argsGetOption ( const QStringList &  argList,
QString  shortOpt,
QString  longOpt 
)
static

Check if a QStringList has a CLI-style option in it (before the first –).

Parameters
argLista list of strings, think argv
shortOpta short-form option string, e.g, "-h"
longOpta long-form option string, e.g. "--help"
Returns
true if the option exists in args before any element which is "--"
static QVariant CLIProcessor::argsGetOptionWithArg ( const QStringList &  argList,
QString  shortOpt,
QString  longOpt,
QVariant  defaultValue 
)
static

Retrieve the argument to an option from a QStringList.

Given a list of strings, this function will extract the argument of type T to an option, where the option in an element which matches either the short or long forms, and the argument to that option is the following element in the list, e.g. ("--option", "arg"). It is also possible to extract argument to options which are part of the option element, separated by the "=" character, e.g. ( "--option=arg" ). Type conversion is done using the QTextStream class, and as such possible types which this template function may use are restricted to those where there is a value operator<<() defined in the QTextStream class for that type. The argument list is only processed as far as the first value "--". If an argument "--" is to be retrieved, it must be apecified using the "--option=--" form.

Parameters
argLista list of strings, think argv.
shortOptthe short form of the option, e.g. "-n".
longOptthe long form of the option, e.g. "--number".
defaultValuethe default value to return if the option was not found in args.
Exceptions
runtime_error("no_optarg")the expected argument to the option was not found.
runtime_error("optarg_type")the expected argument to the option could not be converted.
Returns
The value of the argument to the specified option which occurs before the first element with the value "--". If the option is not found, defaultValue is returned.
static int CLIProcessor::argsGetYesNoOption ( const QStringList &  argList,
QString  shortOpt,
QString  longOpt,
int  defaultValue 
)
static

Check if a QStringList has a yes/no CLI-style option in it, and find out the argument to that parameter.

e.g. option –use-foo can have parameter "yes" or "no" It is also possible for the argument to take values, "1", "0"; "true", "false";

Parameters
argLista list of strings, think argv
shortOpta short-form option string, e.g, "-h"
longOpta long-form option string, e.g. "--help"
defaultValuethe default value to return if the option was not found in args.
Exceptions
runtime_error("no_optarg")the expected argument to the option was not found. The longOpt value is appended in parenthesis.
runtime_error("optarg_type")the expected argument to the option could not be converted. The longOpt value is appended in parenthesis.
Returns
1 if the argument to the specified opion is "yes", "y", "true", "on" or 1; 0 if the argument to the specified opion is "no", "n", "false", "off" or 0; the value of the defaultValue parameter if the option was not found in the argument list before an element which has the value "--".
static void CLIProcessor::parseCLIArgsPostConfig ( const QStringList &  argList,
QSettings *  conf 
)
static

Processing of command line options which is to be done after the config file is read.

This gives us the chance to over-ride settings which are in the configuration file.

static void CLIProcessor::parseCLIArgsPreConfig ( const QStringList &  argList)
static

Processing of command line options which is to be done before config file is read.

This includes the chance to set the configuration file name. It is to be done in the sub-class of the StelApp, as the sub-class may want to manage the argument list, as is the case with the StelMainWindow version.


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