From ec6abad74348e9b577e1dd63b41d65263bb0334a Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Thu, 15 May 2014 17:23:13 +0200 Subject: Adapted FunctionBase template to accept multiple argument types * FunctionBase::argument_tuple is a std::tuple specialization type specialized on the argument types passed inside the variadic template argument of FunctionBase * added tuple Mapper and XObjectValue helper namespaces containing recursive tuple construction and XObjectPtr value extraction logic * changed all external function implementations accordingly * this change was implemented to uniformly support different external function argument types than std::string --- src/support/tuple/mapper.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/support/tuple/mapper.h (limited to 'src/support/tuple/mapper.h') diff --git a/src/support/tuple/mapper.h b/src/support/tuple/mapper.h new file mode 100644 index 0000000..c95365e --- /dev/null +++ b/src/support/tuple/mapper.h @@ -0,0 +1,62 @@ +#ifndef INPUTXSLT_SRC_SUPPORT_TUPLE_MAPPER_H_ +#define INPUTXSLT_SRC_SUPPORT_TUPLE_MAPPER_H_ + +#include + +#include +#include + +#include "common.h" +#include "xobject_value.h" + +namespace InputXSLT { + +template +using enable_if = typename std::enable_if::type; + +namespace Mapper { + template < + typename Target, + std::size_t Index = 0, + typename Current = std::tuple<>, + enable_if::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::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::type + >( + source[Index] + ) + ) + ) + ); + } +}; + +} + +#endif // INPUTXSLT_SRC_SUPPORT_TUPLE_MAPPER_H_ -- cgit v1.2.3