X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=include%2FmultiValue.h;h=26738b5c54e6a7c2461d9a8e88edb4355365aee9;hb=f2d683504e2dc76868ec84d7c1fd858edc0df5a4;hp=62fbf4d150c0dce495cabf6037d5a236586a6946;hpb=f4f7e7543fb56070a408da837cf4e42333504348;p=command.git diff --git a/include/multiValue.h b/include/multiValue.h index 62fbf4d..26738b5 100644 --- a/include/multiValue.h +++ b/include/multiValue.h @@ -68,11 +68,17 @@ namespace command { * \inheritdoc */ virtual bool understand(const std::string & value) { - size_t start = parameter->valuePosition(value); + size_t start = 0; size_t pos = 0; bool _understand = true; std::string prefix = ""; + start = parameter->valuePosition(value); + + if (start > value.size()) { + return false; + } + if (start > 0) { prefix = value.substr(0, ++start);// always count: "=" } @@ -82,8 +88,12 @@ namespace command { values.push_back(prefix + value.substr(start, pos-start)); _understand &= parameter->understand(values.back()); start = pos + 1; - } while ((pos != std::string::npos) && (start < value.size())); + if (!_understand) { + values.clear(); + break; + } + } while ((pos != std::string::npos) && (start < value.size())); return _understand; } @@ -117,4 +127,4 @@ namespace command { }; } -#endif /* __COMMAND_PARAMETER_H */ +#endif /* __COMMAND_MULTIVALUE_H */