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

Method importFromFile

radiantcore/xmlregistry/RegistryTree.cpp:204–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204void RegistryTree::importFromFile(const std::string& importFilePath,
205 const std::string& parentKey)
206{
207 std::string importKey = parentKey;
208
209 // If an empty parentKey was passed, set it to the default import node
210 if (importKey.empty())
211 {
212 importKey = _defaultImportNode;
213 }
214
215 // Check if the importKey exists - if not: create it
216 std::string fullImportKey = prepareKey(importKey);
217
218 if (!keyExists(fullImportKey))
219 {
220 createKey(fullImportKey);
221 }
222
223 // Lookup the mount point by using findXPath(), it must exist by now
224 xml::NodeList importNodeList = _tree.findXPath(fullImportKey);
225
226 if (importNodeList.empty())
227 {
228 rMessage() << "XMLRegistry: Critical: ImportNode could not be found." << std::endl;
229 return;
230 }
231
232 rMessage() << "XMLRegistry: Importing XML file: " << importFilePath << std::endl;
233
234 // Load the file
235 xml::Document importDoc(importFilePath);
236
237 if (!importDoc.isValid())
238 {
239 // Throw the XMLImportException
240 throw std::runtime_error("Unable to load file: " + importFilePath);
241 }
242
243 // Import the document into our XML tree
244 _tree.importDocument(importDoc, importNodeList[0]);
245}
246
247void RegistryTree::exportToFile(const std::string& key, const std::string& filename)
248{

Callers 1

importMethod · 0.80

Calls 5

rMessageFunction · 0.85
importDocumentMethod · 0.80
emptyMethod · 0.45
findXPathMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected