XQuilla/include/xqilla/functions/FunctionLookup.hpp

86 lines
2.9 KiB
C++
Raw Normal View History

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: FunctionLookup.hpp 476 2008-01-11 15:48:49Z jpcs $
2020-02-17 22:05:20 +01:00
*/
#ifndef _FLOOKUP_HPP
#define _FLOOKUP_HPP
#include <xqilla/framework/XQillaExport.hpp>
#include <vector>
#include <xercesc/util/XercesDefs.hpp>
2020-02-17 22:11:31 +01:00
#include <xercesc/util/RefHash2KeysTableOf.hpp>
2020-02-17 22:05:20 +01:00
#include <xqilla/ast/ASTNode.hpp>
class FuncFactory;
class XPath2MemoryManager;
2020-02-17 22:11:31 +01:00
class ExternalFunction;
2020-02-17 22:13:50 +01:00
class DynamicContext;
2020-02-17 22:05:20 +01:00
class XQILLA_API FunctionLookup
{
public:
2020-02-17 22:11:31 +01:00
FunctionLookup(XPath2MemoryManager* memMgr);
~FunctionLookup();
2020-02-17 22:05:20 +01:00
///adds a function to the custom function table
2020-02-17 22:11:31 +01:00
void insertFunction(FuncFactory *func);
2020-02-17 22:05:20 +01:00
/// replaces the implementation of an existing function
2020-02-17 22:11:31 +01:00
void replaceFunction(FuncFactory *func);
2020-02-17 22:05:20 +01:00
///returns the approriate Function object
2020-02-17 22:11:31 +01:00
ASTNode* lookUpFunction(const XMLCh* URI, const XMLCh* fname,
const VectorOfASTNodes &args,
XPath2MemoryManager* memMgr) const;
2020-02-17 22:05:20 +01:00
2020-02-17 22:11:31 +01:00
///adds a function to the external function table
void insertExternalFunction(const ExternalFunction *func);
///returns the approriate ExternalFunction object
const ExternalFunction *lookUpExternalFunction(const XMLCh* URI,
const XMLCh* fname,
2020-02-17 22:12:51 +01:00
size_t numArgs) const;
2020-02-17 22:13:50 +01:00
void copyExternalFunctionsTo(DynamicContext *context) const;
2020-02-17 22:11:31 +01:00
void insertUpdateFunctions(XPath2MemoryManager *memMgr);
private:
XERCES_CPP_NAMESPACE_QUALIFIER RefHash2KeysTableOf< FuncFactory > _funcTable;
XERCES_CPP_NAMESPACE_QUALIFIER RefHash2KeysTableOf< const ExternalFunction > _exFuncTable;
public:
// static (global table interfaces)
static void insertGlobalFunction(FuncFactory *func);
static void insertGlobalExternalFunction(const ExternalFunction *func);
// next two look in global table first, then the contextTable
static ASTNode* lookUpGlobalFunction(const XMLCh* URI, const XMLCh* fname,
const VectorOfASTNodes &args,
XPath2MemoryManager* memMgr,
const FunctionLookup *contextTable);
static const ExternalFunction *lookUpGlobalExternalFunction(
2020-02-17 22:12:51 +01:00
const XMLCh* URI, const XMLCh* fname, size_t numArgs,
2020-02-17 22:11:31 +01:00
const FunctionLookup *contextTable);
static void initialize();
static void terminate();
private:
static FunctionLookup *g_globalFunctionTable;
static XPath2MemoryManager *g_memMgr;
2020-02-17 22:05:20 +01:00
};
#endif