1
0
Fork 0

loadxml: if argument "targetnode" isn't defined, return the file data in

the argument tree under "data". This is useful in cases where the file
data are only needed temporarily and shouldn't remain in the main tree.
This commit is contained in:
mfranz 2007-06-04 10:07:31 +00:00
parent d11e18f9a7
commit ff454131d5

View file

@ -1312,22 +1312,25 @@ do_hud_init2(const SGPropertyNode *)
/** /**
* An fgcommand to allow loading of xml files via nasal, * An fgcommand to allow loading of xml files via nasal,
* the xml file's structure will be made available within * the xml file's structure will be made available within
* a (definable) property tree node * a property tree node defined under argument "targetnode",
* or in the given argument tree under "data" otherwise.
* *
* @param filename a string to hold the complete path & filename of a XML file * @param filename a string to hold the complete path & filename of a XML file
* @param targetnode a string pointing to a location within the property tree * @param targetnode a string pointing to a location within the property tree
* where to store the parsed XML file * where to store the parsed XML file
*/ */
static bool static bool
do_load_xml_to_proptree(const SGPropertyNode * node) do_load_xml_to_proptree(const SGPropertyNode * arg)
{ {
// SG_LOG(SG_GENERAL, SG_ALERT, "fgcommand loadxml executed"); SGPropertyNode *a = const_cast<SGPropertyNode *>(arg);
SGPropertyNode *targetnode;
if (a->hasValue("targetnode"))
targetnode = fgGetNode(a->getStringValue("targetnode"), true);
else
targetnode = a->getNode("data", true);
SGPropertyNode * targetnode; const char *filename = a->getNode("filename")->getStringValue();
targetnode = fgGetNode(node->getNode("targetnode")->getStringValue(),true);
const char *filename = node->getNode("filename")->getStringValue();
try { try {
fgLoadProps(filename, targetnode); fgLoadProps(filename, targetnode);
} catch (const sg_exception &e) { } catch (const sg_exception &e) {
@ -1484,7 +1487,7 @@ static struct {
{ "hud-init", do_hud_init }, { "hud-init", do_hud_init },
{ "hud-init2", do_hud_init2 }, { "hud-init2", do_hud_init2 },
{ "loadxml", do_load_xml_to_proptree}, { "loadxml", do_load_xml_to_proptree},
{ "savexml", do_save_xml_from_proptree }, { "savexml", do_save_xml_from_proptree },
{ "press-cockpit-button", do_press_cockpit_button }, { "press-cockpit-button", do_press_cockpit_button },
{ "release-cockpit-button", do_release_cockpit_button }, { "release-cockpit-button", do_release_cockpit_button },
{ "dump-scenegraph", do_dump_scene_graph }, { "dump-scenegraph", do_dump_scene_graph },