ParamKit
A small library helping to parse commandline parameters (for Windows).
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
paramkit::Param Class Referenceabstract

The base class of a parameter. More...

#include <param.h>

Inheritance diagram for paramkit::Param:
Inheritance graph
[legend]

Public Member Functions

 Param (const std::string &_argStr, bool _isRequired)
 A constructor of a parameter. More...
 
 Param (const std::string &_argStr, const std::string &_typeDescStr, bool _isRequired)
 A constructor of a parameter. More...
 
virtual std::string valToString () const =0
 Returns the string representation of the parameter's value. More...
 
virtual std::string type () const =0
 Returns the string representation of the parameter's type. More...
 
virtual bool parse (const char *arg)=0
 Parses the parameter from the given string. More...
 
virtual bool parse (const wchar_t *arg)
 Parses the parameter from the given wide string. More...
 
void setActive (bool _active)
 
virtual bool isActive () const
 Returns true if the parameter is active, false otherwise. More...
 
virtual bool isSet () const =0
 Returns true if the parameter is filled, false otherwise. More...
 
virtual std::string info (bool isExtended) const
 
void printInColor (int color)
 Prints the parameter using the given color. Appends the parameter switch to the name. More...
 

Protected Member Functions

void printDesc (bool isExtended=true) const
 Prints a formatted description of the parameter, including its unique name, type, and the info. More...
 
virtual bool isNameSimilar (const std::string &filter)
 Checks if the param name is similar to the given filter. More...
 
virtual bool isKeywordInType (const std::string &keyword)
 Checks if the parameter type contains the keyword. More...
 
virtual bool isKeywordInDescription (const std::string &keyword)
 Checks if the description contains the keyword. More...
 
virtual std::string extendedInfo () const
 Extended information. More...
 

Protected Attributes

std::string argStr
 a unique name of the parameter More...
 
std::string typeDescStr
 a description of the type of the parameter: what type of values are allowed More...
 
std::string m_info
 a basic information about the the parameter's purpose More...
 
std::string m_extInfo
 an extended information about the the parameter's purpose More...
 
bool isRequired
 a flag indicating if this parameter is required More...
 
bool requiredArg
 a flag indicating if this parameter needs to be followed by a value More...
 
bool active
 a flag indicating if this parameter is available More...
 

Friends

class Params
 
class ParamCompare
 
class ParamGroup
 

Detailed Description

The base class of a parameter.

Definition at line 30 of file param.h.

Constructor & Destructor Documentation

◆ Param() [1/2]

paramkit::Param::Param ( const std::string &  _argStr,
bool  _isRequired 
)
inline

A constructor of a parameter.

Parameters
_argStr: the name of the parameter
_isRequired: the flag if this is a required parameter (if false, the parameter is optional)

Definition at line 38 of file param.h.

◆ Param() [2/2]

paramkit::Param::Param ( const std::string &  _argStr,
const std::string &  _typeDescStr,
bool  _isRequired 
)
inline

A constructor of a parameter.

Parameters
_argStr: the name of the parameter
_typeDescStr: a description of the parameter type
_isRequired: the flag if this is a required parameter (if false, the parameter is optional)

Definition at line 52 of file param.h.

Member Function Documentation

◆ extendedInfo()

virtual std::string paramkit::Param::extendedInfo ( ) const
inlineprotectedvirtual

Extended information.

Reimplemented in paramkit::EnumParam.

Definition at line 155 of file param.h.

◆ info()

virtual std::string paramkit::Param::info ( bool  isExtended) const
inlinevirtual

Definition at line 92 of file param.h.

Here is the call graph for this function:

◆ isActive()

virtual bool paramkit::Param::isActive ( ) const
inlinevirtual

Returns true if the parameter is active, false otherwise.

Definition at line 84 of file param.h.

◆ isKeywordInDescription()

virtual bool paramkit::Param::isKeywordInDescription ( const std::string &  keyword)
inlineprotectedvirtual

Checks if the description contains the keyword.

Reimplemented in paramkit::EnumParam.

Definition at line 146 of file param.h.

Here is the call graph for this function:

◆ isKeywordInType()

virtual bool paramkit::Param::isKeywordInType ( const std::string &  keyword)
inlineprotectedvirtual

Checks if the parameter type contains the keyword.

Reimplemented in paramkit::EnumParam.

Definition at line 137 of file param.h.

Here is the call graph for this function:

◆ isNameSimilar()

virtual bool paramkit::Param::isNameSimilar ( const std::string &  filter)
inlineprotectedvirtual

Checks if the param name is similar to the given filter.

Definition at line 130 of file param.h.

Here is the call graph for this function:

◆ isSet()

virtual bool paramkit::Param::isSet ( ) const
pure virtual

Returns true if the parameter is filled, false otherwise.

Implemented in paramkit::EnumParam, paramkit::BoolParam, paramkit::WStringParam, paramkit::StringParam, and paramkit::IntParam.

◆ parse() [1/2]

virtual bool paramkit::Param::parse ( const char *  arg)
pure virtual

◆ parse() [2/2]

virtual bool paramkit::Param::parse ( const wchar_t *  arg)
inlinevirtual

Parses the parameter from the given wide string.

Reimplemented in paramkit::WStringParam.

Definition at line 71 of file param.h.

Here is the call graph for this function:

◆ printDesc()

void paramkit::Param::printDesc ( bool  isExtended = true) const
inlineprotected

Prints a formatted description of the parameter, including its unique name, type, and the info.

Definition at line 114 of file param.h.

Here is the call graph for this function:

◆ printInColor()

void paramkit::Param::printInColor ( int  color)
inline

Prints the parameter using the given color. Appends the parameter switch to the name.

Definition at line 106 of file param.h.

Here is the call graph for this function:

◆ setActive()

void paramkit::Param::setActive ( bool  _active)
inline

Definition at line 78 of file param.h.

◆ type()

virtual std::string paramkit::Param::type ( ) const
pure virtual

◆ valToString()

virtual std::string paramkit::Param::valToString ( ) const
pure virtual

Returns the string representation of the parameter's value.

Implemented in paramkit::EnumParam, paramkit::BoolParam, paramkit::WStringParam, paramkit::StringParam, and paramkit::IntParam.

Friends And Related Function Documentation

◆ ParamCompare

friend class ParamCompare
friend

Definition at line 171 of file param.h.

◆ ParamGroup

friend class ParamGroup
friend

Definition at line 172 of file param.h.

◆ Params

friend class Params
friend

Definition at line 170 of file param.h.

Member Data Documentation

◆ active

bool paramkit::Param::active
protected

a flag indicating if this parameter is available

Definition at line 168 of file param.h.

◆ argStr

std::string paramkit::Param::argStr
protected

a unique name of the parameter

Definition at line 160 of file param.h.

◆ isRequired

bool paramkit::Param::isRequired
protected

a flag indicating if this parameter is required

Definition at line 166 of file param.h.

◆ m_extInfo

std::string paramkit::Param::m_extInfo
protected

an extended information about the the parameter's purpose

Definition at line 164 of file param.h.

◆ m_info

std::string paramkit::Param::m_info
protected

a basic information about the the parameter's purpose

Definition at line 163 of file param.h.

◆ requiredArg

bool paramkit::Param::requiredArg
protected

a flag indicating if this parameter needs to be followed by a value

Definition at line 167 of file param.h.

◆ typeDescStr

std::string paramkit::Param::typeDescStr
protected

a description of the type of the parameter: what type of values are allowed

Definition at line 162 of file param.h.


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