diff options
author | Adrian Kummerlaender | 2014-07-07 22:25:03 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2014-07-07 22:25:03 +0200 |
commit | 8f05c7de54336daefb214a754de35367098b6510 (patch) | |
tree | fc8d2b8309c88a1e57193784ad4f48bfa573952d /src/function/read_file.cc | |
parent | be99b28838796ff5e1dc91685d6121a55d962a88 (diff) | |
download | InputXSLT-8f05c7de54336daefb214a754de35367098b6510.tar InputXSLT-8f05c7de54336daefb214a754de35367098b6510.tar.gz InputXSLT-8f05c7de54336daefb214a754de35367098b6510.tar.bz2 InputXSLT-8f05c7de54336daefb214a754de35367098b6510.tar.lz InputXSLT-8f05c7de54336daefb214a754de35367098b6510.tar.xz InputXSLT-8f05c7de54336daefb214a754de35367098b6510.tar.zst InputXSLT-8f05c7de54336daefb214a754de35367098b6510.zip |
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
Diffstat (limited to 'src/function/read_file.cc')
-rw-r--r-- | src/function/read_file.cc | 20 |
1 files changed, 8 insertions, 12 deletions
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 <xercesc/dom/DOMDocument.hpp> -#include <xercesc/dom/DOMImplementation.hpp> -#include <xercesc/dom/DOMElement.hpp> #include <xercesc/parsers/XercesDOMParser.hpp> #include <xercesc/framework/LocalFileInputSource.hpp> @@ -62,21 +59,17 @@ boost::optional<std::string> 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<XMLCh>("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"); |