Skip to content

Commit

Permalink
Added method to allow saving of IDF DOM tree. Re #3873.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anders-Markvardsen committed Nov 9, 2011
1 parent df5ad4f commit e847d1c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ namespace Geometry
/// get name of location element
static std::string getNameOfLocationElement(Poco::XML::Element* pElem);

/// Save DOM tree to xml file
void saveDOM_Tree(std::string& outFilename);

private:
/// Static reference to the logger class
static Kernel::Logger& g_log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <iostream>
#include <Poco/DOM/Document.h>
#include <Poco/DOM/DOMParser.h>
#include <Poco/DOM/DOMWriter.h>
#include <Poco/DOM/Element.h>
#include <Poco/DOM/NodeFilter.h>
#include <Poco/DOM/NodeIterator.h>
Expand Down Expand Up @@ -341,7 +342,24 @@ namespace Geometry
return m_instrument;
}

//-----------------------------------------------------------------------------------------------------------------------
/** Save DOM tree to xml file. This method was initially added for testing purpose
* but may be useful for other purposes. During the parsing of the DOM tree
* in parseXML() the tree may be modified, e.g. if <combine-components-into-one-shape>
* is used.
*
* @param outFilename :: To set position/location off
*/
void InstrumentDefinitionParser::saveDOM_Tree(std::string& outFilename)
{
Poco::XML::DOMWriter writer;
writer.setNewLine("\n");
writer.setOptions(Poco::XML::XMLWriter::PRETTY_PRINT);

std::ofstream outFile(outFilename.c_str());
writer.writeNode(outFile, pDoc);
outFile.close();
}

//-----------------------------------------------------------------------------------------------------------------------
/** Set location (position) of comp as specified in XML location element.
Expand Down

0 comments on commit e847d1c

Please sign in to comment.