Commit 00713907 authored by Alexander Lapshin's avatar Alexander Lapshin

.

parent b7f35dc1
......@@ -364,6 +364,39 @@ static bool loadjson(const jsonval& parent, const std::string& key, int& value,
return true;
}
static bool loadjson(const jsonval& parent, const std::string& key, size_t& value, const bool exist = true, bool* loaded = nullptr)
{
jsonval::ConstMemberIterator itr;
if (!extract_value(parent, key, exist, loaded, itr)) {
return false;
}
const jsonval& a = itr->value;
if (a.IsNumber()) {
value = a.GetInt();
}
else if (a.IsString()) {
std::string str = a.GetString();
if (str.empty() && !exist) {
if (loaded) {
*loaded = false;
}
return false;
}
if (!Converter::ToNumber(str, value)) {
throw (Exp() << "bad value format '" << str << "'" << " in container '");
}
}
else {
throw (Exp() << "element '" << key << "'" << " has unexpected format '");
}
return true;
}
static bool loadjson(const jsonval& parent, const std::string& key, bool& value, const bool exist = true, bool* loaded = nullptr)
{
jsonval::ConstMemberIterator itr;
......
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