Xalan-C++ API Reference  1.12.0
XPathEnvSupportDefault.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(XPATHENVSUPPORTDEFAULT_HEADER_GUARD_1357924680)
19 #define XPATHENVSUPPORTDEFAULT_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base include file. Must be first.
26 
27 
28 
30 
31 
32 
34 
35 
36 
37 namespace XALAN_CPP_NAMESPACE {
38 
39 
40 
43 
44 
45 
47 {
48 public:
49 
53 
54  /**
55  * Perform initialization of statics -- must be called before any
56  * processing occurs. See class XPathInit.
57  */
58  static void
59  initialize(MemoryManager& theManager);
60 
61  /**
62  * Perform termination of statics. See class XPathInit.
63  */
64  static void
65  terminate();
66 
67 
68  XPathEnvSupportDefault(MemoryManager& theManager XALAN_DEFAULT_MEMMGR);
69 
70  virtual
72 
73  MemoryManager&
75  {
76  return m_memoryManager;
77  }
78 
79  virtual void
80  setPrintWriter(PrintWriter* pw);
81 
82  virtual void
83  problem(
84  eSource source,
85  eClassification classification,
86  const XalanDOMString& msg,
87  const Locator* locator,
88  const XalanNode* sourceNode);
89 
90  virtual void
91  problem(
92  eSource source,
93  eClassification classification,
94  const XalanDOMString& msg,
95  const XalanNode* sourceNode);
96 
97  // Interfaces to install and uninstall external functions globally.
98  // These calls are not thread-safe, and should happen during
99  // processing.
100 
101  /**
102  * Install an external function in the global space.
103  *
104  * @param theNamespace The namespace for the functionl
105  * @param functionName The name of the function.
106  * @param function The function to install.
107  */
108  static void
109  installExternalFunctionGlobal(
110  const XalanDOMString& theNamespace,
111  const XalanDOMString& functionName,
112  const Function& function);
113 
114  /**
115  * Uninstall an external function from the global space.
116  *
117  * @param theNamespace The namespace for the functionl
118  * @param functionName The name of the function.
119  */
120  static void
121  uninstallExternalFunctionGlobal(
122  const XalanDOMString& theNamespace,
123  const XalanDOMString& functionName);
124 
125  // Interfaces to install and uninstall external functions in this instance.
126 
127  /**
128  * Install an external function in the local space.
129  *
130  * @param theNamespace The namespace for the functionl
131  * @param functionName The name of the function.
132  * @param function The function to install.
133  */
134  virtual void
135  installExternalFunctionLocal(
136  const XalanDOMString& theNamespace,
137  const XalanDOMString& functionName,
138  const Function& function);
139 
140  /**
141  * Uninstall an external function from the local space.
142  *
143  * @param theNamespace The namespace for the functionl
144  * @param functionName The name of the function.
145  */
146  virtual void
147  uninstallExternalFunctionLocal(
148  const XalanDOMString& theNamespace,
149  const XalanDOMString& functionName);
150 
151 
152  // These interfaces are inherited from XPathEnvSupport...
153 
154  virtual XalanDocument*
155  parseXML(
156  MemoryManager& theManager,
157  const XalanDOMString& urlString,
158  const XalanDOMString& base,
159  ErrorHandler* theErrorHandler = 0);
160 
161  virtual XalanDocument*
162  getSourceDocument(const XalanDOMString& theURI) const;
163 
164  virtual void
165  setSourceDocument(
166  const XalanDOMString& theURI,
167  XalanDocument* theDocument);
168 
169  virtual const XalanDOMString&
170  findURIFromDoc(const XalanDocument* owner) const;
171 
172  virtual bool
173  elementAvailable(
174  const XalanDOMString& theNamespace,
175  const XalanDOMString& elementName) const;
176 
177  virtual bool
178  functionAvailable(
179  const XalanDOMString& theNamespace,
180  const XalanDOMString& functionName) const;
181 
182  virtual XObjectPtr
183  extFunction(
184  XPathExecutionContext& executionContext,
185  const XalanDOMString& theNamespace,
186  const XalanDOMString& functionName,
187  XalanNode* context,
188  const XObjectArgVectorType& argVec,
189  const Locator* locator) const;
190 
191  virtual void
192  reset();
193 
194  // Delete functor for table cleanup...
196  {
199 
200  NamespaceFunctionTableDeleteFunctor(MemoryManager& theManager);
201  /**
202  * Delete the value object in a map value pair. The value of the pair must
203  * be of pointer type.
204  *
205  * @param thePair key-value pair
206  */
207  void
208  operator()(const NamespaceFunctionTablesInnerType::value_type& thePair) const;
209 
210  private:
211 
212  MemoryManager& m_memoryManager;
213  };
214 
215 protected:
216 
217  /**
218  * Find an external function.
219  *
220  * @param theNamespace The namespace for the function.
221  * @param functionName The name of the function.
222  * @return a pointer to the function if found, or 0 if not found.
223  */
224  const Function*
225  findFunction(
226  const XalanDOMString& theNamespace,
227  const XalanDOMString& functionName) const;
228 
229 private:
230 
231  // These are not implemented...
233 
235  operator=(const XPathEnvSupportDefault&);
236 
237  bool
238  operator==(const XPathEnvSupportDefault&) const;
239 
240  /**
241  * Update the supplied function table. If the parameter
242  * function is 0, and a function with the supplied
243  * namespace and name exists in the table, it will be
244  * removed. If function is not 0, and a function with
245  * the supplied namespace and name exists in the table,
246  * it will be replaced with the new function. Otherwise,
247  * the function will be added.
248  *
249  * @param theNamespace The namespace for the functionl
250  * @param functionName The name of the function.
251  * @param function The function to install.
252  */
253  static void
254  updateFunctionTable(
255  NamespaceFunctionTablesType& theTable,
256  const XalanDOMString& theNamespace,
257  const XalanDOMString& functionName,
258  const Function* function);
259 
260  /**
261  * Find an external function in the supplied table.
262  *
263  * @param theTable The table to search.
264  * @param theNamespace The namespace for the function.
265  * @param functionName The name of the function.
266  * @return a pointer to the function if found, or 0 if not found.
267  */
268  const Function*
269  findFunction(
270  const NamespaceFunctionTablesType& theTable,
271  const XalanDOMString& theNamespace,
272  const XalanDOMString& functionName) const;
273 
274  // Data members...
275 
276  SourceDocsTableType m_sourceDocs;
277 
278  NamespaceFunctionTablesType m_externalFunctions;
279 
280  MemoryManager& m_memoryManager;
281 
282  PrintWriter* m_pw;
283 
284  static NamespaceFunctionTablesType s_externalFunctions;
285 
286  static const XalanDOMString s_emptyString;
287 };
288 
289 }
290 
291 
292 
293 #endif // XPATHENVSUPPORTDEFAULT_HEADER_GUARD_1357924680
xalanc::XPathEnvSupportDefault::NamespaceFunctionTablesType
XalanMap< XalanDOMString, FunctionTableType > NamespaceFunctionTablesType
Definition: XPathEnvSupportDefault.hpp:52
xalanc::FunctionTableTypeDefinition
XalanMap< XalanDOMString, const Function * > FunctionTableTypeDefinition
Definition: XPathEnvSupportDefault.hpp:41
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::XPathEnvSupportDefault::NamespaceFunctionTableDeleteFunctor::FunctionTableInnerType
FunctionTableType FunctionTableInnerType
Definition: XPathEnvSupportDefault.hpp:197
XPathEnvSupport.hpp
XALAN_USES_MEMORY_MANAGER
#define XALAN_USES_MEMORY_MANAGER(Type)
Definition: XalanMemoryManagement.hpp:589
xalanc::XalanDocument
Definition: XalanDocument.hpp:36
XALAN_DEFAULT_MEMMGR
#define XALAN_DEFAULT_MEMMGR
Definition: XalanMemoryManagement.hpp:516
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::XPathEnvSupportDefault::SourceDocsTableType
XalanMap< XalanDOMString, XalanDocument * > SourceDocsTableType
Definition: XPathEnvSupportDefault.hpp:50
xalanc::XObjectPtr
Class to hold XObjectPtr return types.
Definition: XObject.hpp:883
xalanc::XPathEnvSupportDefault::NamespaceFunctionTableDeleteFunctor::NamespaceFunctionTablesInnerType
NamespaceFunctionTablesType NamespaceFunctionTablesInnerType
Definition: XPathEnvSupportDefault.hpp:198
xalanc::XPathEnvSupportDefault::getMemoryManager
MemoryManager & getMemoryManager() const
Definition: XPathEnvSupportDefault.hpp:74
DOMStringHelper.hpp
xalanc::XPathEnvSupportDefault::NamespaceFunctionTableDeleteFunctor
Definition: XPathEnvSupportDefault.hpp:195
xalanc::Function
Definition: Function.hpp:57
xalanc::PrintWriter
Definition: PrintWriter.hpp:37
xalanc::XalanMap
Xalan implementation of a hashtable.
Definition: XalanMap.hpp:186
XalanMap.hpp
xalanc::XPathEnvSupportDefault
Definition: XPathEnvSupportDefault.hpp:46
xalanc::XPathEnvSupport
Definition: XPathEnvSupport.hpp:60
xalanc::XPathExecutionContext
Definition: XPathExecutionContext.hpp:82
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
xalanc::XalanMap< XalanDOMString, FunctionTableType >::value_type
std::pair< const key_type, data_type > value_type
Definition: XalanMap.hpp:201
XPathDefinitions.hpp
xalanc::XPathEnvSupportDefault::FunctionTableType
FunctionTableTypeDefinition FunctionTableType
Definition: XPathEnvSupportDefault.hpp:51