MCPcopy Create free account
hub / github.com/Kitware/VTK / LoadArgumentsFromXML

Method LoadArgumentsFromXML

Utilities/MetaIO/vtkmetaio/metaCommand.cxx:2153–2221  ·  view source on GitHub ↗

Load arguments from XML file */

Source from the content-addressed store, hash-verified

2151
2152/** Load arguments from XML file */
2153bool
2154MetaCommand::LoadArgumentsFromXML(const char * filename, bool createMissingArguments)
2155{
2156#ifdef METAIO_USE_LIBXML2
2157 xmlDocPtr doc;
2158 xmlNodePtr cur;
2159 doc = xmlParseFile(filename);
2160
2161 if (doc == nullptr)
2162 {
2163 std::cerr << "Cannot parse XML file" << std::endl;
2164 return false;
2165 }
2166
2167 cur = xmlDocGetRootElement(doc);
2168
2169 if (cur == nullptr)
2170 {
2171 std::cerr << "XML document is empty" << std::endl;
2172 xmlFreeDoc(doc);
2173 return false;
2174 }
2175 if (xmlStrcmp(cur->name, (const xmlChar *)"MetaCommand"))
2176 {
2177 std::cerr << "document of the wrong type. Root node should be MetaCommand" << std::endl;
2178 xmlFreeDoc(doc);
2179 return false;
2180 }
2181 xmlCleanupParser();
2182
2183 // Simple parsing (two levels hierarchy)
2184 cur = cur->children;
2185 while (cur)
2186 {
2187 xmlNodePtr child = cur->children;
2188 if (child)
2189 {
2190 xmlNodePtr subargument = child->next;
2191 while (subargument)
2192 {
2193 xmlNodePtr subargumentChild = subargument->children;
2194 if (subargumentChild && subargumentChild->content)
2195 {
2196 this->SetOptionValue((const char *)cur->name,
2197 (const char *)subargument->name,
2198 (const char *)subargumentChild->content,
2199 createMissingArguments);
2200 }
2201 subargument = subargument->next;
2202 }
2203
2204 if (child->content)
2205 {
2206 this->SetOptionValue(
2207 (const char *)cur->name, (const char *)cur->name, (const char *)child->content, createMissingArguments);
2208 }
2209 }
2210 cur = cur->next;

Callers

nothing calls this directly

Calls 6

SetOptionValueMethod · 0.95
xmlParseFileFunction · 0.85
xmlDocGetRootElementFunction · 0.85
xmlFreeDocFunction · 0.85
xmlStrcmpFunction · 0.85
xmlCleanupParserFunction · 0.85

Tested by

no test coverage detected