From: david Date: Sun, 3 Mar 2002 21:22:24 +0000 (+0000) Subject: Modified to add an optional parameter to writeProperties to allow X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=10715bbea71ffe5ee4b17558e0c108eb1a2a0021;p=simgear.git Modified to add an optional parameter to writeProperties to allow *all* properties to be written, rather than just the ones flagged as archivable. Tony Peden requested this feature to make it easier for people to document properties. --- diff --git a/simgear/misc/props.hxx b/simgear/misc/props.hxx index 5ac1e5b3..977edca1 100644 --- a/simgear/misc/props.hxx +++ b/simgear/misc/props.hxx @@ -1131,13 +1131,15 @@ void readProperties (const string &file, SGPropertyNode * start_node); /** * Write properties to an XML output stream. */ -void writeProperties (ostream &output, const SGPropertyNode * start_node); +void writeProperties (ostream &output, const SGPropertyNode * start_node, + bool write_all = false); /** * Write properties to an XML file. */ -void writeProperties (const string &file, const SGPropertyNode * start_node); +void writeProperties (const string &file, const SGPropertyNode * start_node, + bool write_all = false); /** diff --git a/simgear/misc/props_io.cxx b/simgear/misc/props_io.cxx index 8b93ba22..7c1f8bee 100644 --- a/simgear/misc/props_io.cxx +++ b/simgear/misc/props_io.cxx @@ -428,12 +428,13 @@ isArchivable (const SGPropertyNode * node) static bool -writeNode (ostream &output, const SGPropertyNode * node, int indent) +writeNode (ostream &output, const SGPropertyNode * node, + bool write_all, int indent) { // Don't write the node or any of // its descendants unless it is // allowed to be archived. - if (!isArchivable(node)) + if (!write_all && !isArchivable(node)) return true; // Everything's OK, but we won't write. const string &name = node->getName(); @@ -457,15 +458,14 @@ writeNode (ostream &output, const SGPropertyNode * node, int indent) } } - // If there are children, write them - // next. + // If there are children, write them next. if (nChildren > 0 || node->isAlias()) { doIndent(output, indent); output << '<' << name; writeAtts(output, node); output << '>' << endl; for (int i = 0; i < nChildren; i++) - writeNode(output, node->getChild(i), indent + INDENT_STEP); + writeNode(output, node->getChild(i), write_all, indent + INDENT_STEP); doIndent(output, indent); output << "' << endl; } @@ -475,7 +475,8 @@ writeNode (ostream &output, const SGPropertyNode * node, int indent) void -writeProperties (ostream &output, const SGPropertyNode * start_node) +writeProperties (ostream &output, const SGPropertyNode * start_node, + bool write_all) { int nChildren = start_node->nChildren(); @@ -483,7 +484,7 @@ writeProperties (ostream &output, const SGPropertyNode * start_node) output << "" << endl; for (int i = 0; i < nChildren; i++) { - writeNode(output, start_node->getChild(i), INDENT_STEP); + writeNode(output, start_node->getChild(i), write_all, INDENT_STEP); } output << "" << endl; @@ -491,11 +492,12 @@ writeProperties (ostream &output, const SGPropertyNode * start_node) void -writeProperties (const string &file, const SGPropertyNode * start_node) +writeProperties (const string &file, const SGPropertyNode * start_node, + bool write_all) { ofstream output(file.c_str()); if (output.good()) { - writeProperties(output, start_node); + writeProperties(output, start_node, write_all); } else { throw sg_io_exception("Cannot open file", sg_location(file)); }