LibEngsas
Public Member Functions | Private Attributes | List of all members
ECmdLineOption Class Reference

Represents one command line argument or option. More...

#include <ecmdlineoption.h>

Public Member Functions

 ECmdLineOption (const QByteArray &name, const QByteArray &alias=QByteArray(), const QString &description=QString(), const QByteArray &defaultValue=QByteArray())
 
void setName (const QByteArray &name)
 Sets the name of the option. More...
 
QByteArray name () const
 
bool requiresArgument () const
 Returns true, if the option requires an argument. More...
 
bool isArgument () const
 Returns true, if the option is an argument. More...
 
bool isOptional () const
 Returns true, if the option or argument is optional. More...
 
void setAlias (const QByteArray &alias)
 The alias of this option. More...
 
QByteArray alias () const
 
void setDescription (const QString &description=QString())
 The description of this option, which is used at the help. More...
 
QString description () const
 
void setDefaultValue (const QByteArray &defaultValue=QByteArray())
 The default vaule, if no value is given. More...
 
QByteArray defaultValue () const
 
void setIsSet (bool status=true)
 
bool isSet () const
 Is true, if the option is set at the command line. More...
 
void setValue (const QByteArray &value)
 
QByteArray value () const
 Returns the value, which is specified via the command line. More...
 
QString usage () const
 The part at the usage line in help. More...
 
QString helpLine () const
 The help line for this option in help. More...
 
void addToKCmdLineOptions (KCmdLineOptions *option) const
 Adds this option to the given KCmdLineOptions option. More...
 

Private Attributes

QByteArray myName
 
QByteArray myAlias
 
QByteArray myDefaultValue
 
QByteArray myValue
 
QString myDescription
 
bool myIsSet
 
bool myRequiresArgument
 
bool myIsArgument
 
bool myIsOptional
 

Detailed Description

Represents one command line argument or option.

It is used by ECmdLineArgs to handle available options and parse the given arguments.

Todo:
add convenience functions for the use of QStrings instead of QByteArrays

Constructor & Destructor Documentation

ECmdLineOption::ECmdLineOption ( const QByteArray &  name,
const QByteArray &  alias = QByteArray(),
const QString &  description = QString(),
const QByteArray &  defaultValue = QByteArray() 
)

To find out more about the parameters and espacially about name, to add optional options and or arguments, look at setName().

Parameters
namesee setName()
aliassee setAlias()
descriptionsee setDescription()
defaultValuesee setDefaultValue()

+ Here is the call graph for this function:

Member Function Documentation

void ECmdLineOption::addToKCmdLineOptions ( KCmdLineOptions *  option) const

Adds this option to the given KCmdLineOptions option.

If KDE is not enabled, this function does nothing.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

QByteArray ECmdLineOption::alias ( ) const

+ Here is the caller graph for this function:

QByteArray ECmdLineOption::defaultValue ( ) const

+ Here is the caller graph for this function:

QString ECmdLineOption::description ( ) const

+ Here is the caller graph for this function:

QString ECmdLineOption::helpLine ( ) const

The help line for this option in help.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ECmdLineOption::isArgument ( ) const

Returns true, if the option is an argument.

This is the case, if the name is something like

setName("+option");

+ Here is the caller graph for this function:

bool ECmdLineOption::isOptional ( ) const

Returns true, if the option or argument is optional.

This is the case, if the option name contains [ and ].

+ Here is the caller graph for this function:

bool ECmdLineOption::isSet ( ) const

Is true, if the option is set at the command line.

+ Here is the caller graph for this function:

QByteArray ECmdLineOption::name ( ) const

+ Here is the caller graph for this function:

bool ECmdLineOption::requiresArgument ( ) const

Returns true, if the option requires an argument.

This is the case, if the option name is something like

setName("option <argument>");

+ Here is the caller graph for this function:

void ECmdLineOption::setAlias ( const QByteArray &  alias)

The alias of this option.

E.g. set it to "u" if the option is "user" and should be accessible through "-u".

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ECmdLineOption::setDefaultValue ( const QByteArray &  defaultValue = QByteArray())

The default vaule, if no value is given.

The default default value is an empty QByteArray().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ECmdLineOption::setDescription ( const QString &  description = QString())

The description of this option, which is used at the help.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ECmdLineOption::setIsSet ( bool  status = true)

+ Here is the caller graph for this function:

void ECmdLineOption::setName ( const QByteArray &  name)

Sets the name of the option.

It also analyze the name as following:

  • name <argument> - The option with name "name" requires an argument
  • +name - The option is an required argument
  • [name] - The option is optional (combineable with the ones before)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ECmdLineOption::setValue ( const QByteArray &  value)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

QString ECmdLineOption::usage ( ) const

The part at the usage line in help.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

QByteArray ECmdLineOption::value ( ) const

Returns the value, which is specified via the command line.

Or it returns an the defaultValue() if no value is given.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

QByteArray ECmdLineOption::myAlias
private
QByteArray ECmdLineOption::myDefaultValue
private
QString ECmdLineOption::myDescription
private
bool ECmdLineOption::myIsArgument
private
bool ECmdLineOption::myIsOptional
private
bool ECmdLineOption::myIsSet
private
QByteArray ECmdLineOption::myName
private
bool ECmdLineOption::myRequiresArgument
private
QByteArray ECmdLineOption::myValue
private

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