41 bool parseXML(tinyxml2::XMLHandle& tag, Initializer& parent,
const std::string& prefix);
48 std::string value = tag.ToElement()->Attribute(
name.c_str());
54 for (tinyxml2::XMLHandle child = tag.FirstChild(); child.ToNode(); child = child.NextSibling())
55 if (child.ToElement() !=
nullptr) ++count;
58 if (tag.ToElement() ==
nullptr)
return;
60 if (!tag.ToElement()->GetText())
65 const std::string value = tag.ToElement()->GetText();
72 std::vector<Initializer> ret;
73 tinyxml2::XMLHandle child_tag = tag.FirstChild();
74 while (child_tag.ToNode())
76 if (child_tag.ToElement() ==
nullptr)
78 child_tag = child_tag.NextSibling();
82 if (!
parseXML(child_tag, ret[ret.size() - 1], prefix +
"- "))
90 child_tag = child_tag.NextSibling();
101 std::string
name = std::string(tag.ToElement()->Name());
106 tinyxml2::XMLAttribute* attr =
const_cast<tinyxml2::XMLAttribute*
>(tag.ToElement()->FirstAttribute());
109 std::string member_name = attr->Name();
111 attr =
const_cast<tinyxml2::XMLAttribute*
>(attr->Next());
115 tinyxml2::XMLHandle member_tag = tag.FirstChild();
116 while (member_tag.ToNode())
118 if (member_tag.ToElement() ==
nullptr)
120 member_tag = member_tag.NextSibling();
123 std::string member_name = std::string(member_tag.ToElement()->Name());
124 appendChildXML(parent, member_name,
false, member_tag, prefix +
"- ");
125 member_tag = member_tag.NextSibling();
133 tinyxml2::XMLDocument xml_file;
136 if (xml_file.Parse(file_name.c_str()) != tinyxml2::XML_SUCCESS)
138 ThrowPretty(
"Can't load file!\nFile: '" + file_name +
"'");
143 std::string xml =
LoadFile(file_name);
144 if (xml_file.Parse(xml.c_str()) != tinyxml2::XML_SUCCESS)
151 tinyxml2::XMLHandle root_tag(xml_file.RootElement()->FirstChildElement());
154 ThrowPretty(
"Can't parse XML!\nFile: '" + file_name +
"'");
161 tinyxml2::XMLDocument xml_file;
164 if (xml_file.Parse(file_name.c_str()) != tinyxml2::XML_SUCCESS)
166 #ifdef TINYXML_HAS_ERROR_STR
168 << xml_file.ErrorStr() <<
"\nFile: '" + file_name +
"'");
171 <<
"\nFile: '" + file_name +
"'");
177 std::string xml =
LoadFile(file_name);
178 tinyxml2::XMLError return_code = xml_file.Parse(xml.c_str());
179 if (xml_file.Error())
181 #ifdef TINYXML_HAS_ERROR_STR
182 ThrowPretty(
"Can't load file! Return code: " << return_code <<
"\n"
183 << xml_file.ErrorStr() <<
"\nFile: '" +
ParsePath(file_name) +
"'");
185 ThrowPretty(
"Can't load file! Return code: " << return_code <<
"\n"
186 <<
"File: '" +
ParsePath(file_name) +
"'");
191 std::vector<Initializer> initializers;
192 tinyxml2::XMLHandle root_tag(xml_file.RootElement()->FirstChild());
193 while (root_tag.ToNode())
195 if (root_tag.ToElement() ==
nullptr)
197 root_tag = root_tag.NextSibling();
201 if (!
parseXML(root_tag, initializers[initializers.size() - 1],
""))
203 initializers.pop_back();
205 root_tag = root_tag.NextSibling();
207 bool found_solver =
false;
208 bool found_problem =
false;
209 if (solver_name.empty() || solver_name ==
"")
213 std::string initializer_type = i.GetName();
218 if (known_type == initializer_type)
230 if (known_type == initializer_type)
233 found_problem =
true;
244 std::string
name = boost::any_cast<std::string>(i.GetProperty(
"Name"));
245 if (
name == solver_name)
250 if (
name == problem_name)
253 found_problem =
true;
257 if (!found_solver)
ThrowPretty(
"Can't find solver '" + solver_name +
"' in '" + file_name +
"'!");
258 if (!found_problem)
ThrowPretty(
"Can't find problem '" + problem_name +
"' in '" + file_name +
"'!");