 |
Leonetienne/Hazelnupp
Simple, easy to use, command line parameter interface
|
Go to the documentation of this file.
4 #include <unordered_map>
15 Hazelnupp(
const int argc,
const char*
const* argv);
20 void Parse(
const int argc,
const char*
const* argv);
29 bool HasParam(
const std::string& key)
const;
59 void PopulateRawArgs(
const int argc,
const char*
const* argv);
62 void ExpandAbbreviations();
65 std::size_t ParseNextParameter(
const std::size_t parIndex,
Parameter*& out_Par);
68 Value* ParseValue(
const std::vector<std::string>& values,
const ParamConstraint* constraint =
nullptr);
71 void ApplyConstraints();
74 const ParamConstraint* GetConstraintForKey(
const std::string& key)
const;
76 std::string executableName;
77 std::unordered_map<std::string, Parameter*> parameters;
80 std::unordered_map<std::string, std::string> abbreviations;
83 std::unordered_map<std::string, ParamConstraint> constraints;
85 std::vector<std::string> rawArgs;
88 bool crashOnFail =
true;
void ClearConstraints()
Will delete all constraints.
const std::string & GetExecutableName() const
Will return argv[0], the name of the executable.
const Value & operator[](const std::string &key) const
Will return the value given a key.
The main class to interface with.
void ClearAbbreviations()
Will delete all abbreviations.
Abstract class for values.
bool GetCrashOnFail() const
Gets whether the application crashes on an exception whilst parsing, and prints to stderr.
bool HasParam(const std::string &key) const
Will check wether a parameter exists given a key, or not.
void Parse(const int argc, const char *const *argv)
Will parse command line arguments.
void RegisterAbbreviation(const std::string &abbrev, const std::string &target)
Will register an abbreviation (like -f for –force)
void RegisterConstraints(const std::vector< ParamConstraint > &constraints)
Will register parameter constraints.
const std::string & GetAbbreviation(const std::string &abbrev) const
Will return the long form of an abbreviation (like –force for -f)
bool HasAbbreviation(const std::string &abbrev) const
Will check wether or not an abbreviation is registered.
void SetCrashOnFail(bool crashOnFail)
Sets whether to crash the application, and print to stderr, when an exception is raised whilst parsin...