Example #1
0
void ConfigVisitor::Visit(const json::Object& object) {
	if (!name.empty())
		name += "/";

	for (auto const& obj : object) {
		ConfigVisitor config_visitor(values, name + obj.first, ignore_errors, replace);
		obj.second.Accept(config_visitor);
	}
}
Example #2
0
void Options::LoadConfig(std::istream& stream, bool ignore_errors) {
	/// @todo Store all previously loaded configs in an array for bug report purposes,
	///       this is just a temp stub.
	json::UnknownElement config_root;

	try {
		json::Reader::Read(config_root, stream);
	} catch (json::Reader::ParseException& e) {
		LOG_E("option/load") << "json::ParseException: " << e.what() << ", Line/offset: " << e.m_locTokenBegin.m_nLine + 1 << '/' << e.m_locTokenBegin.m_nLineOffset + 1;
	} catch (json::Exception& e) {
		/// @todo Do something better here, maybe print the exact error
		LOG_E("option/load") << "json::Exception: " << e.what();
	}

	ConfigVisitor config_visitor(values, "", ignore_errors, !ignore_errors);
	config_root.Accept(config_visitor);
}