ParamKit
A small library helping to parse commandline parameters (for Windows).
|
The class responsible for storing and parsing parameters (objects of the type Param), possibly divided into groups (ParamGroup) More...
#include <params.h>
Public Member Functions | |
Params (const std::string &version="") | |
virtual | ~Params () |
virtual void | printBanner () |
virtual void | printVersionInfo () |
bool | addGroup (ParamGroup *group) |
ParamGroup * | getParamGroup (const std::string &str) |
bool | addParamToGroup (const std::string paramName, const std::string groupName) |
void | addParam (Param *param) |
Adds a parameter into the storage. More... | |
bool | setInfo (const std::string ¶mName, const std::string &basic_info, const std::string &extended_info="") |
Sets the information about the parameter, defined by its name. More... | |
void | printInfo (bool hilightMissing=false, const std::string &filter="", bool isExtended=true) |
Prints info about all the parameters. Optionally hilights the required ones that are missing. More... | |
void | printBriefInfo () |
Prints brief info about all the parameters. Wrapper for printInfo. More... | |
bool | setIntValue (const std::string ¶mName, uint64_t val) |
Fills an IntParam defined by its name with the given value. If such parameter does not exist, or is not of the type IntParam, returns false. Otherwise returns true. More... | |
uint64_t | getIntValue (const std::string ¶mName) |
Gets an integer value of the IntParam defined by its name. If such parameter does not exist, or is not of IntParam type, returns PARAM_UNINITIALIZED. More... | |
virtual bool | isSet (const std::string ¶mName) |
Checks if the parameter with the given name is set (filled). More... | |
virtual bool | hasRequiredFilled () |
Checks if all the required parameters are filled. More... | |
void | releaseGroups () |
Deletes all the parameters groups. More... | |
void | releaseParams () |
Deletes all the added parameters. More... | |
template<typename T_CHAR > | |
bool | parse (int argc, T_CHAR *argv[]) |
Parses the parameters. Prints a warning if an undefined parameter was supplied. More... | |
void | print () |
Prints the values of all the parameters that are currently set. More... | |
template<class PARAM_T , typename FIELD_T > | |
bool | copyVal (const std::string ¶mId, FIELD_T &toFill) |
template<class PARAM_T , typename FIELD_T > | |
bool | copyCStr (const std::string ¶mId, FIELD_T &toFill, size_t toFillLen) |
Protected Member Functions | |
virtual size_t | countFilled (bool isRequired) |
size_t | _info (bool isRequired, bool hilightMissing, const std::string &filter, bool isExtended) |
bool | printHelp (const std::string helpArg, bool shouldExpand) |
void | printInfoSection (bool isExtended) |
bool | addParamToGroup (Param *param, ParamGroup *group) |
size_t | countGroups (bool required, bool hilightMissing, const std::string &filter) const |
size_t | countCategory (bool isRequired) |
Returns the number of parameters of particular category: required or optional. More... | |
void | printUnknownParam (const std::string ¶m) |
void | printUnknownArgument (const std::string &str) |
Param * | getParam (const std::string &str) |
Retrieve the parameter by its unique name. Returns nullptr if such parameter does not exist. More... | |
std::string | skipParamPrefix (std::string &str) |
Skip the parameter prefix. Example: "/param", '-param', or "--param" is converted to "param". More... | |
Static Protected Member Functions | |
static bool | isParam (const std::string &str) |
Checks if the string starts from the parameter switch. More... | |
Protected Attributes | |
std::string | versionStr |
std::map< std::string, Param * > | myParams |
BoolParam | paramHelp |
StringParam | paramHelpP |
BoolParam | paramInfoP |
BoolParam | paramVersion |
ParamGroup * | generalGroup |
std::map< Param *, ParamGroup * > | paramToGroup |
std::map< std::string, ParamGroup * > | paramGroups |
const int | hdrColor |
const int | paramColor |
The class responsible for storing and parsing parameters (objects of the type Param), possibly divided into groups (ParamGroup)
|
inline |
|
inlinevirtual |
|
inlineprotected |
|
inline |
|
inline |
|
inline |
|
inlineprotected |
|
inline |
|
inline |
|
inlineprotected |
|
inlineprotectedvirtual |
|
inlineprotected |
|
inline |
|
inlineprotected |
|
inline |
|
inlinevirtual |
|
inlinestaticprotected |
|
inlinevirtual |
|
inline |
|
inline |
|
inlinevirtual |
|
inline |
|
inlineprotected |
|
inline |
Prints info about all the parameters. Optionally hilights the required ones that are missing.
hilightMissing | : if set, the required parameters that were not filled are printed in red. |
filter | : display only parameters similar to the given string |
isExtended | : display extended info about each parameter |
Definition at line 126 of file params.h.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlinevirtual |
|
inline |
|
inline |
|
inline |
Sets the information about the parameter, defined by its name.
paramName | : a unique name of the parameter |
basic_info | : basic description of the parameter |
extended_info | : additional description of the parameter |
Definition at line 110 of file params.h.
|
inline |
Fills an IntParam defined by its name with the given value. If such parameter does not exist, or is not of the type IntParam, returns false. Otherwise returns true.
paramName | : a name of the parameter (of the type IntParam) that is to be filled |
val | : the value to be set into the parameter |
Definition at line 148 of file params.h.
|
inlineprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |