From 141725d681dd69f77e993c3d59d613d1ad7014f9 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 12 Jul 2014 09:51:09 +0200 Subject: 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 --- src/function/base.h | 4 +--- src/function/external_text_formatter.cc | 2 +- src/function/external_text_formatter.h | 2 +- src/function/read_directory.cc | 2 +- src/function/read_directory.h | 2 +- src/function/read_file.cc | 2 +- src/function/read_file.h | 2 +- src/function/transform.cc | 25 ++++++------------------- src/function/transform.h | 2 +- src/function/write_file.cc | 2 +- src/function/write_file.h | 2 +- src/transformer_facade.h | 1 - 12 files changed, 16 insertions(+), 32 deletions(-) (limited to 'src') 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( - const_cast(this) - )->constructDocument( + static_cast(this)->constructDocument( valueGetter.get 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 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; }; diff --git a/src/transformer_facade.h b/src/transformer_facade.h index 14d2f41..dfe6123 100644 --- a/src/transformer_facade.h +++ b/src/transformer_facade.h @@ -46,7 +46,6 @@ class TransformerFacade { xalan::FormatterListener& ); - }; } -- cgit v1.2.3