63 template<
typename... Args>
96 template<
typename... Args>
104 template<
typename Arg>
122 template<
typename Arg>
133 if (arg ==
nullptr) {
134 throw std::out_of_range(
"Argument not found");
147 if (arg ==
nullptr) {
148 throw std::out_of_range(
"Argument not found");
158 std::string
help()
const;
169 void parse(
int argc,
const char*
const argv[]);
189 template<
typename Ident>
200 void parse(std::vector<std::string>& argv)
const;
Argument parser class.
Definition: Parser.hpp:46
ArgumentParser & addConstraint(Arg &&constr)
Add the given constraint, to the parser.
void parse(int argc, const char *const argv[])
Parses the given arguments as they are presented on main() (see the parsing rules in the description ...
Simple argument class.
Definition: Argument.hpp:48
ArgumentSet m_constraints
Stored argument constraints.
Definition: Parser.hpp:52
const Argument * findArg() const
Find positional argument (see Argument::matches()), either the first one that can be set...
ArgumentParser(Args &&...args)
Construct a new ArgumentParser.
std::string m_programName
Program name as displayed in help text.
Definition: Parser.hpp:56
void set_arg_value(const Argument *arg, const std::string &value) const
Helper function to set the value of an Argument of which takes_value() returns true.
const std::string & program_name() const
Returns the program name.
Definition: Parser.hpp:87
virtual ~ArgumentParser()
ArgumentParser destructor.
Definition: Parser.hpp:69
const Argument & operator[](char flag) const
Get the Argument given the flag.
Definition: Parser.hpp:131
std::vector< ArgumentSet > m_argSets
Collection ArgumentSets (groups)
Definition: Parser.hpp:49
ArgumentParser & addAll(Args &&...args)
Add all given arguments, or constraints, to the parser.
ArgumentParser & program_name(const std::string &programName)
Set the program name.
Definition: Parser.hpp:78
std::string help() const
Generate a help string for the user to see.
Simple set of arguments.
Definition: ArgumentConstraint.hpp:194
const Argument & operator[](const std::string &name) const
Get the Argument given the flag.
Definition: Parser.hpp:145
ArgumentParser & add(Arg &&arg)
Add the given argument, or constraint, to the parser.