diff --git a/build b/build index 0973804..eafdfb0 100644 --- a/build +++ b/build @@ -1 +1 @@ -137 \ No newline at end of file +138 \ No newline at end of file diff --git a/src/APConfig.cpp b/src/APConfig.cpp index 3f1def3..f72e477 100644 --- a/src/APConfig.cpp +++ b/src/APConfig.cpp @@ -153,60 +153,62 @@ namespace OpenWifi { } } - std::set Sections; - for(const auto &i:Config_) { - Poco::JSON::Parser P; - auto O = P.parse(i.element.configuration).extract(); - auto Names = O->getNames(); - for(const auto &SectionName:Names) { - auto InsertInfo = Sections.insert(SectionName); - if (InsertInfo.second) { - if (O->isArray(SectionName)) { - auto OriginalArray = O->getArray(SectionName); - if (Explain_) { - Poco::JSON::Object ExObj; - ExObj.set("from-uuid", i.info.id); - ExObj.set("from-name", i.info.name); - ExObj.set("action", "added"); - ExObj.set("element", OriginalArray); - Explanation_.add(ExObj); + try { + std::set Sections; + for (const auto &i: Config_) { + Poco::JSON::Parser P; + auto O = P.parse(i.element.configuration).extract(); + auto Names = O->getNames(); + for (const auto &SectionName: Names) { + auto InsertInfo = Sections.insert(SectionName); + if (InsertInfo.second) { + if (O->isArray(SectionName)) { + auto OriginalArray = O->getArray(SectionName); + if (Explain_) { + Poco::JSON::Object ExObj; + ExObj.set("from-uuid", i.info.id); + ExObj.set("from-name", i.info.name); + ExObj.set("action", "added"); + ExObj.set("element", OriginalArray); + Explanation_.add(ExObj); + } + auto ExpandedArray = Poco::makeShared(); + ReplaceVariablesInArray(OriginalArray, ExpandedArray); + Configuration->set(SectionName, ExpandedArray); + } else if (O->isObject(SectionName)) { + auto OriginalSection = O->get(SectionName).extract(); + if (Explain_) { + Poco::JSON::Object ExObj; + ExObj.set("from-uuid", i.info.id); + ExObj.set("from-name", i.info.name); + ExObj.set("action", "added"); + ExObj.set("element", OriginalSection); + Explanation_.add(ExObj); + } + auto ExpandedSection = Poco::makeShared(); + ReplaceVariablesInObject(OriginalSection, ExpandedSection); + Configuration->set(SectionName, ExpandedSection); + } else { + std::cout << " --- unknown element type --- " << O->get(SectionName).toString() + << std::endl; } - auto ExpandedArray = Poco::makeShared(); - ReplaceVariablesInArray(OriginalArray, ExpandedArray); - Configuration->set(SectionName, ExpandedArray); - } else if (O->isObject(SectionName)) { - auto OriginalSection = O->get(SectionName).extract(); - if (Explain_) { - Poco::JSON::Object ExObj; - ExObj.set("from-uuid", i.info.id); - ExObj.set("from-name", i.info.name); - ExObj.set("action", "added"); - ExObj.set("element", OriginalSection); - Explanation_.add(ExObj); - } - auto ExpandedSection = Poco::makeShared(); - ReplaceVariablesInObject(OriginalSection, ExpandedSection); - Configuration->set(SectionName, ExpandedSection); } else { - std::cout << " --- unknown element type --- " << O->get(SectionName).toString() << std::endl; - } - } else { - if (Explain_) { - Poco::JSON::Object ExObj; - ExObj.set("from-uuid", i.info.id); - ExObj.set("from-name", i.info.name); - ExObj.set("action", "ignored"); - ExObj.set("reason", "weight insufficient"); - ExObj.set("element", O->get(SectionName)); - Explanation_.add(ExObj); + if (Explain_) { + Poco::JSON::Object ExObj; + ExObj.set("from-uuid", i.info.id); + ExObj.set("from-name", i.info.name); + ExObj.set("action", "ignored"); + ExObj.set("reason", "weight insufficient"); + ExObj.set("element", O->get(SectionName)); + Explanation_.add(ExObj); + } } } } - } - if(Config_.empty()) - return false; + } catch (...) { - return true; + } + return !Config_.empty(); } static bool DeviceTypeMatch(const std::string &DeviceType, const Types::StringVec & Types) {