Xalan-C++ API Reference  1.12.0
Function.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #if !defined(FUNCTION_HEADER_GUARD_1357924680)
19 #define FUNCTION_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base header file. Must be first.
25 
27 
28 
29 #include <vector>
30 
31 
32 
33 #include <xalanc/XPath/XObject.hpp>
35 
36 
37 namespace XERCES_CPP_NAMESPACE
38 {
39  class Locator;
40 }
41 
42 
43 
44 namespace XALAN_CPP_NAMESPACE {
45 
46 
47 
48 class XalanNode;
49 
50 
51 
52 // Base class for all XPath function classes.
53 //
54 // These are all inline, even though
55 // there are virtual functions, because we expect that they will only be
56 // needed by the XPath class.
58 {
59 public:
60 
61  typedef xercesc::Locator LocatorType;
62 
63  explicit
64  Function();
65 
66  virtual
67  ~Function();
68 
72 
73  /**
74  * Execute an XPath function object. The function must return a valid
75  * object. Extension functions should override this version of execute(),
76  * rather than one of the other calls designed for a specific number of
77  * arguments, since the extension function mechanism will call this
78  * version first. Extension functions that accept more than three
79  * arguments _must_ override this version.
80  *
81  * @param executionContext executing context
82  * @param context current context node
83  * @param args vector of pointers to XObject arguments
84  * @param locator Locator instance for the XPath expression that contains the function call
85  * @return pointer to the result XObject
86  */
87  virtual XObjectPtr
88  execute(
89  XPathExecutionContext& executionContext,
90  XalanNode* context,
91  const XObjectArgVectorType& args,
92  const Locator* locator) const;
93 
94  /**
95  * Execute an XPath function object. The function must return a valid
96  * object. Called if function has no parameters.
97  *
98  * @param executionContext executing context
99  * @param context current context node
100  * @param locator Locator instance for the XPath expression that contains the function call
101  * @return pointer to the result XObject
102  */
103  virtual XObjectPtr
104  execute(
105  XPathExecutionContext& executionContext,
106  XalanNode* context,
107  const Locator* locator) const;
108 
109  /**
110  * Execute an XPath function object. The function must return a valid
111  * object. Called if function has one parameter.
112  *
113  * @param executionContext executing context
114  * @param context current context node
115  * @param arg pointer to XObject argument
116  * @param locator Locator instance for the XPath expression that contains the function call
117  * @return pointer to the result XObject
118  */
119  virtual XObjectPtr
120  execute(
121  XPathExecutionContext& executionContext,
122  XalanNode* context,
123  const XObjectPtr arg,
124  const Locator* locator) const;
125 
126  /**
127  * Execute an XPath function object. The function must return a valid
128  * object. Called if function has two parameters.
129  *
130  * @param executionContext executing context
131  * @param context current context node
132  * @param arg1 pointer to XObject argument
133  * @param arg2 pointer to XObject argument
134  * @param locator Locator instance for the XPath expression that contains the function call
135  * @return pointer to the result XObject
136  */
137  virtual XObjectPtr
138  execute(
139  XPathExecutionContext& executionContext,
140  XalanNode* context,
141  const XObjectPtr arg1,
142  const XObjectPtr arg2,
143  const Locator* locator) const;
144 
145  /**
146  * Execute an XPath function object. The function must return a valid
147  * object. Called if function has three parameters.
148  *
149  * @param executionContext executing context
150  * @param context current context node
151  * @param arg1 pointer to XObject arguments
152  * @param arg2 pointer to XObject argument
153  * @param arg3 pointer to XObject argument
154  * @param locator Locator instance for the XPath expression that contains the function call
155  * @return pointer to the result XObject
156  */
157  virtual XObjectPtr
158  execute(
159  XPathExecutionContext& executionContext,
160  XalanNode* context,
161  const XObjectPtr arg1,
162  const XObjectPtr arg2,
163  const XObjectPtr arg3,
164  const Locator* locator) const;
165 
166  /**
167  * Create a copy of the function object.
168  *
169  * @return pointer to the new object
170  */
171  virtual Function*
172  clone(MemoryManager& theManager) const = 0;
173 
174 protected:
175 
176  /**
177  * Get the error message to report when
178  * the function is called with the wrong
179  * number of arguments.
180  *
181  * @param theBuffer The XalanDOMString for the message.
182  * @return The error message
183  */
184  virtual const XalanDOMString&
185  getError(XalanDOMString& theBuffer) const = 0;
186 
187  /**
188  * Report the error returned from the getError()
189  * call.
190  *
191  * @param executionContext The current XPathExecutionContext
192  * @param context The context node
193  * @param locator The Locator instance for the XPath expression that contains the function call
194  */
195  void
196  generalError(
197  XPathExecutionContext& executionContext,
198  const XalanNode* context,
199  const Locator* locator) const;
200 
201 private:
202 
203  // Not implemented...
204  Function&
205  operator=(const Function&);
206 
207  bool
208  operator==(const Function&) const;
209 };
210 
211 
212 
213 }
214 
215 
216 
217 #endif // FUNCTION_HEADER_GUARD_1357924680
xalanc::Function::GetCachedNodeList
XPathExecutionContext::GetCachedNodeList GetCachedNodeList
Definition: Function.hpp:71
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::XalanNode
Definition: XalanNode.hpp:38
xalanc::XPathExecutionContext::GetCachedNodeList
Definition: XPathExecutionContext.hpp:335
xalanc::XalanVector< XObjectPtr >
xalanc::Function::LocatorType
xercesc::Locator LocatorType
Definition: Function.hpp:61
xalanc::Function::XObjectArgVectorType
XPathExecutionContext::XObjectArgVectorType XObjectArgVectorType
Definition: Function.hpp:69
xalanc::operator==
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1118
XALAN_XPATH_EXPORT
#define XALAN_XPATH_EXPORT
Definition: XPathDefinitions.hpp:35
xalanc::XObjectPtr
Class to hold XObjectPtr return types.
Definition: XObject.hpp:883
xalanc::Function
Definition: Function.hpp:57
xalanc::XPathExecutionContext::GetCachedString
Definition: XPathExecutionContext.hpp:448
XPathExecutionContext.hpp
xalanc::Function::GetCachedString
XPathExecutionContext::GetCachedString GetCachedString
Definition: Function.hpp:70
xalanc::XPathExecutionContext
Definition: XPathExecutionContext.hpp:82
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
XObject.hpp
XPathDefinitions.hpp
XalanMemMgrAutoPtr.hpp