savexml: analog to loadxml, if no <sourcenode> is given, save file
contents from the argument tree's <data> node. That way one doesn't have to plug a temporary branch into the main tree.
This commit is contained in:
parent
532389a5bd
commit
b3b87842b1
1 changed files with 12 additions and 3 deletions
|
@ -1352,6 +1352,8 @@ do_load_xml_to_proptree(const SGPropertyNode * arg)
|
||||||
* XML file
|
* XML file
|
||||||
* @param sourcenode a string pointing to a location within the property tree
|
* @param sourcenode a string pointing to a location within the property tree
|
||||||
* where to find the nodes that should be written recursively into an XML file
|
* where to find the nodes that should be written recursively into an XML file
|
||||||
|
* @param data if no sourcenode is given, then the file contents are taken from
|
||||||
|
* the argument tree's "data" node.
|
||||||
*
|
*
|
||||||
* TODO:
|
* TODO:
|
||||||
* deal with already existing filenames, optionally return error/success
|
* deal with already existing filenames, optionally return error/success
|
||||||
|
@ -1364,11 +1366,18 @@ do_load_xml_to_proptree(const SGPropertyNode * arg)
|
||||||
static bool
|
static bool
|
||||||
do_save_xml_from_proptree(const SGPropertyNode * node)
|
do_save_xml_from_proptree(const SGPropertyNode * node)
|
||||||
{
|
{
|
||||||
//TODO: do Parameter validation !
|
|
||||||
SGPropertyNode * sourcenode;
|
SGPropertyNode * sourcenode;
|
||||||
sourcenode = fgGetNode(node->getNode("sourcenode")->getStringValue(),true);
|
if (node->hasValue("sourcenode"))
|
||||||
|
sourcenode = fgGetNode(node->getStringValue("sourcenode"), true);
|
||||||
|
else if (node->hasValue("data"))
|
||||||
|
sourcenode = const_cast<SGPropertyNode *>(node)->getNode("data");
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const char *filename = node->getStringValue("filename", 0);
|
||||||
|
if (!filename)
|
||||||
|
return false;
|
||||||
|
|
||||||
const char *filename = node->getNode("filename")->getStringValue();
|
|
||||||
try {
|
try {
|
||||||
writeProperties (filename, sourcenode, true);
|
writeProperties (filename, sourcenode, true);
|
||||||
} catch (const sg_exception &e) {
|
} catch (const sg_exception &e) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue