Go to the documentation of this file.
61 usage <<
"\r\n Positional Arguments:\r\n\r\n";
72 usage <<
"\r\n Optional Arguments:\r\n\r\n";
77 char tmp[2] = { it.current()->getIdentifier(), 0 };
79 (
usage <<
" -" << tmp <<
", --" << it.current()->getName()).pad(16) <<
80 " " << it.current()->getDescription() <<
"\r\n";
102 const char *description)
120 const char *description,
146 for (
int i = 1; i < argc; i++)
150 String & part1 = parts[0];
156 if (part1.
length() > 1 && part1[0] ==
'-' && part1[1] ==
'-')
169 outarg =
new Argument((*arg)->getName());
174 else if (part1.
length() > 1 && part1[0] ==
'-' && part1[1] !=
'-')
192 outarg =
new Argument((*arg)->getName());
virtual bool hasCurrent() const
Check if there is a current item.
Size length() const
Same as count().
String m_name
Program name.
virtual const T & at(Size position) const
Return item at the given position as a reference.
Iterate through a HashTable.
String m_description
Program description.
void setCount(Size count)
Set argument maximum count.
void setDescription(const String &desc)
Set program description.
HashTable< String, Argument * > m_flags
Contains all registered flag arguments by name.
ArgumentParser()
Constructor.
List< String > split(const char delimiter) const
Split the String into parts separated by a delimiter.
Generic command-line argument parser.
Represents program command line argument.
Result addPositional(Argument *arg)
Add positional argument.
virtual const V * get(const K &key) const
Returns the first value for the given key.
Size getCount() const
Retrieve maximum argument count (if set)
virtual ~ArgumentParser()
Destructor.
virtual Size count() const
Get the number of values stored in the HashTable.
virtual Size count() const
Returns the number of items inside the Vector.
Vector< Argument * > m_positionals
Contains all registered positional arguments.
void setValue(const char *value)
Set argument option value.
unsigned int Size
Any sane size indicator cannot go negative.
Result registerFlag(char arg, const char *name, const char *description)
Register a flag Argument.
void setDescription(const char *description)
Set argument single line description.
const String & name() const
Retrieve program name.
virtual int insert(const T &item)
Adds the given item to the Vector, if possible.
HashTable< String, Argument * > m_flagsId
Contains all registered flag arguments by single character identifier.
String substring(const Size index, const Size size=0) const
Returns a part of the String as a copy.
Result registerPositional(const char *name, const char *description, Size count=1)
Register a positional argument.
Result addFlag(Argument *arg)
Add flag argument.
virtual bool hasCurrent() const
Check if there is a current item.
void setIdentifier(char id)
Set argument identifier.
String getUsage() const
Get program usage.
Iterate through a constant (read-only) HashTable.
virtual bool insert(const K &key, const V &value)
Inserts the given item to the HashTable.
void setName(const char *name)
Set program name.
T last()
Get the last value on the list.
const Vector< Argument * > & getPositionals() const
Get positional arguments.
Result parse(int argc, char **argv, ArgumentContainer &output)
Parse input arguments.