QuasarAppLib 1.0.530.c9fba11
QuasarAppUtils::Params Class Reference

The Params class Contains functions for working with input arguments and logs. This Class support next commandline arguments. More...

#include <params.h>

Collaboration diagram for QuasarAppUtils::Params:
Collaboration graph

Public Member Functions

 Params ()=delete

Static Public Member Functions

static bool parseParams (const int argc, const char *argv[], const OptionsDataList &options={})
 parseParams Parse input data of started application.
static bool parseParams (int argc, char *argv[], const OptionsDataList &options={})
 parseParams Parse input data of started application.
static bool parseParams (const QStringList &paramsArray, const OptionsDataList &options={})
 parseParams Parse input data of started application.
static QString getArg (const QString &key, const QString &def={})
 getArg return string value of a key if key is exits else return a def value. If a def value not defined returns empty string.
static void setArg (const QString &key, const QString &val)
 setArg sets a new value of a key.
static void setEnable (const QString &key, bool enable)
 setEnable This method sets boolean value of key.
static bool isEndable (const QString &key)
 isEndable This method check if enable a key argument.
static void log (const QString &log, VerboseLvl vLvl=VerboseLvl::Debug)
 log This method print log text on console.
static VerboseLvl getVerboseLvl ()
 getVerboseLvl This method return the verbose log level.
static bool isDebug ()
 isDebug This method return true if the application verbose level >= VerboseLvl::Debug.
static bool isDebugBuild ()
 isDebugBuild This method return true if the library buildet in debug mode.
static int size ()
 size This method return count of the all input arguments.
static void showHelp ()
 showHelp This method shows all help message.
static void showHelpForInputOptions ()
 showHelpForInputOptions This method show help for each input option.
static Help::Section getHelpOfInputOptions ()
 getHelpOfInputOptions This method return help abut input options only. Except help and h options.
static const Help::Section & getHelp ()
 getHelp This method return options help page.
static const QMap< QString, QString > & getUserParamsMap ()
 getUserParamsMap This method return const reference to the parsed arguments map.
static void clearParsedData ()
 clearParsedData This method clear all parsed data.
static QString getCurrentExecutable ()
 getCurrentExecutable This method return path to the current executable.
static QString getCurrentExecutableDir ()
 getCurrentExecutableDir This method return a path to a folder with the current executable.
static OptionsDataList availableArguments ()
 availableArguments This method return list of the available arguments of QuasarAppLibrary

Detailed Description

The Params class Contains functions for working with input arguments and logs. This Class support next commandline arguments.

  • -verbose (level 1 - 3) Shows debug log
  • -fileLog (path to file) Sets path of log file. Default it is path to executable file with suffix '.log'

Usage

#include <quasarapp.h>
exit(0);
}
static void showHelp()
showHelp This method shows all help message.
Definition params.cpp:87
static void log(const QString &log, VerboseLvl vLvl=VerboseLvl::Debug)
log This method print log text on console.
Definition params.cpp:39
static bool parseParams(const int argc, const char *argv[], const OptionsDataList &options={})
parseParams Parse input data of started application.
Definition params.cpp:193
@ Warning
Warning message. This logs will marked as a Warning and printing if the verbose lvl >= 1.
Definition params.h:27

Definition at line 64 of file params.h.

Constructor & Destructor Documentation

◆ Params()

QuasarAppUtils::Params::Params ( )
delete
Here is the call graph for this function:

Member Function Documentation

◆ availableArguments()

OptionsDataList Params::availableArguments ( )
static

availableArguments This method return list of the available arguments of QuasarAppLibrary

Returns
list of the available arguments

Definition at line 136 of file params.cpp.

Here is the caller graph for this function:

◆ clearParsedData()

void Params::clearParsedData ( )
static

clearParsedData This method clear all parsed data.

Definition at line 122 of file params.cpp.

◆ getArg()

QString Params::getArg ( const QString & key,
const QString & def = {} )
static

getArg return string value of a key if key is exits else return a def value. If a def value not defined returns empty string.

Parameters
keyThis is key of a console argument.
defThis is Default value. If key not exits This function will return a default value.
Returns
a string value of argument.

Definition at line 348 of file params.cpp.

Here is the caller graph for this function:

◆ getCurrentExecutable()

QString Params::getCurrentExecutable ( )
static

getCurrentExecutable This method return path to the current executable.

Returns
path to current executable.

Definition at line 128 of file params.cpp.

Here is the call graph for this function:

◆ getCurrentExecutableDir()

QString Params::getCurrentExecutableDir ( )
static

getCurrentExecutableDir This method return a path to a folder with the current executable.

Returns
path of the folder with current executable.

Definition at line 132 of file params.cpp.

Here is the caller graph for this function:

◆ getHelp()

