Add ability to append multiple Options to an OptionProperty

via addOptions(vector<int>, vector<string>)
This commit is contained in:
Matthew Territo
2016-07-22 12:39:09 -06:00
parent e5206cccb4
commit 8f40020fcb
2 changed files with 24 additions and 0 deletions
+17
View File
@@ -61,6 +61,23 @@ void OptionProperty::addOption(int value, std::string desc) {
_options.push_back(std::move(option));
}
void OptionProperty::addOptions(std::vector<int> values, std::vector<std::string> descs) {
if (values.size() != descs.size()) {
LERROR("Skipping " << this->fullyQualifiedIdentifier() << ": "
<< "number of values (" << values.size() << ") "
<< "does not equal number of descriptions (" << descs.size() << ")"
);
return;
}
for (int i = 0; i < values.size(); i++) {
LDEBUG(this->fullyQualifiedIdentifier() << ": Adding "
<< descs[i]
<< " (" << values[i] << ")"
);
this->addOption(values[i], descs[i]);
}
}
void OptionProperty::setValue(int value) {
// Check if the passed value belongs to any option
for (auto o : _options) {