Langmuir
Simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LangmuirCore::CommandLineParser Class Reference

A class to parse command line arguments. More...

#include <clparser.h>

Public Member Functions

 CommandLineParser (QObject *parent=0)
 create the CommandLineParser More...
 
void setDescription (const QString &desc)
 set the program description More...
 
void addBool (QString flag, QString dest, QString help)
 add a flag that has no argument More...
 
void addPositional (QString dest, QString help)
 add an argument that has no flag More...
 
void add (QString flag, QString dest, QString help)
 add a flag that has an argument More...
 
template<typename T >
get (const QString &dest, T default_value)
 get value by key and convert to type More...
 
void parse (QStringList &args)
 parse the command line arguments More...
 
QString help ()
 get the help string More...
 

Protected Member Functions

template<typename T >
convert (const QString &value)
 convert value to type More...
 

Protected Attributes

QMap< QString, bool > m_isBool
 map dest->boolean More...
 
QMap< QString, int > m_isPositional
 map dest->boolean More...
 
QMap< QString, QString > m_flags
 map dest->flag More...
 
QMap< QString, QString > m_helps
 map dest->help More...
 
QMap< QString, QString > m_values
 map dest->value More...
 
QString m_description
 description string More...
 
QStringList m_args
 list of remaining command line arguments More...
 
unsigned int m_numPositional
 total number of positional arguments More...
 
unsigned int m_numArguments
 total number of arguments More...
 

Detailed Description

A class to parse command line arguments.

Constructor & Destructor Documentation

LangmuirCore::CommandLineParser::CommandLineParser ( QObject *  parent = 0)
explicit

create the CommandLineParser

Parameters
parentQObject this belongs to

Member Function Documentation

void LangmuirCore::CommandLineParser::add ( QString  flag,
QString  dest,
QString  help 
)

add a flag that has an argument

Parameters
flagcommand line flag
destinternal key
helphelp message
void LangmuirCore::CommandLineParser::addBool ( QString  flag,
QString  dest,
QString  help 
)

add a flag that has no argument

Parameters
flagcommand line flag
destinternal key
helphelp message
void LangmuirCore::CommandLineParser::addPositional ( QString  dest,
QString  help 
)

add an argument that has no flag

Parameters
destinternal key
helphelp message
template<typename T >
T LangmuirCore::CommandLineParser::convert ( const QString &  value)
protected

convert value to type

Parameters
valuevalue as string
template<typename T >
T LangmuirCore::CommandLineParser::get ( const QString &  dest,
default_value 
)

get value by key and convert to type

Parameters
destinternal key
default_valuedefault value if key not present
QString LangmuirCore::CommandLineParser::help ( )

get the help string

void LangmuirCore::CommandLineParser::parse ( QStringList &  args)

parse the command line arguments

Parameters
argsarguments as a list of strings
void LangmuirCore::CommandLineParser::setDescription ( const QString &  desc)

set the program description

Parameters
descdescription string

Member Data Documentation

QStringList LangmuirCore::CommandLineParser::m_args
protected

list of remaining command line arguments

QString LangmuirCore::CommandLineParser::m_description
protected

description string

QMap<QString,QString> LangmuirCore::CommandLineParser::m_flags
protected

map dest->flag

QMap<QString,QString> LangmuirCore::CommandLineParser::m_helps
protected

map dest->help

QMap<QString,bool> LangmuirCore::CommandLineParser::m_isBool
protected

map dest->boolean

QMap<QString,int> LangmuirCore::CommandLineParser::m_isPositional
protected

map dest->boolean

unsigned int LangmuirCore::CommandLineParser::m_numArguments
protected

total number of arguments

unsigned int LangmuirCore::CommandLineParser::m_numPositional
protected

total number of positional arguments

QMap<QString,QString> LangmuirCore::CommandLineParser::m_values
protected

map dest->value


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