| 245 | } |
| 246 | |
| 247 | void 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 | |
| 283 | void RegistryTree::dump() const |
| 284 | { |
nothing calls this directly
no test coverage detected