Torc  0.1
Public Types | Public Member Functions | Static Public Member Functions | List of all members
TorcCommandLine Class Reference

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...
 

Detailed Description

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.

Member Enumeration Documentation

Enumerator
None 
Help 
Version 
LogLevel 
LogType 
Database 
LogFile 
XSDTest 
ConfDir 
ShareDir 
TransDir 

Definition at line 20 of file torccommandline.h.

Constructor & Destructor Documentation

TorcCommandLine::TorcCommandLine ( TorcCommandLine::Options  Flags)
explicit

Definition at line 94 of file torccommandline.cpp.

TorcCommandLine::~TorcCommandLine ( )
default

Member Function Documentation

void TorcCommandLine::Add ( const QString &  Keys,
const QVariant &  Default,
const QString &  HelpText,
bool  ExitImmediately 
)

Implement custom command line options.

Parameters
KeysA comma separated list of synonymous command line options (e.g. "h,help").
DefaultThe default value AND type for an option (e.g. QString("info") or (bool)true).
HelpTextBrief help text for the option.
ExitImmediatelyTell 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.

Parameters
argcAs passed to the main application at startup.
argvAs passed to the main application at startup.
ExitWill 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.

Note
In the case of options that require no value (e.g. –help), QVariant((bool)true) is returned if the option was detected.

Definition at line 346 of file torccommandline.cpp.

bool TorcCommandLine::RegisterEnvironmentVariable ( const QString &  Var,
const QString &  Description 
)
static

Register an environment variable for display via the help option.

Definition at line 358 of file torccommandline.cpp.


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