#include "parameter.h"
#include "exception/missingOptionValue.h"
#include "exception/optionFailedConversion.h"
+#include "exception/optionValueNotSpecified.h"
namespace command {
/**
virtual bool understand(const std::string & argv) {
if (argv.find(name) == 0) {
- std::size_t pos = argv.find("=");
+ std::size_t pos = this->valuePosition(argv);
if (pos != name.size()) {
throw MissingOptionValue("Option: " + name + " requires value but no one has been provided");
/**
* \inheritdoc
*/
- virtual unsigned int valuePosition(const std::string & argv) {
- return argv.find("=");
+ virtual unsigned int valuePosition(const std::string & value) {
+ std::size_t pos = value.find("=");
+
+ if (pos == std::string::npos) {
+ throw OptionValueNotSpecified("Option: " + name + " requires value to be specified using equal sign");
+ }
+
+ return pos;
}
};
* \inheritdoc
*/
virtual unsigned int valuePosition(const std::string & ) {
- throw new std::invalid_argument(this->describe() + "is void Option, so it does not have value part");
+ throw new std::invalid_argument(this->describe() + " is void Option, so it does not have value part");
}
};
}