From f6ff54c492df81018cf48da039ee681508f88e46 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 16 Aug 2014 23:30:36 +0200 Subject: Implemented primitive optional parameter support for external functions * renamed FunctionExternalTextFormatter into FunctionExternalCommand ** the goal is to provide a general interface to a variety of external commands *** e.g. not just text formatters but system utilities for file management and so on ** this requires the stdin parameter to be optional as not all external commands require stdin input * implemented "filter_derived" helper template to determine amount of optional parameters ** optional parameters are defined as "boost::optional" specializations *** they in turn can be detected by checking if "boost::optional_detail::optional_tag" is a base class * "callConstructDocument" member method of "FunctionBase" performs additional bounds checking of parameter vector * "boost::optional" specific member overload was added to "XObjectValue" helper class ** we will have to provide full specializations for all optional types as C++ prohibits partial member function template specialization * renamed the external function in "PlattformGuard" * changed README.md and test cases accordingly --- src/support/filesystem_context.h | 2 +- src/support/include_entity_resolver.cc | 2 +- src/support/include_entity_resolver.h | 2 +- src/support/type/filter.h | 24 ++++++++++++++++++++++++ src/support/type/xobject_value.cc | 13 ++++++++++++- 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 src/support/type/filter.h (limited to 'src/support') diff --git a/src/support/filesystem_context.h b/src/support/filesystem_context.h index f3875a3..c00fe29 100644 --- a/src/support/filesystem_context.h +++ b/src/support/filesystem_context.h @@ -4,7 +4,7 @@ #include #include -#include "boost/filesystem.hpp" +#include #include #include diff --git a/src/support/include_entity_resolver.cc b/src/support/include_entity_resolver.cc index deac1d5..197b217 100644 --- a/src/support/include_entity_resolver.cc +++ b/src/support/include_entity_resolver.cc @@ -2,7 +2,7 @@ #include -#include "boost/filesystem.hpp" +#include #include "support/xalan_string.h" #include "support/xerces_string_guard.h" diff --git a/src/support/include_entity_resolver.h b/src/support/include_entity_resolver.h index ea5fb7a..e7c5542 100644 --- a/src/support/include_entity_resolver.h +++ b/src/support/include_entity_resolver.h @@ -4,7 +4,7 @@ #include #include -#include "boost/optional.hpp" +#include #include #include diff --git a/src/support/type/filter.h b/src/support/type/filter.h new file mode 100644 index 0000000..4a0e19f --- /dev/null +++ b/src/support/type/filter.h @@ -0,0 +1,24 @@ +#ifndef INPUTXSLT_SRC_SUPPORT_TYPE_FILTER_H_ +#define INPUTXSLT_SRC_SUPPORT_TYPE_FILTER_H_ + +#include +#include + +namespace InputXSLT { + +template < + typename BaseReference, + typename Head, + typename... Tail +> +struct filter_derived { + typedef typename std::conditional< + std::is_base_of::value, + std::tuple, + std::tuple + >::type type; +}; + +} + +#endif // INPUTXSLT_SRC_SUPPORT_TYPE_FILTER_H_ diff --git a/src/support/type/xobject_value.cc b/src/support/type/xobject_value.cc index 9bb6648..e457a69 100644 --- a/src/support/type/xobject_value.cc +++ b/src/support/type/xobject_value.cc @@ -4,7 +4,8 @@ #include #include -#include "boost/filesystem.hpp" +#include +#include #include @@ -26,6 +27,16 @@ std::string XObjectValue::get( return boost::trim_copy(toString(ptr->str())); } +template <> +boost::optional XObjectValue::get>( + const xalan::XObjectPtr& ptr) const { + if ( ptr.null() ) { + return boost::optional(); + } else { + return this->get(ptr); + } +} + template <> boost::filesystem::path XObjectValue::get( const xalan::XObjectPtr& ptr) const { -- cgit v1.2.3