aboutsummaryrefslogtreecommitdiff
path: root/src/function
diff options
context:
space:
mode:
authorAdrian Kummerlaender2014-07-12 09:51:09 +0200
committerAdrian Kummerlaender2014-07-12 09:51:09 +0200
commit141725d681dd69f77e993c3d59d613d1ad7014f9 (patch)
tree018fc2ebea779dd4b9a01543f0512c3e24e0fce7 /src/function
parent2192896e08572419edf99c81c3a524f07e877a10 (diff)
downloadInputXSLT-141725d681dd69f77e993c3d59d613d1ad7014f9.tar
InputXSLT-141725d681dd69f77e993c3d59d613d1ad7014f9.tar.gz
InputXSLT-141725d681dd69f77e993c3d59d613d1ad7014f9.tar.bz2
InputXSLT-141725d681dd69f77e993c3d59d613d1ad7014f9.tar.lz
InputXSLT-141725d681dd69f77e993c3d59d613d1ad7014f9.tar.xz
InputXSLT-141725d681dd69f77e993c3d59d613d1ad7014f9.tar.zst
InputXSLT-141725d681dd69f77e993c3d59d613d1ad7014f9.zip
Marked constructDocument member methods as const
* they don't modifiy the class state so there is no reason for them not being marked as const ** all calling methods are also const ** this enables us to remove the const_cast in FunctionBase * modified external function implementations accordingly * inlined handleError method in FunctionTransform as it is not needed in multiple places anymore
Diffstat (limited to 'src/function')
-rw-r--r--src/function/base.h4
-rw-r--r--src/function/external_text_formatter.cc2
-rw-r--r--src/function/external_text_formatter.h2
-rw-r--r--src/function/read_directory.cc2
-rw-r--r--src/function/read_directory.h2
-rw-r--r--src/function/read_file.cc2
-rw-r--r--src/function/read_file.h2
-rw-r--r--src/function/transform.cc25
-rw-r--r--src/function/transform.h2
-rw-r--r--src/function/write_file.cc2
-rw-r--r--src/function/write_file.h2
11 files changed, 16 insertions, 31 deletions
diff --git a/src/function/base.h b/src/function/base.h
index 7c2043e..c3e1fb6 100644
--- a/src/function/base.h
+++ b/src/function/base.h
@@ -104,9 +104,7 @@ class FunctionBase : public xalan::Function {
);
return this->document_cache_->create(
- static_cast<Implementation*>(
- const_cast<FunctionBase*>(this)
- )->constructDocument(
+ static_cast<const Implementation*>(this)->constructDocument(
valueGetter.get<typename std::tuple_element<
Index,
std::tuple<Types...>
diff --git a/src/function/external_text_formatter.cc b/src/function/external_text_formatter.cc
index ccf7ee7..048f81a 100644
--- a/src/function/external_text_formatter.cc
+++ b/src/function/external_text_formatter.cc
@@ -42,7 +42,7 @@ namespace InputXSLT {
DomDocumentCache::document_ptr FunctionExternalTextFormatter::constructDocument(
boost::filesystem::path formatterPath,
std::string stdinText
-) {
+) const {
DomDocumentCache::document_ptr domDocument(
DomDocumentCache::createDocument("content")
);
diff --git a/src/function/external_text_formatter.h b/src/function/external_text_formatter.h
index 23e6ab9..27f2fc7 100644
--- a/src/function/external_text_formatter.h
+++ b/src/function/external_text_formatter.h
@@ -21,7 +21,7 @@ class FunctionExternalTextFormatter : public FunctionBase<
DomDocumentCache::document_ptr constructDocument(
boost::filesystem::path,
std::string
- );
+ ) const;
};
diff --git a/src/function/read_directory.cc b/src/function/read_directory.cc
index 9b84828..8436459 100644
--- a/src/function/read_directory.cc
+++ b/src/function/read_directory.cc
@@ -6,7 +6,7 @@
namespace InputXSLT {
DomDocumentCache::document_ptr FunctionReadDirectory::constructDocument(
- boost::filesystem::path directoryPath) {
+ boost::filesystem::path directoryPath) const {
DomDocumentCache::document_ptr domDocument(
DomDocumentCache::createDocument("content")
);
diff --git a/src/function/read_directory.h b/src/function/read_directory.h
index 59ece1a..914f9b3 100644
--- a/src/function/read_directory.h
+++ b/src/function/read_directory.h
@@ -18,7 +18,7 @@ class FunctionReadDirectory : public FunctionBase<
friend FunctionBase;
DomDocumentCache::document_ptr constructDocument(
- boost::filesystem::path);
+ boost::filesystem::path) const;
};
diff --git a/src/function/read_file.cc b/src/function/read_file.cc
index 0ca5ee3..42cb4a4 100644
--- a/src/function/read_file.cc
+++ b/src/function/read_file.cc
@@ -60,7 +60,7 @@ boost::optional<std::string> readPlainFile(
namespace InputXSLT {
DomDocumentCache::document_ptr FunctionReadFile::constructDocument(
- boost::filesystem::path filePath) {
+ boost::filesystem::path filePath) const {
DomDocumentCache::document_ptr domDocument(
DomDocumentCache::createDocument("content")
);
diff --git a/src/function/read_file.h b/src/function/read_file.h
index 3026c79..b26bc6a 100644
--- a/src/function/read_file.h
+++ b/src/function/read_file.h
@@ -18,7 +18,7 @@ class FunctionReadFile : public FunctionBase<
friend FunctionBase;
DomDocumentCache::document_ptr constructDocument(
- boost::filesystem::path);
+ boost::filesystem::path) const;
};
diff --git a/src/function/transform.cc b/src/function/transform.cc
index 6cda7a7..7eab3fd 100644
--- a/src/function/transform.cc
+++ b/src/function/transform.cc
@@ -7,29 +7,12 @@
#include "support/dom/result_node_facade.h"
#include "support/error/error_capacitor.h"
-namespace {
-
-using InputXSLT::ErrorCapacitor;
-
-inline void handleErrors(
- InputXSLT::ResultNodeFacade& result,
- const ErrorCapacitor::error_cache& errors
-) {
- result.setAttribute("result", "error");
-
- for ( auto&& error : errors ) {
- result.setValueNode("error", error);
- }
-}
-
-}
-
namespace InputXSLT {
DomDocumentCache::document_ptr FunctionTransform::constructDocument(
xalan::XSLTInputSource inputSource,
xalan::XSLTInputSource transformationSource
-) {
+) const {
DomDocumentCache::document_ptr domDocument(
DomDocumentCache::createDocument("content")
);
@@ -52,7 +35,11 @@ DomDocumentCache::document_ptr FunctionTransform::constructDocument(
result.setAttribute("result", "success");
}
catch (const ErrorCapacitor::exception& exception) {
- handleErrors(result, *exception);
+ result.setAttribute("result", "error");
+
+ for ( auto&& error : *exception ) {
+ result.setValueNode("error", error);
+ }
}
WarningCapacitor::warning_cache_ptr warnings(
diff --git a/src/function/transform.h b/src/function/transform.h
index 95acba3..48f5c89 100644
--- a/src/function/transform.h
+++ b/src/function/transform.h
@@ -21,7 +21,7 @@ class FunctionTransform : public FunctionBase<
DomDocumentCache::document_ptr constructDocument(
xalan::XSLTInputSource,
xalan::XSLTInputSource
- );
+ ) const;
};
diff --git a/src/function/write_file.cc b/src/function/write_file.cc
index 3df9d78..06fdcfd 100644
--- a/src/function/write_file.cc
+++ b/src/function/write_file.cc
@@ -60,7 +60,7 @@ namespace InputXSLT {
DomDocumentCache::document_ptr FunctionWriteFile::constructDocument(
boost::filesystem::path filePath,
xalan::XalanNode* const contentNode
-) {
+) const {
DomDocumentCache::document_ptr domDocument(
DomDocumentCache::createDocument("content")
);
diff --git a/src/function/write_file.h b/src/function/write_file.h
index c1d6100..723865e 100644
--- a/src/function/write_file.h
+++ b/src/function/write_file.h
@@ -19,7 +19,7 @@ class FunctionWriteFile : public FunctionBase<
DomDocumentCache::document_ptr constructDocument(
boost::filesystem::path,
xalan::XalanNode* const
- );
+ ) const;
};