![]() |
Leonetienne/Hazelnupp
Simple, easy to use, command line parameter interface
|
The main class to interface with. More...
#include <CmdArgsInterface.h>
Public Member Functions | |
CmdArgsInterface () | |
CmdArgsInterface (const int argc, const char *const *argv) | |
~CmdArgsInterface () | |
void | Parse (const int argc, const char *const *argv) |
Will parse command line arguments. More... | |
const std::string & | GetExecutableName () const |
Will return argv[0], the name of the executable. More... | |
const Value & | operator[] (const std::string &key) const |
Will return the value given a key. More... | |
bool | HasParam (const std::string &key) const |
Will check wether a parameter exists given a key, or not. More... | |
void | RegisterAbbreviation (const std::string &abbrev, const std::string &target) |
Will register an abbreviation (like -f for –force) More... | |
const std::string & | GetAbbreviation (const std::string &abbrev) const |
Will return the long form of an abbreviation (like –force for -f) Returns "" if no match is found. More... | |
bool | HasAbbreviation (const std::string &abbrev) const |
Will check wether or not an abbreviation is registered. More... | |
void | ClearAbbreviation (const std::string &abbrevation) |
Will delete the abbreviation for a given parameter. More... | |
void | ClearAbbreviations () |
Will delete all abbreviations. More... | |
void | RegisterConstraint (const std::string &key, const ParamConstraint &constraint) |
Will register a constraint for a parameter. More... | |
ParamConstraint | GetConstraint (const std::string ¶meter) const |
Will return the constraint information for a specific parameter. More... | |
void | ClearConstraint (const std::string ¶meter) |
Will the constraint of a specific parameter. More... | |
void | ClearConstraints () |
Will delete all constraints. More... | |
void | SetCrashOnFail (bool crashOnFail) |
Sets whether to crash the application, and print to stderr, when an exception is raised whilst parsing, or not. More... | |
bool | GetCrashOnFail () const |
Gets whether the application crashes on an exception whilst parsing, and prints to stderr. More... | |
void | SetCatchHelp (bool catchHelp) |
Sets whether the CmdArgsInterface should automatically catch the –help parameter, print the parameter documentation to stdout, and exit or not. More... | |
bool | GetCatchHelp () const |
Retruns whether the CmdArgsInterface should automatically catch the –help parameter, print the parameter documentation to stdout, and exit or not. More... | |
void | SetBriefDescription (const std::string &description) |
Sets a brief description of the application to be automatically added to the documentation. More... | |
const std::string & | GetBriefDescription () |
Returns the brief description of the application to be automatically added to the documentation. More... | |
void | RegisterDescription (const std::string ¶meter, const std::string &description) |
Willl register a short description for a parameter. More... | |
const std::string & | GetDescription (const std::string ¶meter) const |
Will return a short description for a parameter, if it exists. More... | |
bool | HasDescription (const std::string ¶meter) const |
Returns whether or not a given parameter has a registered description. More... | |
void | ClearDescription (const std::string ¶meter) |
Will delete the description of a parameter if it exists. More... | |
void | ClearDescriptions () |
Will delete all parameter descriptions. More... | |
std::string | GenerateDocumentation () const |
Will generate a text-based documentation suited to show the user, for example on –help. More... | |
The main class to interface with.
Definition at line 13 of file CmdArgsInterface.h.
CmdArgsInterface::CmdArgsInterface | ( | ) |
Definition at line 15 of file CmdArgsInterface.cpp.
CmdArgsInterface::CmdArgsInterface | ( | const int | argc, |
const char *const * | argv | ||
) |
Definition at line 20 of file CmdArgsInterface.cpp.
CmdArgsInterface::~CmdArgsInterface | ( | ) |
Definition at line 26 of file CmdArgsInterface.cpp.
void CmdArgsInterface::ClearAbbreviation | ( | const std::string & | abbrevation | ) |
Will delete the abbreviation for a given parameter.
IMPORTANT: This parameter is the abbreviation! Not the long form!
Definition at line 632 of file CmdArgsInterface.cpp.
void CmdArgsInterface::ClearAbbreviations | ( | ) |
Will delete all abbreviations.
Definition at line 638 of file CmdArgsInterface.cpp.
void CmdArgsInterface::ClearConstraint | ( | const std::string & | parameter | ) |
Will the constraint of a specific parameter.
Definition at line 593 of file CmdArgsInterface.cpp.
void CmdArgsInterface::ClearConstraints | ( | ) |
Will delete all constraints.
Definition at line 651 of file CmdArgsInterface.cpp.
void CmdArgsInterface::ClearDescription | ( | const std::string & | parameter | ) |
Will delete the description of a parameter if it exists.
Definition at line 412 of file CmdArgsInterface.cpp.
void Hazelnp::CmdArgsInterface::ClearDescriptions | ( | ) |
Will delete all parameter descriptions.
Definition at line 419 of file CmdArgsInterface.cpp.
std::string CmdArgsInterface::GenerateDocumentation | ( | ) | const |
Will generate a text-based documentation suited to show the user, for example on –help.
Definition at line 425 of file CmdArgsInterface.cpp.
const std::string & CmdArgsInterface::GetAbbreviation | ( | const std::string & | abbrev | ) | const |
Will return the long form of an abbreviation (like –force for -f)
Returns "" if no match is found.
Definition at line 619 of file CmdArgsInterface.cpp.
const std::string & CmdArgsInterface::GetBriefDescription | ( | ) |
Returns the brief description of the application to be automatically added to the documentation.
Definition at line 385 of file CmdArgsInterface.cpp.
bool CmdArgsInterface::GetCatchHelp | ( | ) | const |
Retruns whether the CmdArgsInterface should automatically catch the –help parameter, print the parameter documentation to stdout, and exit or not.
Definition at line 374 of file CmdArgsInterface.cpp.
ParamConstraint CmdArgsInterface::GetConstraint | ( | const std::string & | parameter | ) | const |
Will return the constraint information for a specific parameter.
Definition at line 588 of file CmdArgsInterface.cpp.
bool CmdArgsInterface::GetCrashOnFail | ( | ) | const |
Gets whether the application crashes on an exception whilst parsing, and prints to stderr.
Definition at line 363 of file CmdArgsInterface.cpp.
const std::string & Hazelnp::CmdArgsInterface::GetDescription | ( | const std::string & | parameter | ) | const |
Will return a short description for a parameter, if it exists.
Empty string if it does not exist.
Definition at line 396 of file CmdArgsInterface.cpp.
const std::string & CmdArgsInterface::GetExecutableName | ( | ) | const |
Will return argv[0], the name of the executable.
Definition at line 599 of file CmdArgsInterface.cpp.
bool CmdArgsInterface::HasAbbreviation | ( | const std::string & | abbrev | ) | const |
Will check wether or not an abbreviation is registered.
Definition at line 627 of file CmdArgsInterface.cpp.
bool CmdArgsInterface::HasDescription | ( | const std::string & | parameter | ) | const |
Returns whether or not a given parameter has a registered description.
Definition at line 407 of file CmdArgsInterface.cpp.
bool CmdArgsInterface::HasParam | ( | const std::string & | key | ) | const |
Will check wether a parameter exists given a key, or not.
Definition at line 199 of file CmdArgsInterface.cpp.
const Value & CmdArgsInterface::operator[] | ( | const std::string & | key | ) | const |
void CmdArgsInterface::Parse | ( | const int | argc, |
const char *const * | argv | ||
) |
void CmdArgsInterface::RegisterAbbreviation | ( | const std::string & | abbrev, |
const std::string & | target | ||
) |
Will register an abbreviation (like -f for –force)
Definition at line 613 of file CmdArgsInterface.cpp.
void CmdArgsInterface::RegisterConstraint | ( | const std::string & | key, |
const ParamConstraint & | constraint | ||
) |
Will register a constraint for a parameter.
IMPORTANT: Any parameter can only have ONE constraint. Applying a new one will overwrite the old one! Construct the ParamConstraint struct yourself to combine Require, TypeSafety and Incompatibilities! You can also use the ParamConstraint constructor!
Definition at line 644 of file CmdArgsInterface.cpp.
void Hazelnp::CmdArgsInterface::RegisterDescription | ( | const std::string & | parameter, |
const std::string & | description | ||
) |
Willl register a short description for a parameter.
Will overwrite existing descriptions for that parameter.
Definition at line 390 of file CmdArgsInterface.cpp.
void CmdArgsInterface::SetBriefDescription | ( | const std::string & | description | ) |
Sets a brief description of the application to be automatically added to the documentation.
Definition at line 379 of file CmdArgsInterface.cpp.
void CmdArgsInterface::SetCatchHelp | ( | bool | catchHelp | ) |
Sets whether the CmdArgsInterface should automatically catch the –help parameter, print the parameter documentation to stdout, and exit or not.
Definition at line 368 of file CmdArgsInterface.cpp.
void CmdArgsInterface::SetCrashOnFail | ( | bool | crashOnFail | ) |
Sets whether to crash the application, and print to stderr, when an exception is raised whilst parsing, or not.
Definition at line 657 of file CmdArgsInterface.cpp.