23 #ifndef PLLL_INCLUDE_GUARD__ARGUMENTS_HPP
24 #define PLLL_INCLUDE_GUARD__ARGUMENTS_HPP
74 enum Type { VT_Empty, VT_Text, VT_Integer, VT_Float };
87 Value(
const std::string & value, std::string &
id);
99 return d_type == VT_Empty;
110 return d_type == VT_Text;
135 return d_id_overflow;
143 return d_type == VT_Integer;
164 return d_type == VT_Float;
180 class MapIteratorComparator
183 bool operator() (
const std::map<std::string, Value>::const_iterator & A,
184 const std::map<std::string, Value>::const_iterator & B)
const
186 std::less<const Value*> less;
187 return less(&(A->second), &(B->second));
191 std::map<std::string, Value> d_args;
192 std::list<std::string> d_names;
193 mutable std::set<std::map<std::string, Value>::const_iterator, MapIteratorComparator> d_unprocessed_args;
206 return d_args.empty() && d_names.empty();
225 std::map<std::string, Value>::const_iterator i = d_args.find(arg);
226 if (i == d_args.end())
230 std::set<std::map<std::string, Value>::const_iterator, MapIteratorComparator>::iterator it = d_unprocessed_args.find(i);
231 if (it != d_unprocessed_args.end())
232 d_unprocessed_args.erase(it);
245 return d_unprocessed_args.size();
258 for (std::set<std::map<std::string, Value>::const_iterator, MapIteratorComparator>::iterator
259 i = d_unprocessed_args.begin(); i != d_unprocessed_args.end(); ++i)
260 f((*i)->first, (*i)->second);
bool hasUnprocessedArguments() const
Tests for unchecked label/values pairs.
const std::string & getText() const
Returns the raw text value.
long getInteger() const
Return integer value.
void enumerateUnprocessedArguments(Fun f) const
Calls a functor for every unchecked label/values pair.
const std::list< std::string > & getNames() const
Retrieves a list of names, i.e. arguments not starting with - or preceeded with --.
ArgumentParser(int argc, char **argv)
Parses the command line arguments. Ignores the name of the current program.
Parses command line arguments and makes them accessible.
const Value * getValue(const std::string &arg) const
Looks up the value of a label.
double getFloat() const
Return floating point value.
bool isEmpty() const
Tests whether value is empty.
bool hasOverflow() const
Checks for overflows.
bool isFloat() const
Informs whether the result is a floating point number.
bool hasNoArguments() const
Quick tests whether arguments were given.
bool isInteger() const
Informs whether the result is an integer.
bool isText() const
Returns whether the value is text.
Stores the value of one command line argument.