Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

XPathFunctionTable.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #if !defined(XPATHFUNCTIONTABLE_HEADER_GUARD_1357924680)
17 #define XPATHFUNCTIONTABLE_HEADER_GUARD_1357924680
18 
19 
20 
21 // Base include file. Must be first.
23 
24 
25 
26 #include <algorithm>
27 
28 
29 
31 
32 
33 
35 
36 
37 
40 
41 
42 
43 XALAN_CPP_NAMESPACE_BEGIN
44 
45 
46 
51 {
52 public:
53 
55 
56  XPathExceptionFunctionNotAvailable(const XalanDOMString& theFunctionNumber,
57  XalanDOMString& theResult);
58 
60  const XalanDOMString& theFunctionNumber,
61  const LocatorType& theLocator,
62  XalanDOMString& theResult);
63 
65 };
66 
67 
68 
74 {
75 public:
76 
77  XPathExceptionFunctionNotSupported(const XalanDOMChar* theFunctionName,
78  XalanDOMString& theResult);
79 
81 };
82 
83 
84 
89 {
90 public:
91 
92  enum { InvalidFunctionNumberID = -1, TableSize = 36 };
93 
94  typedef size_t SizeType;
97 
103  XPathFunctionTable(bool fCreateTable = true);
104 
106 
107  void
109  {
110  m_memoryManager = &theManager;
111  }
115  void
116  CreateTable();
117 
121  void
122  DestroyTable();
123 
130  const Function&
131  operator[](const XalanDOMString& theFunctionName) const
132  {
133  const int theFunctionID =
134  getFunctionIndex(theFunctionName);
135 
136  if (theFunctionID != InvalidFunctionNumberID)
137  {
138  return *m_functionTable[theFunctionID];
139  }
140  else
141  {
142  MemoryManagerType* theManager = const_cast<MemoryManagerType*>(m_memoryManager);
143 
144  XalanDOMString theResult(*theManager);
145 
146  throw XPathExceptionFunctionNotAvailable(theFunctionName, theResult);
147  }
148  }
149 
156  const Function&
157  operator[](int theFunctionID) const
158  {
159  assert(theFunctionID >= 0 && theFunctionID < TableSize);
160  assert(m_functionTable[theFunctionID] != 0);
161 
162  return *m_functionTable[theFunctionID];
163  }
164 
171  const XalanDOMString&
172  idToName(int theFunctionID,
173  XalanDOMString& theResult) const
174  {
175 
176  if (theFunctionID >= 0 && theFunctionID < TableSize)
177  {
178  theResult.assign(
179  s_functionNames[theFunctionID].m_name,
180  s_functionNames[theFunctionID].m_size);
181  }
182 
183  return theResult;
184  }
185 
192  int
193  nameToID(const XalanDOMString& theName) const
194  {
195  return getFunctionIndex(theName);
196  }
197 
204  void
206  const XalanDOMString& theFunctionName,
207  const Function& theFunction)
208  {
209  InstallFunction(theFunctionName.c_str(), theFunction);
210  }
211 
218  bool
219  UninstallFunction(const XalanDOMString& theFunctionName)
220  {
221  return UninstallFunction(theFunctionName.c_str());
222  }
223 
230  void
231  InstallFunction(
232  const XalanDOMChar* theFunctionName,
233  const Function& theFunction);
234 
241  bool
242  UninstallFunction(const XalanDOMChar* theFunctionName);
243 
250  bool
251  isInstalledFunction(const XalanDOMString& theFunctionName) const
252  {
253  return getFunctionIndex(theFunctionName) != InvalidFunctionNumberID ? true : false;
254  }
255 
256 #if defined(XALAN_NO_MEMBER_TEMPLATES)
257 
258  typedef XalanVector<XalanDOMString> InstalledFunctionNameVectorType;
259 
265  void
266  getInstalledFunctionNames(InstalledFunctionNameVectorType& theVector) const
267  {
268  XalanDOMString theString;
269 
270  for (int i = 0; i < TableSize; ++i)
271  {
272  if (m_functionTable[i] != 0)
273  {
274  theString.assign(
275  s_functionNames[i].m_name,
276  s_functionNames[i].m_size);
277 
278  theVector.push_back(theString);
279  }
280  }
281  }
282 #else
283 
289  template<class OutputIteratorType>
290  void
291  getInstalledFunctionNames(OutputIteratorType theIterator) const
292  {
294 
295  for (int i = 0; i < TableSize; ++i)
296  {
297  if (m_functionTable[i] != 0)
298  {
299  theString.assign(
300  s_functionNames[i].m_name,
301  s_functionNames[i].m_size);
302 
303  *theIterator = theString;
304 
305  ++theIterator;
306  }
307  }
308  }
309 #endif
310 
312  {
313  const XalanDOMChar* m_name;
314 
316  };
317 
318  // These are static strings for the functions supported.
319  // Note that the XSLT functions are also here, since it's
320  // just easier to do it this way.
321 
322  // The string "id"
323  static const XalanDOMChar s_id[];
324 
325  // The string "key"
326  static const XalanDOMChar s_key[];
327 
328  // The string "not"
329  static const XalanDOMChar s_not[];
330 
331  // The string "sum"
332  static const XalanDOMChar s_sum[];
333 
334  // The string "lang"
335  static const XalanDOMChar s_lang[];
336 
337  // The string "last"
338  static const XalanDOMChar s_last[];
339 
340  // The string "name"
341  static const XalanDOMChar s_name[];
342 
343  // The string "true"
344  static const XalanDOMChar s_true[];
345 
346  // The string "count"
347  static const XalanDOMChar s_count[];
348 
349  // The string "false"
350  static const XalanDOMChar s_false[];
351 
352  // The string "floor"
353  static const XalanDOMChar s_floor[];
354 
355  // The string "round"
356  static const XalanDOMChar s_round[];
357 
358  // The string "concat"
359  static const XalanDOMChar s_concat[];
360 
361  // The string "number"
362  static const XalanDOMChar s_number[];
363 
364  // The string "string"
365  static const XalanDOMChar s_string[];
366 
367  // The string "boolean"
368  static const XalanDOMChar s_boolean[];
369 
370  // The string "ceiling"
371  static const XalanDOMChar s_ceiling[];
372 
373  // The string "current"
374  static const XalanDOMChar s_current[];
375 
376  // The string "contains"
377  static const XalanDOMChar s_contains[];
378 
379  // The string "document"
380  static const XalanDOMChar s_document[];
381 
382  // The string "position"
383  static const XalanDOMChar s_position[];
384 
385  // The string "substring"
386  static const XalanDOMChar s_substring[];
387 
388  // The string "translate"
389  static const XalanDOMChar s_translate[];
390 
391  // The string "local-name"
392  static const XalanDOMChar s_localName[];
393 
394  // The string "generate-id"
395  static const XalanDOMChar s_generateId[];
396 
397  // The string "starts-with"
398  static const XalanDOMChar s_startsWith[];
399 
400  // The string "format-number"
401  static const XalanDOMChar s_formatNumber[];
402 
403  // The string "namespace-uri"
404  static const XalanDOMChar s_namespaceUri[];
405 
406  // The string "string-length"
407  static const XalanDOMChar s_stringLength[];
408 
409  // The string "normalize-space"
410  static const XalanDOMChar s_normalizeSpace[];
411 
412  // The string "substring-after"
413  static const XalanDOMChar s_substringAfter[];
414 
415  // The string "system-property"
416  static const XalanDOMChar s_systemProperty[];
417 
418  // The string "substring-before"
419  static const XalanDOMChar s_substringBefore[];
420 
421  // The string "element-available"
422  static const XalanDOMChar s_elementAvailable[];
423 
424  // The string "function-available"
425  static const XalanDOMChar s_functionAvailable[];
426 
427  // The string "unparsed-entity-uri"
428  static const XalanDOMChar s_unparsedEntityUri[];
429 
430  // A table of function names.
431  static const FunctionNameTableEntry s_functionNames[];
432 
433  // The size of the table.
435 
436 private:
437 
438  static int
439  getFunctionIndex(const XalanDOMString& theName)
440  {
441  return getFunctionIndex(
442  theName.c_str(),
443  theName.length());
444  }
445 
446  static int
447  getFunctionIndex(const XalanDOMChar* theName)
448  {
449  return getFunctionIndex(
450  theName,
451  XalanDOMString::length(theName));
452  }
453 
454  static int
455  getFunctionIndex(
456  const XalanDOMChar* theName,
457  StringSizeType theNameLength);
458 
459  MemoryManagerType* m_memoryManager;
460 
461  const Function* m_functionTable[TableSize];
462 
463  const Function** const m_functionTableEnd;
464 
465  // The last one in the table of function names.
466  static const FunctionNameTableEntry* const s_lastFunctionName;
467 };
468 
469 
470 
471 XALAN_CPP_NAMESPACE_END
472 
473 
474 
475 #endif // XPATHFUNCTIONTABLE_HEADER_GUARD_1357924680

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

dot

Xalan-C++ XSLT Processor Version 1.10
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.

Apache Logo