diff options
author | Adrian Kummerlaender | 2014-08-17 13:32:22 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2014-08-17 13:32:22 +0200 |
commit | 8ed33c3e9e2648a5a0150c05e06c228336e9e9d6 (patch) | |
tree | e6be3688300dfe4d046b8f84c5907d82b282b942 /src/function | |
parent | f6ff54c492df81018cf48da039ee681508f88e46 (diff) | |
download | InputXSLT-8ed33c3e9e2648a5a0150c05e06c228336e9e9d6.tar InputXSLT-8ed33c3e9e2648a5a0150c05e06c228336e9e9d6.tar.gz InputXSLT-8ed33c3e9e2648a5a0150c05e06c228336e9e9d6.tar.bz2 InputXSLT-8ed33c3e9e2648a5a0150c05e06c228336e9e9d6.tar.lz InputXSLT-8ed33c3e9e2648a5a0150c05e06c228336e9e9d6.tar.xz InputXSLT-8ed33c3e9e2648a5a0150c05e06c228336e9e9d6.tar.zst InputXSLT-8ed33c3e9e2648a5a0150c05e06c228336e9e9d6.zip |
Fixed minimum parameter count calculation
* the minimum count of parameters to a external function is the maximum parameter count minus all optional parameters
* updated error message of "FunctionBase" member method "getError" to reflect the newly implemented possibility of optional parameters
Diffstat (limited to 'src/function')
-rw-r--r-- | src/function/base.h | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/src/function/base.h b/src/function/base.h index a8f93b9..3726aa8 100644 --- a/src/function/base.h +++ b/src/function/base.h @@ -26,8 +26,9 @@ template < typename... Types > class FunctionBase : public xalan::Function { - static const std::size_t parameter_count = sizeof...(Types); - static const std::size_t optional_parameter_count = std::tuple_size< + static const std::size_t maximum_parameter_count = sizeof...(Types); + static const std::size_t minimum_parameter_count = maximum_parameter_count + - std::tuple_size< typename filter_derived< boost::optional_detail::optional_tag, Types... @@ -56,7 +57,7 @@ class FunctionBase : public xalan::Function { this->callConstructDocument( parameters, locator, - typename IndexSequence<parameter_count>::type() + typename IndexSequence<maximum_parameter_count>::type() ) ); @@ -90,11 +91,25 @@ class FunctionBase : public xalan::Function { const xalan::XalanDOMString& getError( xalan::XalanDOMString& result) const { - result.assign(std::string( - "The function expects " + - std::to_string(parameter_count) + - " parameter(s)" - ).data()); + const std::string startText("The function expects "); + const std::string endText(" parameter(s)"); + + if ( minimum_parameter_count == maximum_parameter_count ) { + result.assign(std::string( + startText + + std::to_string(minimum_parameter_count) + + endText + ).data()); + } else { + result.assign(std::string( + startText + + "between " + + std::to_string(minimum_parameter_count) + + " and " + + std::to_string(maximum_parameter_count) + + endText + ).data()); + } return result; } @@ -140,8 +155,8 @@ class FunctionBase : public xalan::Function { } ); - if ( parameters.size() > parameter_count || - parameters.size() < optional_parameter_count || + if ( parameters.size() > maximum_parameter_count || + parameters.size() < minimum_parameter_count || anyNull ) { xalan::XPathExecutionContext::GetAndReleaseCachedString guard( executionContext |