aboutsummaryrefslogtreecommitdiff
path: root/src/support/dom/document_cache_item.cc
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-05-03 22:04:16 +0200
committerAdrian Kummerländer2014-05-03 22:04:16 +0200
commit261170cc5b6661106877dc2611dab281f4d91348 (patch)
tree8482f249c090af5ca462f7e36a4b87082185f027 /src/support/dom/document_cache_item.cc
parente5ed418907f09bf8905463f42a44593d51159bc9 (diff)
downloadInputXSLT-261170cc5b6661106877dc2611dab281f4d91348.tar
InputXSLT-261170cc5b6661106877dc2611dab281f4d91348.tar.gz
InputXSLT-261170cc5b6661106877dc2611dab281f4d91348.tar.bz2
InputXSLT-261170cc5b6661106877dc2611dab281f4d91348.tar.lz
InputXSLT-261170cc5b6661106877dc2611dab281f4d91348.tar.xz
InputXSLT-261170cc5b6661106877dc2611dab281f4d91348.tar.zst
InputXSLT-261170cc5b6661106877dc2611dab281f4d91348.zip
Revamped DomDocumentCache with regard to thread safety
* DomDocumentCache::item class now is _finalized_ by default and doesn't perform document instantiation, just lifetime management ** xercesc::DOMDocument is instantiated inside the external function implementations and committed to the document cache for conversion to a xalan document * added mutex with scoped lock to prevent concurrent write access to the std::unordered_map contained withing DomDocumentCache * functionality of the _get_ member method was split into _get_ and _create_ ** added typedef for std::pair specialization type "optional_item" that functions as the return value of _create_ and _get_ * "locator->getSystemId()" was leaking memory as xerces doesn't manage the lifetime of the returned heap-allocated char array ** analog to XMLCh* strings ** transformed XercesStringGuard into template class to be instantiated on either XMLCh or char
Diffstat (limited to 'src/support/dom/document_cache_item.cc')
-rw-r--r--src/support/dom/document_cache_item.cc43
1 files changed, 8 insertions, 35 deletions
diff --git a/src/support/dom/document_cache_item.cc b/src/support/dom/document_cache_item.cc
index 8cc1c24..9798bfa 100644
--- a/src/support/dom/document_cache_item.cc
+++ b/src/support/dom/document_cache_item.cc
@@ -1,50 +1,23 @@
#include "support/dom/document_cache_item.h"
-#include <xercesc/dom/DOMImplementation.hpp>
-#include <xercesc/util/XMLString.hpp>
-
-#include "support/xerces_string_guard.h"
-
namespace InputXSLT {
-DomDocumentCache::item::item(const std::string& rootNode):
+DomDocumentCache::item::item(xercesc::DOMDocument* document):
parser_(),
dom_support_(parser_),
- document_(
- xercesc::DOMImplementation::getImplementation()->createDocument(
- nullptr,
- *XercesStringGuard(rootNode),
- nullptr
- )
- ),
- parsed_source_() { }
+ document_(document),
+ parsed_source_(
+ document_,
+ parser_,
+ dom_support_
+ ) { }
DomDocumentCache::item::~item() {
this->document_->release();
}
-bool DomDocumentCache::item::isFinalized() const {
- return static_cast<bool>(this->parsed_source_);
-}
-
-xercesc::DOMDocument* DomDocumentCache::item::getXercesDocument() const {
- return this->document_;
-}
-
xalan::XalanDocument* DomDocumentCache::item::getXalanDocument() {
- if ( this->parsed_source_ ) {
- return this->parsed_source_->getDocument();
- } else {
- this->parsed_source_.reset(
- new xalan::XercesDOMWrapperParsedSource(
- document_,
- parser_,
- dom_support_
- )
- );
-
- return this->parsed_source_->getDocument();
- }
+ return this->parsed_source_.getDocument();
}
}