#include <string>
#include <sstream>
#include <iostream>
+#include <functional>
#include "parameter.h"
#include "callable.h"
* Arguments are non-named parameters of program.
*
* Example:
- * ./myprog ARGUMENT
- * ./myprog /path/to/file
- * ./myprog "some argument"
+ * - ./myprog ARGUMENT
+ * - ./myprog /path/to/file
+ * - ./myprog "some argument"
*/
template<typename ParameterType>
class Argument : public Parameter, public Callable<ParameterType> {
: Parameter(description), Callable<ParameterType>(function) {
}
+ Argument(const std::string & description, std::function<void(ParameterType)> function)
+ : Parameter(description), Callable<ParameterType>(function) {
+ }
+
/**
*
*/
virtual ~Argument() { }
/**
- *
+ * \inheritdoc
*/
virtual void handle() {
this->call(value);
+ this->used = true;
}
/**
* against next value.
*/
virtual bool understand(const std::string & argv) {
- if (!isUsed()) {
- std::stringstream ss;
+ std::stringstream ss;
- ss << argv;
- ss >> value;
+ ss << std::fixed << argv;
+ ss >> value;
- if (!ss.fail()) {
- this->used = true;
- return true;
- }
+ if (!ss.fail()) {
+ return true;
}
return false;
}
+
+ /**
+ * \inheritdoc
+ */
+ virtual unsigned int valuePosition(const std::string & ) {
+ return 0;
+ }
};
}