Torc
0.1
|
Torc command line handler. More...
#include <torccommandline.h>
Public Types | |
enum | Option { None = (0 << 0), Help = (1 << 0), Version = (1 << 1), LogLevel = (1 << 2), LogType = (1 << 3), Database = (1 << 4), LogFile = (1 << 5), XSDTest = (1 << 6), ConfDir = (1 << 7), ShareDir = (1 << 8), TransDir = (1 << 9) } |
Public Member Functions | |
TorcCommandLine (TorcCommandLine::Options Flags) | |
~TorcCommandLine ()=default | |
int | Evaluate (int argc, const char *const *argv, bool &Exit) |
Evaluate the command line options. More... | |
void | Add (const QString &Keys, const QVariant &Default, const QString &HelpText, bool ExitImmediately) |
Implement custom command line options. More... | |
QVariant | GetValue (const QString &Key) |
Return the value associated with Key or an invalid QVariant if the option is not present. More... | |
Static Public Member Functions | |
static bool | RegisterEnvironmentVariable (const QString &Var, const QString &Description) |
Register an environment variable for display via the help option. More... | |
Torc command line handler.
TorcCommandLine will always add handling for help, log, verbose and version handling.
Additional pre-defined handlers can be implemented by passing additional TorcCommandLine::Options flags to the constructor.
Custom command line options can be implemented by calling Add and retrieving the expected value via GetValue.
Definition at line 14 of file torccommandline.h.
Enumerator | |
---|---|
None | |
Help | |
Version | |
LogLevel | |
LogType | |
Database | |
LogFile | |
XSDTest | |
ConfDir | |
ShareDir | |
TransDir |
Definition at line 20 of file torccommandline.h.
|
explicit |
Definition at line 94 of file torccommandline.cpp.
|
default |
void TorcCommandLine::Add | ( | const QString & | Keys, |
const QVariant & | Default, | ||
const QString & | HelpText, | ||
bool | ExitImmediately | ||
) |
Implement custom command line options.
Keys | A comma separated list of synonymous command line options (e.g. "h,help"). |
Default | The default value AND type for an option (e.g. QString("info") or (bool)true). |
HelpText | Brief help text for the option. |
ExitImmediately | Tell the application to exit immediately after processing the command line. |
Definition at line 134 of file torccommandline.cpp.
int TorcCommandLine::Evaluate | ( | int | argc, |
const char *const * | argv, | ||
bool & | Exit | ||
) |
Evaluate the command line options.
argc | As passed to the main application at startup. |
argv | As passed to the main application at startup. |
Exit | Will be set to true if the application should exit after command line processing. |
Definition at line 186 of file torccommandline.cpp.
QVariant TorcCommandLine::GetValue | ( | const QString & | Key | ) |
Return the value associated with Key or an invalid QVariant if the option is not present.
Definition at line 346 of file torccommandline.cpp.
|
static |
Register an environment variable for display via the help option.
Definition at line 358 of file torccommandline.cpp.