Fixed return value for deserialize() implementations. #3250
This commit is contained in:
parent
b9127e163b
commit
6e5938c833
2 changed files with 12 additions and 5 deletions
|
@ -63,7 +63,10 @@ ConfigBase::apply(const ConfigBase &other, bool ignore_nonexistent) {
|
||||||
|
|
||||||
// not the most efficient way, but easier than casting pointers to subclasses
|
// not the most efficient way, but easier than casting pointers to subclasses
|
||||||
bool res = my_opt->deserialize( other.option(*it)->serialize() );
|
bool res = my_opt->deserialize( other.option(*it)->serialize() );
|
||||||
if (!res) CONFESS("Unexpected failure when deserializing serialized value");
|
if (!res) {
|
||||||
|
std::string error = "Unexpected failure when deserializing serialized value for " + *it;
|
||||||
|
CONFESS(error.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,8 @@ class ConfigOptionFloat : public ConfigOptionSingle<double>
|
||||||
|
|
||||||
bool deserialize(std::string str) {
|
bool deserialize(std::string str) {
|
||||||
std::istringstream iss(str);
|
std::istringstream iss(str);
|
||||||
return iss >> this->value;
|
iss >> this->value;
|
||||||
|
return !iss.fail();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -145,7 +146,8 @@ class ConfigOptionInt : public ConfigOptionSingle<int>
|
||||||
|
|
||||||
bool deserialize(std::string str) {
|
bool deserialize(std::string str) {
|
||||||
std::istringstream iss(str);
|
std::istringstream iss(str);
|
||||||
return iss >> this->value;
|
iss >> this->value;
|
||||||
|
return !iss.fail();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -268,7 +270,8 @@ class ConfigOptionPercent : public ConfigOptionFloat
|
||||||
bool deserialize(std::string str) {
|
bool deserialize(std::string str) {
|
||||||
// don't try to parse the trailing % since it's optional
|
// don't try to parse the trailing % since it's optional
|
||||||
std::istringstream iss(str);
|
std::istringstream iss(str);
|
||||||
return iss >> this->value;
|
iss >> this->value;
|
||||||
|
return !iss.fail();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -307,7 +310,8 @@ class ConfigOptionFloatOrPercent : public ConfigOptionPercent
|
||||||
bool deserialize(std::string str) {
|
bool deserialize(std::string str) {
|
||||||
this->percent = str.find_first_of("%") != std::string::npos;
|
this->percent = str.find_first_of("%") != std::string::npos;
|
||||||
std::istringstream iss(str);
|
std::istringstream iss(str);
|
||||||
return iss >> this->value;
|
iss >> this->value;
|
||||||
|
return !iss.fail();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue