diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/function/base.h | 55 | ||||
-rw-r--r-- | src/function/external_text_formatter.cc | 11 | ||||
-rw-r--r-- | src/function/external_text_formatter.h | 3 | ||||
-rw-r--r-- | src/function/read_directory.cc | 4 | ||||
-rw-r--r-- | src/function/read_directory.h | 2 | ||||
-rw-r--r-- | src/function/read_file.cc | 3 | ||||
-rw-r--r-- | src/function/read_file.h | 2 | ||||
-rw-r--r-- | src/function/read_xml_file.cc | 3 | ||||
-rw-r--r-- | src/function/read_xml_file.h | 2 | ||||
-rw-r--r-- | src/function/transform.cc | 17 | ||||
-rw-r--r-- | src/function/transform.h | 4 | ||||
-rw-r--r-- | src/support/tuple/mapper.h | 62 | ||||
-rw-r--r-- | src/support/type/xobject_value.cc (renamed from src/support/tuple/xobject_value.cc) | 0 | ||||
-rw-r--r-- | src/support/type/xobject_value.h (renamed from src/support/tuple/xobject_value.h) | 0 |
14 files changed, 55 insertions, 113 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 ); }; diff --git a/src/support/tuple/mapper.h b/src/support/tuple/mapper.h deleted file mode 100644 index 28c5f3b..0000000 --- a/src/support/tuple/mapper.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef INPUTXSLT_SRC_SUPPORT_TUPLE_MAPPER_H_ -#define INPUTXSLT_SRC_SUPPORT_TUPLE_MAPPER_H_ - -#include <xalanc/XPath/XObject.hpp> - -#include <tuple> -#include <type_traits> - -#include "common.h" -#include "xobject_value.h" - -namespace InputXSLT { - -template <bool Condition> -using enable_if = typename std::enable_if<Condition, std::size_t>::type; - -namespace Mapper { - template < - typename Target, - std::size_t Index = 0, - typename Current = std::tuple<>, - enable_if<Index == std::tuple_size<Target>::value> = 0 - > - inline Target construct( - const xalan::XPathExecutionContext::XObjectArgVectorType&, - Current&& current - ) { - return current; - } - - template < - typename Target, - std::size_t Index = 0, - typename Current = std::tuple<>, - enable_if<Index < std::tuple_size<Target>::value> = 0 - > - inline Target construct( - const xalan::XPathExecutionContext::XObjectArgVectorType& source, - Current&& current = std::tuple<>() - ) { - return construct< - Target, - Index + 1 - >( - source, - std::tuple_cat( - current, - std::make_tuple( - XObjectValue::get< - typename std::tuple_element<Index, Target>::type - >( - source[Index] - ) - ) - ) - ); - } -} - -} - -#endif // INPUTXSLT_SRC_SUPPORT_TUPLE_MAPPER_H_ diff --git a/src/support/tuple/xobject_value.cc b/src/support/type/xobject_value.cc index cdeb9c6..cdeb9c6 100644 --- a/src/support/tuple/xobject_value.cc +++ b/src/support/type/xobject_value.cc diff --git a/src/support/tuple/xobject_value.h b/src/support/type/xobject_value.h index bb602a4..bb602a4 100644 --- a/src/support/tuple/xobject_value.h +++ b/src/support/type/xobject_value.h |