Commit 641aae96 authored by Alexander Lapshin's avatar Alexander Lapshin

.

parent 1e8ac4e0
......@@ -19,7 +19,7 @@ typedef rapidjson::Document jsondoc;
inline bool extract_value(const jsonval& parent, const std::string& key, bool exist, bool* loaded, jsonval::ConstMemberIterator& result)
{
const jsonval::ConstMemberIterator itr = parent.FindMember(key.c_str());
jsonval::ConstMemberIterator itr = parent.FindMember(key.c_str());
if (itr == parent.MemberEnd() && exist) {
throw Exp() << "error: element '" << key << "' not found";
......@@ -57,7 +57,7 @@ inline bool extract_value(const jsonval& parent, const std::string& key, bool ex
static bool loadjson(const jsonval& parent, const std::string& key, std::vector<std::string>& vec, bool exist = true, bool* loaded = 0)
{
jsonval::ConstMemberIterator itr;
if(!extract_value(parent, key, exist, loaded, itr)){
if (!extract_value(parent, key, exist, loaded, itr)) {
return false;
}
......@@ -103,7 +103,7 @@ static bool loadjson(const jsonval& parent, const std::string& key, std::vector<
}
const jsonval& a = itr->value;
if (!a.IsArray()) {
throw Exp() << "error: element is not an array";
}
......@@ -153,7 +153,7 @@ template <typename T> bool loadjson(const jsonval& parent, std::string key, std:
}
const jsonval& a = itr->value;
if (!a.IsArray()) {
throw Exp() << "error: element is not an array";
}
......@@ -185,7 +185,7 @@ template <typename T, typename Tid> bool loadjson(const jsonval& parent, std::st
loadjson(a[i], item);
map[item.getId()] = item;
}
return true;
}
......@@ -215,7 +215,7 @@ template <typename T> bool loadjson(const jsonval& parent, const std::string& ke
}
const jsonval& a = itr->value;
if (!a.IsObject()) {
throw Exp() << "error: element is not an object";
}
......@@ -267,10 +267,6 @@ template <typename T, typename T2> void loadjson(const jsonval& parent, std::map
}
}
if (!ok) {
throw Exp() << "json parse error " << filename << ", code: " << ok.Code() << ", offset: " << ok.Offset();
}
static bool loadjson(const jsonval& parent, const std::string& key, double& value, bool exist = true, bool* loaded = 0)
{
jsonval::ConstMemberIterator itr;
......@@ -279,7 +275,7 @@ static bool loadjson(const jsonval& parent, const std::string& key, double& valu
}
const jsonval& a = itr->value;
if (a.IsNumber()) {
value = a.GetDouble();
}
......@@ -300,7 +296,7 @@ static bool loadjson(const jsonval& parent, const std::string& key, double& valu
else {
throw (Exp() << "element '" << key << "'" << " has unexpected format '");
}
return true;
}
......@@ -310,9 +306,9 @@ static bool loadjson(const jsonval& parent, const std::string& key, int& value,
if (!extract_value(parent, key, exist, loaded, itr)) {
return false;
}
const jsonval& a = itr->value;
if (a.IsNumber()) {
value = a.GetInt();
}
......@@ -345,7 +341,7 @@ static bool loadjson(const jsonval& parent, const std::string& key, bool& value,
}
const jsonval& a = itr->value;
if (a.IsInt()) {
value = a.GetInt();
}
......@@ -381,7 +377,7 @@ static bool loadjson(const jsonval& parent, const std::string& key, std::string&
}
const jsonval& a = itr->value;
if (a.IsString()) {
value = a.GetString();
}
......@@ -393,7 +389,7 @@ static bool loadjson(const jsonval& parent, const std::string& key, std::string&
else {
throw (Exp() << "element '" << key << "'" << " has unexpected format '");
}
return true;
}
......@@ -528,7 +524,7 @@ static void flushjson(const jsondoc& outroot, const std::string& outputfile, boo
if (pretty) {
rapidjson::StringBuffer buffer;
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buffer);
if(!outroot.Accept(writer)){
if (!outroot.Accept(writer)) {
throw Exp() << "json write fail";
}
std::cout << buffer.GetString();
......
This diff is collapsed.
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