aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-09-14 19:49:15 +0200
committerAdrian Kummerlaender2014-09-14 19:49:15 +0200
commit8ebea90f5cee70654ab9f1c19ed4f89dfc8ffb25 (patch)
tree55997e02cbcaa5cf2d961dc33a1ff7ca2981ec95
parentced9f340e88e6011376fb65ae81bf2f2b327ecc0 (diff)
downloadInputXSLT-8ebea90f5cee70654ab9f1c19ed4f89dfc8ffb25.tar
InputXSLT-8ebea90f5cee70654ab9f1c19ed4f89dfc8ffb25.tar.gz
InputXSLT-8ebea90f5cee70654ab9f1c19ed4f89dfc8ffb25.tar.bz2
InputXSLT-8ebea90f5cee70654ab9f1c19ed4f89dfc8ffb25.tar.lz
InputXSLT-8ebea90f5cee70654ab9f1c19ed4f89dfc8ffb25.tar.xz
InputXSLT-8ebea90f5cee70654ab9f1c19ed4f89dfc8ffb25.tar.zst
InputXSLT-8ebea90f5cee70654ab9f1c19ed4f89dfc8ffb25.zip
Switched member initialization to std::make_unique
* i.e. InputXSLT now requires a C++14 supporting compiler / standard library implementation * this was done while enabling the StreamInputSource to handle all kinds of streams ** this in turn is required to enable e.g. stdin as transformation source while preserving the correct filesystem context
-rw-r--r--CMakeLists.txt2
-rw-r--r--ixslt.cc8
-rw-r--r--src/support/dom/document_cache.cc2
-rw-r--r--src/support/dom/document_cache_item.h2
-rw-r--r--src/support/error/error_capacitor.cc4
-rw-r--r--src/support/error/error_capacitor.h7
-rw-r--r--src/support/error/warning_capacitor.cc10
-rw-r--r--src/support/error/warning_capacitor.h2
-rw-r--r--src/transformer_facade.cc24
9 files changed, 31 insertions, 30 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f933aeb..705ecb7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,7 +3,7 @@ project(InputXSLT)
set(
CMAKE_CXX_FLAGS
- "${CMAKE_CXX_FLAGS} -std=c++11 -W -Wall -Wextra -Winline -pedantic"
+ "${CMAKE_CXX_FLAGS} -std=c++14 -W -Wall -Wextra -Winline -pedantic"
)
include_directories(
diff --git a/ixslt.cc b/ixslt.cc
index 683effd..6932dec 100644
--- a/ixslt.cc
+++ b/ixslt.cc
@@ -42,8 +42,10 @@ class StreamInputSource {
const boost::filesystem::path& actualPath,
const boost::filesystem::path& contextPath
):
- file_(actualPath),
- source_(file_) {
+ file_(std::make_unique<boost::filesystem::ifstream>(
+ actualPath
+ )),
+ source_(*file_) {
this->source_.setSystemId(
*InputXSLT::XercesStringGuard<XMLCh>(
"file://" + contextPath.string()
@@ -56,7 +58,7 @@ class StreamInputSource {
}
private:
- boost::filesystem::ifstream file_;
+ std::unique_ptr<std::istream> file_;
xalan::XSLTInputSource source_;
};
diff --git a/src/support/dom/document_cache.cc b/src/support/dom/document_cache.cc
index c18bf96..c000aef 100644
--- a/src/support/dom/document_cache.cc
+++ b/src/support/dom/document_cache.cc
@@ -33,7 +33,7 @@ xalan::XalanDocument* DomDocumentCache::create(document_ptr&& document) {
std::lock_guard<std::mutex> guard(this->write_mutex_);
this->cache_.emplace(
- new item(
+ std::make_unique<item>(
std::move(document)
)
);
diff --git a/src/support/dom/document_cache_item.h b/src/support/dom/document_cache_item.h
index ebc9172..df24948 100644
--- a/src/support/dom/document_cache_item.h
+++ b/src/support/dom/document_cache_item.h
@@ -17,7 +17,7 @@ class DomDocumentCache::item {
xalan::XalanDocument* getXalanDocument();
protected:
- friend DomDocumentCache;
+ friend std::unique_ptr<item> std::make_unique<item>(document_ptr&&);
item(document_ptr&&);
diff --git a/src/support/error/error_capacitor.cc b/src/support/error/error_capacitor.cc
index cc7dd01..22ec45d 100644
--- a/src/support/error/error_capacitor.cc
+++ b/src/support/error/error_capacitor.cc
@@ -4,7 +4,7 @@ namespace InputXSLT {
ErrorCapacitor::ErrorCapacitor(ErrorMultiplexer* multiplexer):
ErrorMultiplexer::receiver(multiplexer),
- error_cache_(new error_cache()) { }
+ error_cache_(std::make_unique<error_cache>()) { }
void ErrorCapacitor::discharge() {
if ( !this->error_cache_->empty() ) {
@@ -21,7 +21,7 @@ void ErrorCapacitor::receive(
}
}
-ErrorCapacitor::exception::exception(error_cache_ptr ptr):
+ErrorCapacitor::exception::exception(std::unique_ptr<error_cache> ptr):
error_cache_(std::move(ptr)) { }
auto ErrorCapacitor::exception::operator*() const -> const error_cache& {
diff --git a/src/support/error/error_capacitor.h b/src/support/error/error_capacitor.h
index 1c225e9..03f155d 100644
--- a/src/support/error/error_capacitor.h
+++ b/src/support/error/error_capacitor.h
@@ -12,7 +12,6 @@ class ErrorCapacitor : public ErrorMultiplexer::receiver {
class exception;
typedef std::vector<std::string> error_cache;
- typedef std::unique_ptr<error_cache> error_cache_ptr;
ErrorCapacitor(ErrorMultiplexer*);
@@ -24,18 +23,18 @@ class ErrorCapacitor : public ErrorMultiplexer::receiver {
);
private:
- error_cache_ptr error_cache_;
+ std::unique_ptr<error_cache> error_cache_;
};
class ErrorCapacitor::exception {
public:
- exception(error_cache_ptr);
+ exception(std::unique_ptr<error_cache>);
const error_cache& operator*() const;
private:
- error_cache_ptr error_cache_;
+ std::unique_ptr<error_cache> error_cache_;
};
diff --git a/src/support/error/warning_capacitor.cc b/src/support/error/warning_capacitor.cc
index f8d2b99..0d98977 100644
--- a/src/support/error/warning_capacitor.cc
+++ b/src/support/error/warning_capacitor.cc
@@ -4,14 +4,16 @@ namespace InputXSLT {
WarningCapacitor::WarningCapacitor(ErrorMultiplexer* multiplexer):
ErrorMultiplexer::receiver(multiplexer),
- warning_cache_(new warning_cache()) { }
+ warning_cache_(std::make_unique<warning_cache>()) { }
auto WarningCapacitor::discharge() -> warning_cache_ptr {
- warning_cache_ptr tmp(std::move(this->warning_cache_));
+ warning_cache_ptr tmp(
+ std::make_unique<warning_cache>()
+ );
- this->warning_cache_.reset(new warning_cache());
+ std::swap(tmp, this->warning_cache_);
- return std::move(tmp);
+ return tmp;
}
void WarningCapacitor::receive(
diff --git a/src/support/error/warning_capacitor.h b/src/support/error/warning_capacitor.h
index 6b7058b..70f979b 100644
--- a/src/support/error/warning_capacitor.h
+++ b/src/support/error/warning_capacitor.h
@@ -9,7 +9,7 @@ namespace InputXSLT {
class WarningCapacitor : public ErrorMultiplexer::receiver {
public:
- typedef std::vector<std::string> warning_cache;
+ typedef std::vector<std::string> warning_cache;
typedef std::unique_ptr<warning_cache> warning_cache_ptr;
WarningCapacitor(ErrorMultiplexer*);
diff --git a/src/transformer_facade.cc b/src/transformer_facade.cc
index 5bfb71e..0215e13 100644
--- a/src/transformer_facade.cc
+++ b/src/transformer_facade.cc
@@ -33,19 +33,17 @@ std::unique_ptr<xalan::FormatterToXML> augmentFormatterToXML(
xalan::XalanDOMString outputDoctypeSystem;
xalan::XalanDOMString outputStandalone;
- return std::unique_ptr<xalan::FormatterToXML>(
- new xalan::FormatterToXML(
- *(formatter.getWriter()),
- stylesheetRoot->getOutputVersion(outputVersion),
- stylesheetRoot->getOutputIndent(),
- xalan::FormatterToXML::eDefaultIndentAmount,
- stylesheetRoot->getOutputEncoding(outputEncoding),
- stylesheetRoot->getOutputMediaType(outputMediaType),
- stylesheetRoot->getOutputDoctypeSystem(outputDoctypeSystem),
- stylesheetRoot->getOutputDoctypePublic(outputDoctypePublic),
- !stylesheetRoot->getOmitOutputXMLDecl(),
- stylesheetRoot->getOutputStandalone(outputStandalone)
- )
+ return std::make_unique<xalan::FormatterToXML>(
+ *(formatter.getWriter()),
+ stylesheetRoot->getOutputVersion(outputVersion),
+ stylesheetRoot->getOutputIndent(),
+ xalan::FormatterToXML::eDefaultIndentAmount,
+ stylesheetRoot->getOutputEncoding(outputEncoding),
+ stylesheetRoot->getOutputMediaType(outputMediaType),
+ stylesheetRoot->getOutputDoctypeSystem(outputDoctypeSystem),
+ stylesheetRoot->getOutputDoctypePublic(outputDoctypePublic),
+ !stylesheetRoot->getOmitOutputXMLDecl(),
+ stylesheetRoot->getOutputStandalone(outputStandalone)
);
}