 |
Leonetienne/Hazelnupp
Simple, easy to use, command line parameter interface
|
Go to the documentation of this file.
4 #include <unordered_map>
20 void Parse(
const int argc,
const char*
const* argv);
29 bool HasParam(
const std::string& key)
const;
88 const std::string&
GetDescription(
const std::string& parameter)
const;
104 void PopulateRawArgs(
const int argc,
const char*
const* argv);
107 void ExpandAbbreviations();
110 std::size_t ParseNextParameter(
const std::size_t parIndex,
Parameter*& out_Par);
113 Value* ParseValue(
const std::vector<std::string>& values,
const ParamConstraint* constraint =
nullptr);
116 void ApplyConstraints();
119 const ParamConstraint* GetConstraintForKey(
const std::string& key)
const;
121 std::string executableName;
122 std::unordered_map<std::string, Parameter*> parameters;
125 std::unordered_map<std::string, std::string> parameterAbreviations;
128 std::unordered_map<std::string, ParamConstraint> parameterConstraints;
131 std::vector<std::string> rawArgs;
135 std::unordered_map<std::string, std::string> parameterDescriptions;
138 std::string briefDescription;
141 bool catchHelp =
true;
144 bool crashOnFail =
true;
bool GetCatchHelp() const
Retruns whether the CmdArgsInterface should automatically catch the –help parameter,...
The main class to interface with.
ParamConstraint GetConstraint(const std::string ¶meter) const
Will return the constraint information for a specific parameter.
void ClearAbbreviations()
Will delete all abbreviations.
void SetCatchHelp(bool catchHelp)
Sets whether the CmdArgsInterface should automatically catch the –help parameter, print the parameter...
bool HasAbbreviation(const std::string &abbrev) const
Will check wether or not an abbreviation is registered.
void RegisterConstraint(const std::string &key, const ParamConstraint &constraint)
Will register a constraint for a parameter.
void ClearConstraint(const std::string ¶meter)
Will the constraint of a specific parameter.
Abstract class for values.
void RegisterAbbreviation(const std::string &abbrev, const std::string &target)
Will register an abbreviation (like -f for –force)
bool HasParam(const std::string &key) const
Will check wether a parameter exists given a key, or not.
void ClearConstraints()
Will delete all constraints.
bool GetCrashOnFail() const
Gets whether the application crashes on an exception whilst parsing, and prints to stderr.
bool HasDescription(const std::string ¶meter) const
Returns whether or not a given parameter has a registered description.
void ClearDescription(const std::string ¶meter)
Will delete the description of a parameter if it exists.
void ClearAbbreviation(const std::string &abbrevation)
Will delete the abbreviation for a given parameter.
void Parse(const int argc, const char *const *argv)
Will parse command line arguments.
void SetBriefDescription(const std::string &description)
Sets a brief description of the application to be automatically added to the documentation.
const std::string & GetBriefDescription()
Returns the brief description of the application to be automatically added to the documentation.
const Value & operator[](const std::string &key) const
Will return the value given a key.
void ClearDescriptions()
Will delete all parameter descriptions.
std::string GenerateDocumentation() const
Will generate a text-based documentation suited to show the user, for example on –help.
void RegisterDescription(const std::string ¶meter, const std::string &description)
Willl register a short description for a parameter.
const std::string & GetDescription(const std::string ¶meter) const
Will return a short description for a parameter, if it exists.
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.
const std::string & GetExecutableName() const
Will return argv[0], the name of the executable.
void SetCrashOnFail(bool crashOnFail)
Sets whether to crash the application, and print to stderr, when an exception is raised whilst parsin...