simgear/props/props_io.*: added class for inline calling of writeProperties().

E.g. allows:

    SG_LOG(SG_VIEW, SG_ALERT, "returning:\n" << writePropertiesInline(config, true /*write_all*/));
This commit is contained in:
Julian Smith
2020-12-11 23:44:44 +00:00
parent 8954a54e2e
commit 89fabafa15
2 changed files with 35 additions and 0 deletions

View File

@@ -689,6 +689,24 @@ writeProperties (ostream &output, const SGPropertyNode * start_node,
output << "</PropertyList>" << endl;
}
writePropertiesInline::writePropertiesInline(
const SGPropertyNode * start_node,
bool write_all,
SGPropertyNode::Attribute archive_flag
)
:
m_start_node(start_node),
m_write_all(write_all),
m_archive_flag(archive_flag)
{
}
std::ostream& operator<< (std::ostream& out, const writePropertiesInline& wpm)
{
writeProperties(out, wpm.m_start_node, wpm.m_write_all, wpm.m_archive_flag);
return out;
}
void
writeProperties (const SGPath &path, const SGPropertyNode * start_node,

View File

@@ -49,6 +49,23 @@ void writeProperties (std::ostream &output, const SGPropertyNode * start_node,
bool write_all = false,
SGPropertyNode::Attribute archive_flag = SGPropertyNode::ARCHIVE);
/**
* Convenience manipulator for calling writeProperties(), e.g.:
* std::cerr << "node is:\n" << writePropertiesStream(node, true) << "\n";
*/
struct writePropertiesInline
{
writePropertiesInline(
const SGPropertyNode * start_node,
bool write_all = false,
SGPropertyNode::Attribute archive_flag = SGPropertyNode::ARCHIVE
);
const SGPropertyNode * m_start_node;
bool m_write_all;
SGPropertyNode::Attribute m_archive_flag;
};
std::ostream& operator<< (std::ostream& out, const writePropertiesInline& wpm);
/**
* Write properties to an XML file.