4 #include <unordered_map> 22 void Parse(
const int argc,
const char*
const* argv);
31 bool HasParam(
const std::string& key)
const;
90 const std::string&
GetDescription(
const std::string& parameter)
const;
106 void PopulateRawArgs(
const int argc,
const char*
const* argv);
109 void ExpandAbbreviations();
112 std::size_t ParseNextParameter(
const std::size_t parIndex,
Parameter*& out_Par);
115 Value* ParseValue(
const std::vector<std::string>& values,
const ParamConstraint* constraint =
nullptr);
118 void ApplyConstraints();
121 const ParamConstraint* GetConstraintForKey(
const std::string& key)
const;
123 std::string executableName;
124 std::unordered_map<std::string, Parameter*> parameters;
127 std::unordered_map<std::string, std::string> parameterAbreviations;
130 std::unordered_map<std::string, ParamConstraint> parameterConstraints;
133 std::vector<std::string> rawArgs;
137 std::unordered_map<std::string, std::string> parameterDescriptions;
140 std::string briefDescription;
143 bool catchHelp =
true;
146 bool crashOnFail =
true;
bool HasAbbreviation(const std::string &abbrev) const
Will check wether or not an abbreviation is registered.
const Value & operator[](const std::string &key) const
Will return the value given a key.
bool GetCrashOnFail() const
Gets whether the application crashes on an exception whilst parsing, and prints to stderr...
void Parse(const int argc, const char *const *argv)
Will parse command line arguments.
bool GetCatchHelp() const
Retruns whether the CmdArgsInterface should automatically catch the –help parameter, print the parameter documentation to stdout, and exit or not.
void RegisterDescription(const std::string ¶meter, const std::string &description)
Willl register a short description for a parameter.
const std::string & GetBriefDescription()
Returns the brief description of the application to be automatically added to the documentation...
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...
void SetCatchHelp(bool catchHelp)
Sets whether the CmdArgsInterface should automatically catch the –help parameter, print the parameter documentation to stdout, and exit or not.
void RegisterConstraint(const std::string &key, const ParamConstraint &constraint)
Will register a constraint for a parameter.
const std::string & GetDescription(const std::string ¶meter) const
Will return a short description for a parameter, if it exists.
ParamConstraint GetConstraint(const std::string ¶meter) const
Will return the constraint information for a specific parameter.
void ClearDescription(const std::string ¶meter)
Will delete the description of a parameter if it exists.
void ClearConstraint(const std::string ¶meter)
Will the constraint of a specific parameter.
void SetBriefDescription(const std::string &description)
Sets a brief description of the application to be automatically added to the documentation.
void ClearConstraints()
Will delete all constraints.
std::string GenerateDocumentation() const
Will generate a text-based documentation suited to show the user, for example on –help.
void ClearAbbreviations()
Will delete all abbreviations.
void ClearAbbreviation(const std::string &abbrevation)
Will delete the abbreviation for a given parameter.
void RegisterAbbreviation(const std::string &abbrev, const std::string &target)
Will register an abbreviation (like -f for –force)
void ClearDescriptions()
Will delete all parameter descriptions.
Abstract class for values.
bool HasParam(const std::string &key) const
Will check wether a parameter exists given a key, or not.
bool HasDescription(const std::string ¶meter) const
Returns whether or not a given parameter has a registered description.
void SetCrashOnFail(bool crashOnFail)
Sets whether to crash the application, and print to stderr, when an exception is raised whilst parsin...
The main class to interface with.
const std::string & GetExecutableName() const
Will return argv[0], the name of the executable.