virtual ~Argument() { }
virtual void handle() {
- std::cout << "Argument::handle()" << std::endl;
this->call(std::string("A"));
}
+
+ virtual bool understand(const std::string &) {
+ return false;
+ }
};
}
*
* @param description Description
*/
- Descriptive(std::string description)
+ Descriptive(const std::string& description)
: description(description) {
}
#include <string>
-#include "argument.h"
+#include "parameter.h"
namespace command {
/**
*/
template<typename OptionType>
class Option
- : public Argument<OptionType> {
- public:
-// typedef typename Argument<OptionType, Lambda>::FunctionType FunctionType;
+ : public Parameter, public Callable<OptionType> {
protected:
/**
* Option name
* @param function Function used to handle current Option.
*/
Option(std::string name, std::string description, void (*function)(OptionType))
- : name(name), Argument<OptionType>(description, function) {
+ : Parameter(description), Callable<OptionType>(function) {
}
virtual ~Option() { }
virtual void handle() {
- std::cout << "Option::handle()" << std::endl;
this->call(std::string("O"));
}
+
+ virtual bool understand(std::string argVal) {
+ if (argVal.find(name) != std::string::npos) {
+ return true;
+ }
+
+ return false;
+ }
};
}
namespace command {
/**
- * Class responsible for handling commandline arguments.
- * Arguments are required,x non-named parameters of program.
+ * Base class for all the Arguments and Options.
*
* Example:
* ./myprog ARGUMENT
*/
class Parameter : public Descriptive {
- protected:
- std::string userValue;
public:
typedef class Parameter Type;
/**
}
virtual ~Parameter() {}
+ /**
+ * Method used for handling method calls linked with Argument or Option
+ */
virtual void handle() = 0;
- virtual void passUserValue(std::string argVal) {
- userValue = argVal;
- }
+ /**
+ * Method used for checking if the given user value understandable for
+ * parameter.
+ */
+ virtual bool understand(std::string argVal) = 0;
};
}