![]() |
Leonetienne/Hazelnupp
Simple, easy to use, command line parameter interface
|
The main class to interface with. More...
#include <Hazelnupp.h>
Public Member Functions | |
Hazelnupp () | |
Hazelnupp (const int argc, const char *const *argv) | |
~Hazelnupp () | |
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 Hazelnupp should automatically catch the –help parameter, print the parameter documentation to stdout, and exit or not. More... | |
bool | GetCatchHelp () const |
Retruns whether the Hazelnupp 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 11 of file Hazelnupp.h.
Hazelnupp::Hazelnupp | ( | ) |
Definition at line 15 of file Hazelnupp.cpp.
Hazelnupp::Hazelnupp | ( | const int | argc, |
const char *const * | argv | ||
) |
Definition at line 20 of file Hazelnupp.cpp.
Hazelnupp::~Hazelnupp | ( | ) |
Definition at line 26 of file Hazelnupp.cpp.
void Hazelnupp::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 546 of file Hazelnupp.cpp.
void Hazelnupp::ClearAbbreviations | ( | ) |
Will delete all abbreviations.
Definition at line 552 of file Hazelnupp.cpp.
void Hazelnupp::ClearConstraint | ( | const std::string & | parameter | ) |
Will the constraint of a specific parameter.
Definition at line 507 of file Hazelnupp.cpp.
void Hazelnupp::ClearConstraints | ( | ) |
Will delete all constraints.
Definition at line 565 of file Hazelnupp.cpp.
void Hazelnupp::ClearDescription | ( | const std::string & | parameter | ) |
Will delete the description of a parameter if it exists.
Definition at line 346 of file Hazelnupp.cpp.
void Hazelnp::Hazelnupp::ClearDescriptions | ( | ) |
Will delete all parameter descriptions.
Definition at line 353 of file Hazelnupp.cpp.
std::string Hazelnupp::GenerateDocumentation | ( | ) | const |
Will generate a text-based documentation suited to show the user, for example on –help.
Definition at line 359 of file Hazelnupp.cpp.
const std::string & Hazelnupp::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 533 of file Hazelnupp.cpp.
const std::string & Hazelnupp::GetBriefDescription | ( | ) |
Returns the brief description of the application to be automatically added to the documentation.
Definition at line 319 of file Hazelnupp.cpp.
bool Hazelnupp::GetCatchHelp | ( | ) | const |
Retruns whether the Hazelnupp should automatically catch the –help parameter, print the parameter documentation to stdout, and exit or not.
Definition at line 308 of file Hazelnupp.cpp.
ParamConstraint Hazelnupp::GetConstraint | ( | const std::string & | parameter | ) | const |
Will return the constraint information for a specific parameter.
Definition at line 502 of file Hazelnupp.cpp.
bool Hazelnupp::GetCrashOnFail | ( | ) | const |
Gets whether the application crashes on an exception whilst parsing, and prints to stderr.
Definition at line 297 of file Hazelnupp.cpp.
const std::string & Hazelnp::Hazelnupp::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 330 of file Hazelnupp.cpp.
const std::string & Hazelnupp::GetExecutableName | ( | ) | const |
Will return argv[0], the name of the executable.
Definition at line 513 of file Hazelnupp.cpp.
bool Hazelnupp::HasAbbreviation | ( | const std::string & | abbrev | ) | const |
Will check wether or not an abbreviation is registered.
Definition at line 541 of file Hazelnupp.cpp.
bool Hazelnupp::HasDescription | ( | const std::string & | parameter | ) | const |
Returns whether or not a given parameter has a registered description.
Definition at line 341 of file Hazelnupp.cpp.
bool Hazelnupp::HasParam | ( | const std::string & | key | ) | const |
Will check wether a parameter exists given a key, or not.
Definition at line 165 of file Hazelnupp.cpp.
const Value & Hazelnupp::operator[] | ( | const std::string & | key | ) | const |
void Hazelnupp::Parse | ( | const int | argc, |
const char *const * | argv | ||
) |
Will parse command line arguments.
Definition at line 36 of file Hazelnupp.cpp.
void Hazelnupp::RegisterAbbreviation | ( | const std::string & | abbrev, |
const std::string & | target | ||
) |
Will register an abbreviation (like -f for –force)
Definition at line 527 of file Hazelnupp.cpp.
void Hazelnupp::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 and TypeSafety! You can also use the ParamConstraint constructor!
Definition at line 558 of file Hazelnupp.cpp.
void Hazelnp::Hazelnupp::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 324 of file Hazelnupp.cpp.
void Hazelnupp::SetBriefDescription | ( | const std::string & | description | ) |
Sets a brief description of the application to be automatically added to the documentation.
Definition at line 313 of file Hazelnupp.cpp.
void Hazelnupp::SetCatchHelp | ( | bool | catchHelp | ) |
Sets whether the Hazelnupp should automatically catch the –help parameter, print the parameter documentation to stdout, and exit or not.
Definition at line 302 of file Hazelnupp.cpp.
void Hazelnupp::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 571 of file Hazelnupp.cpp.