aboutsummaryrefslogtreecommitdiff
path: root/src/support/tuple/mapper.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/support/tuple/mapper.h')
-rw-r--r--src/support/tuple/mapper.h62
1 files changed, 62 insertions, 0 deletions
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 <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_