aboutsummaryrefslogtreecommitdiff
path: root/src/function
diff options
context:
space:
mode:
Diffstat (limited to 'src/function')
-rw-r--r--src/function/base.h55
-rw-r--r--src/function/external_text_formatter.cc11
-rw-r--r--src/function/external_text_formatter.h3
-rw-r--r--src/function/read_directory.cc4
-rw-r--r--src/function/read_directory.h2
-rw-r--r--src/function/read_file.cc3
-rw-r--r--src/function/read_file.h2
-rw-r--r--src/function/read_xml_file.cc3
-rw-r--r--src/function/read_xml_file.h2
-rw-r--r--src/function/transform.cc17
-rw-r--r--src/function/transform.h4
11 files changed, 55 insertions, 51 deletions
diff --git a/src/function/base.h b/src/function/base.h
index 3609201..56712bb 100644
--- a/src/function/base.h
+++ b/src/function/base.h
@@ -12,8 +12,9 @@
#include "support/xalan_string.h"
#include "support/filesystem_context.h"
#include "support/include_entity_resolver.h"
-#include "support/tuple/mapper.h"
#include "support/dom/document_cache.h"
+#include "support/type/sequence.h"
+#include "support/type/xobject_value.h"
namespace InputXSLT {
@@ -22,18 +23,18 @@ template <
typename... Types
>
class FunctionBase : public xalan::Function {
- public:
- typedef std::tuple<Types...> parameter_tuple;
+ static const std::size_t parameter_count = sizeof...(Types);
+ public:
FunctionBase(IncludeEntityResolver* resolver):
include_resolver_(resolver),
document_cache_(std::make_shared<DomDocumentCache>()) { }
virtual xalan::XObjectPtr execute(
xalan::XPathExecutionContext& executionContext,
- xalan::XalanNode* context,
- const XObjectArgVectorType& parameters,
- const xalan::Locator* locator
+ xalan::XalanNode* context,
+ const XObjectArgVectorType& parameters,
+ const xalan::Locator* locator
) const {
this->validateParameters(
parameters,
@@ -43,25 +44,22 @@ class FunctionBase : public xalan::Function {
);
xalan::XalanDocument* const domDocument(
- this->document_cache_->create(
- static_cast<Implementation*>(
- const_cast<FunctionBase*>(this)
- )->constructDocument(
- FilesystemContext(locator),
- Mapper::template construct<parameter_tuple>(parameters)
- )
+ this->callConstructDocument(
+ parameters,
+ locator,
+ typename IndexSequence<parameter_count>::type()
)
);
- xalan::XPathExecutionContext::BorrowReturnMutableNodeRefList nodeList(
+ xalan::XPathExecutionContext::BorrowReturnMutableNodeRefList nodes(
executionContext
);
- nodeList->addNodes(
+ nodes->addNodes(
*domDocument->getDocumentElement()->getChildNodes()
);
- return executionContext.getXObjectFactory().createNodeSet(nodeList);
+ return executionContext.getXObjectFactory().createNodeSet(nodes);
}
virtual FunctionBase* clone(
@@ -84,14 +82,33 @@ class FunctionBase : public xalan::Function {
const xalan::XalanDOMString& getError(
xalan::XalanDOMString& result) const {
result.assign(std::string(
- "The function expects " +
- std::to_string(std::tuple_size<parameter_tuple>::value) +
+ "The function expects " +
+ std::to_string(parameter_count) +
" parameter(s)"
).data());
return result;
}
+ template <unsigned... Index>
+ inline xalan::XalanDocument* callConstructDocument(
+ const XObjectArgVectorType& parameters,
+ const xalan::Locator* locator,
+ Sequence<Index...>
+ ) const {
+ return this->document_cache_->create(
+ static_cast<Implementation*>(
+ const_cast<FunctionBase*>(this)
+ )->constructDocument(
+ FilesystemContext(locator),
+ XObjectValue::get<typename std::tuple_element<
+ Index,
+ std::tuple<Types...>
+ >::type>(parameters[Index])...
+ )
+ );
+ }
+
inline void validateParameters(
const XObjectArgVectorType& parameters,
xalan::XPathExecutionContext& executionContext,
@@ -106,7 +123,7 @@ class FunctionBase : public xalan::Function {
}
);
- if ( parameters.size() != std::tuple_size<parameter_tuple>::value || anyNull ) {
+ if ( parameters.size() != parameter_count || anyNull ) {
xalan::XPathExecutionContext::GetAndReleaseCachedString guard(
executionContext
);
diff --git a/src/function/external_text_formatter.cc b/src/function/external_text_formatter.cc
index 22f53c5..9fef439 100644
--- a/src/function/external_text_formatter.cc
+++ b/src/function/external_text_formatter.cc
@@ -44,16 +44,9 @@ namespace InputXSLT {
xercesc::DOMDocument* FunctionExternalTextFormatter::constructDocument(
const InputXSLT::FilesystemContext&,
- const FunctionBase::parameter_tuple& parameters
+ std::string formatterPath,
+ std::string stdinText
) {
- const std::string& formatterPath(
- std::get<0>(parameters)
- );
-
- const std::string& stdinText(
- std::get<1>(parameters)
- );
-
xercesc::DOMDocument* const domDocument(
xercesc::DOMImplementation::getImplementation()->createDocument(
nullptr,
diff --git a/src/function/external_text_formatter.h b/src/function/external_text_formatter.h
index 877bac5..95ff127 100644
--- a/src/function/external_text_formatter.h
+++ b/src/function/external_text_formatter.h
@@ -18,7 +18,8 @@ class FunctionExternalTextFormatter : public FunctionBase<
xercesc::DOMDocument* constructDocument(
const FilesystemContext&,
- const FunctionBase::parameter_tuple&
+ std::string,
+ std::string
);
};
diff --git a/src/function/read_directory.cc b/src/function/read_directory.cc
index e54e146..cfbe302 100644
--- a/src/function/read_directory.cc
+++ b/src/function/read_directory.cc
@@ -11,10 +11,10 @@ namespace InputXSLT {
xercesc::DOMDocument* FunctionReadDirectory::constructDocument(
const InputXSLT::FilesystemContext& fsContext,
- const FunctionBase::parameter_tuple& parameters
+ std::string path
) {
const boost::filesystem::path directoryPath(
- fsContext.resolve(std::get<0>(parameters))
+ fsContext.resolve(path)
);
xercesc::DOMDocument* const domDocument(
diff --git a/src/function/read_directory.h b/src/function/read_directory.h
index 88fcf15..6366a09 100644
--- a/src/function/read_directory.h
+++ b/src/function/read_directory.h
@@ -17,7 +17,7 @@ class FunctionReadDirectory : public FunctionBase<
xercesc::DOMDocument* constructDocument(
const FilesystemContext&,
- const FunctionBase::parameter_tuple&
+ std::string
);
};
diff --git a/src/function/read_file.cc b/src/function/read_file.cc
index 79e321d..22e96d7 100644
--- a/src/function/read_file.cc
+++ b/src/function/read_file.cc
@@ -26,9 +26,8 @@ namespace InputXSLT {
xercesc::DOMDocument* FunctionReadFile::constructDocument(
const FilesystemContext& fsContext,
- const FunctionBase::parameter_tuple& parameters
+ std::string rawPath
) {
- const std::string& rawPath = std::get<0>(parameters);
boost::filesystem::path filePath(fsContext.resolve(rawPath));
if ( !(boost::filesystem::exists(filePath) &&
diff --git a/src/function/read_file.h b/src/function/read_file.h
index cc1b662..fec8fe2 100644
--- a/src/function/read_file.h
+++ b/src/function/read_file.h
@@ -17,7 +17,7 @@ class FunctionReadFile : public FunctionBase<
xercesc::DOMDocument* constructDocument(
const FilesystemContext&,
- const FunctionBase::parameter_tuple&
+ std::string
);
};
diff --git a/src/function/read_xml_file.cc b/src/function/read_xml_file.cc
index cfa216c..65989b2 100644
--- a/src/function/read_xml_file.cc
+++ b/src/function/read_xml_file.cc
@@ -34,9 +34,8 @@ namespace InputXSLT {
xercesc::DOMDocument* FunctionReadXmlFile::constructDocument(
const FilesystemContext& fsContext,
- const FunctionBase::parameter_tuple& parameters
+ std::string rawPath
) {
- const std::string& rawPath = std::get<0>(parameters);
boost::filesystem::path filePath(fsContext.resolve(rawPath));
if ( !(boost::filesystem::exists(filePath) &&
diff --git a/src/function/read_xml_file.h b/src/function/read_xml_file.h
index 6061257..7fe949a 100644
--- a/src/function/read_xml_file.h
+++ b/src/function/read_xml_file.h
@@ -17,7 +17,7 @@ class FunctionReadXmlFile : public FunctionBase<
xercesc::DOMDocument* constructDocument(
const FilesystemContext&,
- const FunctionBase::parameter_tuple&
+ std::string
);
};
diff --git a/src/function/transform.cc b/src/function/transform.cc
index 844dee9..7e6207c 100644
--- a/src/function/transform.cc
+++ b/src/function/transform.cc
@@ -30,19 +30,12 @@ namespace InputXSLT {
xercesc::DOMDocument* FunctionTransform::constructDocument(
const InputXSLT::FilesystemContext& fsContext,
- const FunctionBase::parameter_tuple& parameters
+ std::string transformationPath,
+ std::string targetPath,
+ xalan::XObjectPtr parameterObject
) {
- const std::string transformationPath(
- fsContext.resolve(std::get<0>(parameters)).string()
- );
-
- const std::string targetPath(
- fsContext.resolve(std::get<1>(parameters)).string()
- );
-
- const xalan::XObjectPtr& parameterObject(
- std::get<2>(parameters)
- );
+ transformationPath = fsContext.resolve(transformationPath).string();
+ targetPath = fsContext.resolve(targetPath).string();
xercesc::DOMDocument* const domDocument(
xercesc::DOMImplementation::getImplementation()->createDocument(
diff --git a/src/function/transform.h b/src/function/transform.h
index 810738e..b841750 100644
--- a/src/function/transform.h
+++ b/src/function/transform.h
@@ -19,7 +19,9 @@ class FunctionTransform : public FunctionBase<
xercesc::DOMDocument* constructDocument(
const FilesystemContext&,
- const FunctionBase::parameter_tuple&
+ std::string,
+ std::string,
+ xalan::XObjectPtr
);
};