2020-02-17 22:05:20 +01:00
/*
2020-02-17 22:13:50 +01:00
* Copyright ( c ) 2001 - 2008
2020-02-17 22:05:20 +01:00
* DecisionSoft Limited . All rights reserved .
2020-02-17 22:13:50 +01:00
* Copyright ( c ) 2004 - 2008
2020-02-17 22:05:20 +01:00
* Oracle . All rights reserved .
*
2020-02-17 22:12:51 +01:00
* Licensed under the Apache License , Version 2.0 ( the " License " ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
2020-02-17 22:05:20 +01:00
*
2020-02-17 22:12:51 +01:00
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an " AS IS " BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
*
2020-02-17 22:14:54 +01:00
* $ Id : XQFunction . hpp 475 2008 - 01 - 08 18 : 47 : 44 Z jpcs $
2020-02-17 22:05:20 +01:00
*/
# ifndef _XQFUNCTION_HPP
# define _XQFUNCTION_HPP
# include <xqilla/framework/XQillaExport.hpp>
# include <xqilla/ast/ASTNodeImpl.hpp>
# include <xqilla/runtime/Sequence.hpp>
# include <xqilla/items/ATStringOrDerived.hpp>
# include <xqilla/context/ItemFactory.hpp>
# include <xercesc/util/XMLUniDefs.hpp> // because every implementation will use these to define the function name
# include <vector>
class SequenceType ;
class XQILLA_API XQFunction : public ASTNodeImpl
{
public :
2020-02-17 22:12:51 +01:00
XQFunction ( const XMLCh * name , size_t argsFrom , size_t argsTo , const char * paramDecl , const VectorOfASTNodes & args , XPath2MemoryManager * memMgr ) ;
2020-02-17 22:05:20 +01:00
virtual ~ XQFunction ( ) ;
const XMLCh * getFunctionURI ( ) const ;
const XMLCh * getFunctionName ( ) const ;
const XMLCh * getFunctionSignature ( ) const ;
const VectorOfASTNodes & getArguments ( ) const ;
static const XMLCh XMLChFunctionURI [ ] ;
/** Wraps the arguments in the appropriate conversion functions,
calls static resolution on them , and constant folds if
2020-02-17 22:11:31 +01:00
this function ' s StaticAnalysis is not used */
2020-02-17 22:05:20 +01:00
ASTNode * resolveArguments ( StaticContext * context , bool checkTimezone = false , bool numericFunction = false ) ;
ASTNode * calculateSRCForArguments ( StaticContext * context , bool checkTimezone = false , bool numericFunction = false ) ;
/** casts the expression given as a parameter into the appropriate type and returns the guaranteed correctly typed objects in a sequence */
2020-02-17 22:12:51 +01:00
virtual Result getParamNumber ( size_t number , DynamicContext * context , int flags = 0 ) const ;
2020-02-17 22:05:20 +01:00
/** returns the number of parameters passed into the function */
2020-02-17 22:12:51 +01:00
size_t getNumArgs ( ) const ;
2020-02-17 22:05:20 +01:00
protected :
/** Helper method, produces a single ATStringOrDerived from the output of getParamNumber(). If getParamNumber() returns anything other than a single string, an exception is thrown. */
2020-02-17 22:12:51 +01:00
static const size_t UNLIMITED ;
2020-02-17 22:05:20 +01:00
//parse the supplied string of comma separated arguments into vector of SequenceTypes
2020-02-17 22:08:05 +01:00
void parseParamDecl ( const char * paramString , XPath2MemoryManager * mm ) ;
2020-02-17 22:05:20 +01:00
const XMLCh * _fName , * _fURI , * _signature ;
2020-02-17 22:12:51 +01:00
const size_t _nArgsFrom , _nArgsTo ;
2020-02-17 22:05:20 +01:00
2020-02-17 22:08:05 +01:00
std : : vector < SequenceType * , XQillaAllocator < SequenceType * > > _paramDecl ;
2020-02-17 22:05:20 +01:00
VectorOfASTNodes _args ; // The real store for arguments
} ;
# endif