MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / exportToFile

Method exportToFile

radiantcore/xmlregistry/RegistryTree.cpp:247–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245}
246
247void RegistryTree::exportToFile(const std::string& key, const std::string& filename)
248{
249 if (key.empty()) return;
250
251 // Add the toplevel node to the key if required
252 std::string fullKey = prepareKey(key);
253
254 // Try to find the specified node
255 xml::NodeList result = _tree.findXPath(fullKey);
256
257 if (result.empty())
258 {
259 rMessage() << "XMLRegistry: Failed to save path " << fullKey << std::endl;
260 return;
261 }
262
263 // Create a new xml::Document
264 xml::Document targetDoc = xml::Document::create();
265
266 std::string keyName = fullKey.substr(fullKey.rfind("/") + 1);
267
268 // Add an empty toplevel node with the given key (leaf) name
269 targetDoc.addTopLevelNode(keyName);
270
271 // Select all the child nodes of the export key
272 xml::NodeList children = _tree.findXPath(fullKey + "/*");
273
274 // Copy the child nodes into this document
275 targetDoc.copyNodes(children);
276
277 // Save the whole document to the specified filename
278 targetDoc.saveToFile(filename);
279
280 // rMessage() << "XMLRegistry: Saved " << key << " to " << filename << std::endl;
281}
282
283void RegistryTree::dump() const
284{

Callers

nothing calls this directly

Calls 6

rMessageFunction · 0.85
addTopLevelNodeMethod · 0.80
copyNodesMethod · 0.80
saveToFileMethod · 0.80
emptyMethod · 0.45
findXPathMethod · 0.45

Tested by

no test coverage detected