const Help::Section & Params::getHelp ( )
static

getHelp This method return options help page.

Note
Before using of this method invoke the parseParams method. This is needed for generate the help message.
Returns
help of available options.

Definition at line 114 of file params.cpp.

◆ getHelpOfInputOptions()

Help::Section Params::getHelpOfInputOptions ( )
static

getHelpOfInputOptions This method return help abut input options only. Except help and h options.

Returns
help abut input options only. Except help and h options.

Definition at line 100 of file params.cpp.

Here is the caller graph for this function:

◆ getUserParamsMap()

const QMap< QString, QString > & Params::getUserParamsMap ( )
static

getUserParamsMap This method return const reference to the parsed arguments map.

Returns
A map object with parsed arguments.

Definition at line 118 of file params.cpp.

◆ getVerboseLvl()

VerboseLvl Params::getVerboseLvl ( )
static

getVerboseLvl This method return the verbose log level.

Returns
verbose log lvl.

Definition at line 71 of file params.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isDebug()

bool Params::isDebug ( )
static

isDebug This method return true if the application verbose level >= VerboseLvl::Debug.

Returns
true if a verbose level >= VerboseLvl::Debug

Definition at line 75 of file params.cpp.

Here is the call graph for this function:

◆ isDebugBuild()

bool Params::isDebugBuild ( )
static

isDebugBuild This method return true if the library buildet in debug mode.

Returns
true if this library buildet in debug mode.
Deprecated
Use Qt MACROSSSES

Definition at line 79 of file params.cpp.

◆ isEndable()

bool Params::isEndable ( const QString & key)
static

isEndable This method check if enable a key argument.

Parameters
keyThis is name of the validate arguments
Returns
true if argument enabled.

Definition at line 35 of file params.cpp.

Here is the caller graph for this function:

◆ log()

void Params::log ( const QString & log,
VerboseLvl vLvl = VerboseLvl::Debug )
static

log This method print log text on console.

Parameters
logThis is printed text message.
vLvlThis is verbose level of message, for get more information see the QuasarAppUtils::VerboseLvl enum.
Note
All messages will be printed according to the current verbose setting.
The verbose level sets by verbose option on console.
Deprecated
Use QALogger and qt debug functions(qDebug, qInfo, qError...)

Definition at line 39 of file params.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseParams() [1/3]

bool Params::parseParams ( const int argc,
const char * argv[],
const OptionsDataList & options = {} )
static

parseParams Parse input data of started application.

Parameters
argcCount of arguments.
argvArray of arguments.
optionsThis is list of the available options for parse. See the OptionData class for more information. If you skip this argument then QuasarAppLib will not check input options.
Returns
true if all arguments read successful else false.

Definition at line 193 of file params.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseParams() [2/3]

bool Params::parseParams ( const QStringList & paramsArray,
const OptionsDataList & options = {} )
static

parseParams Parse input data of started application.

Parameters
paramsArrayArguments.
optionsThis is list of the available options for parse. See the OptionData class for more information. If you skip this argument then QuasarAppLib will not check input options.
Returns
true if all arguments read successful else false.

Definition at line 207 of file params.cpp.

Here is the call graph for this function:

◆ parseParams() [3/3]

bool Params::parseParams ( int argc,
char * argv[],
const OptionsDataList & options = {} )
static

parseParams Parse input data of started application.

Parameters
argcCount of arguments.
argvArray of arguments.
optionsThis is list of the available options for parse. See the OptionData class for more information. If you skip this argument then QuasarAppLib will not check input options.
Returns
true if all arguments read successful else false.

Definition at line 203 of file params.cpp.

Here is the call graph for this function:

◆ setArg()

void Params::setArg ( const QString & key,
const QString & val )
static

setArg sets a new value of a key.

Parameters
keyThis is a name of sets option.
valThis is a new value of the key.

Definition at line 352 of file params.cpp.

◆ setEnable()

void Params::setEnable ( const QString & key,
bool enable )
static

setEnable This method sets boolean value of key.

Parameters
keyThis is name of the console option.
enableNew value of key.
Note
For check is enable key argument use the Params::isEndable method.

Definition at line 356 of file params.cpp.

◆ showHelp()

void Params::showHelp ( )
static

showHelp This method shows all help message.

Definition at line 87 of file params.cpp.

Here is the call graph for this function:

◆ showHelpForInputOptions()

void Params::showHelpForInputOptions ( )
static

showHelpForInputOptions This method show help for each input option.

Note
Before using of this method invoke the parseParams method. This is needed for generate the help message.

Example:

myTool help option1 -option2 arguments

Definition at line 96 of file params.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

int Params::size ( )
static

size This method return count of the all input arguments.

Returns
size of all params array.

Definition at line 154 of file params.cpp.

Here is the caller graph for this function:

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