Commit 8a71425e authored by Alexander Lapshin's avatar Alexander Lapshin

+ svalue<int>

parent 5c511f3e
...@@ -852,3 +852,41 @@ static bool loadjson(const jsonval& parent, const std::string& key, svalue<doubl ...@@ -852,3 +852,41 @@ static bool loadjson(const jsonval& parent, const std::string& key, svalue<doubl
return true; return true;
} }
static bool loadjson(const jsonval& parent, const std::string& key, svalue<int>& value, const bool exist = true)
{
jsonval::ConstMemberIterator itr;
bool* loaded = nullptr;
if (!extract_value(parent, key, exist, loaded, itr)) {
return false;
}
const jsonval& a = itr->value;
if (a.IsInt()) {
value = a.GetInt();
}
else if (a.IsString()) {
const std::string str = a.GetString();
if (str.empty() && !exist) {
if (loaded) {
*loaded = false;
}
return false;
}
int val;
if (!Converter::ToNumber(str, val)) {
throw (Exp() << "bad value format '" << str << "'" << " in container '");
}
value = val;
}
else {
throw (Exp() << "element '" << key << "'" << " has unexpected format '");
}
return true;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment