From 8f05c7de54336daefb214a754de35367098b6510 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Mon, 7 Jul 2014 22:25:03 +0200 Subject: Implemented custom xercesc::DOMDocument deleter * pointers to xercesc::DOMDocument were manually released ** this is now solved using a custom deleter for the appropriate std::unqiue_ptr template specialization * added matching factory method to DomDocumentCache * updated external function implementations accordingly ** "constructDocument" is now expected to return a DomDocumentCache::document_ptr instance * updated TransformerFacade accordingly * this change was implemented to get rid of the manual memory management required by xalan / xerces --- src/function/read_file.cc | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src/function/read_file.cc') diff --git a/src/function/read_file.cc b/src/function/read_file.cc index f27a38e..cb1e57f 100644 --- a/src/function/read_file.cc +++ b/src/function/read_file.cc @@ -1,8 +1,5 @@ #include "read_file.h" -#include -#include -#include #include #include @@ -62,21 +59,17 @@ boost::optional readPlainFile( namespace InputXSLT { -xercesc::DOMDocument* FunctionReadFile::constructDocument( +DomDocumentCache::document_ptr FunctionReadFile::constructDocument( boost::filesystem::path filePath) { - xercesc::DOMDocument* const domDocument( - xercesc::DOMImplementation::getImplementation()->createDocument( - nullptr, - *XercesStringGuard("content"), - nullptr - ) + DomDocumentCache::document_ptr domDocument( + DomDocumentCache::createDocument() ); xercesc::DOMNode* const rootNode( domDocument->getDocumentElement() ); - ResultNodeFacade result(domDocument, rootNode, "file"); + ResultNodeFacade result(domDocument.get(), rootNode, "file"); result.setAttribute("path", filePath.string()); if ( boost::filesystem::is_regular_file(filePath) ) { @@ -84,7 +77,10 @@ xercesc::DOMDocument* FunctionReadFile::constructDocument( if ( isXmlFile(filePath) ) { result.setAttribute("type", "xml"); - if ( auto importedNode = readXmlFile(filePath, domDocument) ) { + if ( auto importedNode = readXmlFile( + filePath, + domDocument.get()) + ) { result.setContent(*importedNode); result.setAttribute("result", "success"); -- cgit v1.2.3