## Xalan-C++ API Documentation

### The Xalan C++ XSLT Processor Version 1.5

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# XPathFunctionTable.hpp

Go to the documentation of this file.

    00001 /*
    00002  * The Apache Software License, Version 1.1
    00003  *
    00004  *
    00005  * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
    00006  * reserved.
    00007  *
    00008  * Redistribution and use in source and binary forms, with or without
    00009  * modification, are permitted provided that the following conditions
    00010  * are met:
    00011  *
    00012  * 1. Redistributions of source code must retain the above copyright
    00013  *    notice, this list of conditions and the following disclaimer.
    00014  *
    00015  * 2. Redistributions in binary form must reproduce the above copyright
    00016  *    notice, this list of conditions and the following disclaimer in
    00017  *    the documentation and/or other materials provided with the
    00018  *    distribution.
    00019  *
    00020  * 3. The end-user documentation included with the redistribution,
    00021  *    if any, must include the following acknowledgment:
    00022  *       "This product includes software developed by the
    00023  *        Apache Software Foundation (http://www.apache.org/)."
    00024  *    Alternately, this acknowledgment may appear in the software itself,
    00025  *    if and wherever such third-party acknowledgments normally appear.
    00026  *
    00027  * 4. The names "Xalan" and "Apache Software Foundation" must
    00028  *    not be used to endorse or promote products derived from this
    00029  *    software without prior written permission. For written
    00030  *    permission, please contact apache@apache.org.
    00031  *
    00032  * 5. Products derived from this software may not be called "Apache",
    00033  *    nor may "Apache" appear in their name, without prior written
    00034  *    permission of the Apache Software Foundation.
    00035  *
    00036  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    00037  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    00038  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    00039  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
    00040  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    00041  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    00042  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    00043  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    00044  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    00045  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    00046  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    00047  * SUCH DAMAGE.
    00048  * ====================================================================
    00049  *
    00050  * This software consists of voluntary contributions made by many
    00051  * individuals on behalf of the Apache Software Foundation and was
    00052  * originally based on software copyright (c) 1999, International
    00053  * Business Machines, Inc., http://www.ibm.com.  For more
    00054  * information on the Apache Software Foundation, please see
    00055  * <http://www.apache.org/>.
    00056  */
    00057 #if !defined(XPATHFUNCTIONTABLE_HEADER_GUARD_1357924680)
    00058 #define XPATHFUNCTIONTABLE_HEADER_GUARD_1357924680
    00059
    00060
    00061
    00062 // Base include file.  Must be first.
    00063 #include <XPath/XPathDefinitions.hpp>
    00064
    00065
    00066
    00067 #include <algorithm>
    00068
    00069
    00070
    00071 #include <XalanDOM/XalanDOMString.hpp>
    00072
    00073
    00074
    00075 #include <Include/STLHelper.hpp>
    00076
    00077
    00078
    00079 #include <XPath/Function.hpp>
    00080 #include <XPath/XalanXPathException.hpp>
    00081
    00082
    00083
    00084 XALAN_CPP_NAMESPACE_BEGIN
    00085
    00086
    00087
    00091 class XALAN_XPATH_EXPORT XPathExceptionFunctionNotAvailable : public XalanXPathException
    00092 {
    00093 public:
    00094
    00095     typedef Function::LocatorType   LocatorType;
    00096
    00097     XPathExceptionFunctionNotAvailable(int  theFunctionNumber);
    00098
    00099     XPathExceptionFunctionNotAvailable(const XalanDOMString&    theFunctionName);
    00100
    00101     XPathExceptionFunctionNotAvailable(
    00102         int                 theFunctionNumber,
    00103         const LocatorType&  theLocator);
    00104
    00105     XPathExceptionFunctionNotAvailable(
    00106         const XalanDOMString&   theFunctionName,
    00107         const LocatorType&      theLocator);
    00108
    00109     ~XPathExceptionFunctionNotAvailable();
    00110 };
    00111
    00112
    00113
    00118 class XALAN_XPATH_EXPORT XPathExceptionFunctionNotSupported : public XalanXPathException
    00119 {
    00120 public:
    00121
    00122     XPathExceptionFunctionNotSupported(const XalanDOMChar*  theFunctionName);
    00123
    00124     ~XPathExceptionFunctionNotSupported();
    00125 };
    00126
    00127
    00128
    00132 class XALAN_XPATH_EXPORT XPathFunctionTable
    00133 {
    00134 public:
    00135
    00136     enum { InvalidFunctionNumberID = -1, TableSize = 36 };
    00137
    00138     typedef size_t                      SizeType;
    00139     typedef XalanDOMString::size_type   StringSizeType;
    00140     typedef DeleteFunctor<Function>     DeleteFunctorType;
    00141
    00147     XPathFunctionTable(bool     fCreateTable = true);
    00148
    00149     ~XPathFunctionTable();
    00150
    00154     void
    00155     CreateTable();
    00156
    00160     void
    00161     DestroyTable();
    00162
    00169     const Function&
    00170     operator[](const XalanDOMString&    theFunctionName) const
    00171     {
    00172         const int   theFunctionID =
    00173             getFunctionIndex(theFunctionName);
    00174
    00175         if (theFunctionID != InvalidFunctionNumberID)
    00176         {
    00177             return *m_functionTable[theFunctionID];
    00178         }
    00179         else
    00180         {
    00181             throw XPathExceptionFunctionNotAvailable(theFunctionName);
    00182         }
    00183     }
    00184
    00191     const Function&
    00192     operator[](int  theFunctionID) const
    00193     {
    00194         assert(theFunctionID >= 0 && theFunctionID < TableSize);
    00195         assert(m_functionTable[theFunctionID] != 0);
    00196
    00197         return *m_functionTable[theFunctionID];
    00198     }
    00199
    00206     const XalanDOMString
    00207     idToName(int    theFunctionID) const
    00208     {
    00209         XalanDOMString  theName;
    00210
    00211         if (theFunctionID >= 0 && theFunctionID < TableSize)
    00212         {
    00213             theName.assign(
    00214                 s_functionNames[theFunctionID].m_name,
    00215                 s_functionNames[theFunctionID].m_size);
    00216         }
    00217
    00218         return theName;
    00219     }
    00220
    00227     int
    00228     nameToID(const XalanDOMString&  theName) const
    00229     {
    00230         return getFunctionIndex(theName);
    00231     }
    00232
    00239     void
    00240     InstallFunction(
    00241             const XalanDOMString&   theFunctionName,
    00242             const Function&         theFunction)
    00243     {
    00244         InstallFunction(theFunctionName.c_str(), theFunction);
    00245     }
    00246
    00253     bool
    00254     UninstallFunction(const XalanDOMString&     theFunctionName)
    00255     {
    00256         return UninstallFunction(theFunctionName.c_str());
    00257     }
    00258
    00265     void
    00266     InstallFunction(
    00267             const XalanDOMChar*     theFunctionName,
    00268             const Function&         theFunction);
    00269
    00276     bool
    00277     UninstallFunction(const XalanDOMChar*   theFunctionName);
    00278
    00285     bool
    00286     isInstalledFunction(const XalanDOMString&   theFunctionName) const
    00287     {
    00288         return getFunctionIndex(theFunctionName) != InvalidFunctionNumberID ? true : false;
    00289     }
    00290
    00291 #if defined(XALAN_NO_MEMBER_TEMPLATES)
    00292
    00293 #if defined(XALAN_NO_STD_NAMESPACE)
    00294     typedef vector<XalanDOMString>          InstalledFunctionNameVectorType;
    00295 #else
    00296     typedef std::vector<XalanDOMString>     InstalledFunctionNameVectorType;
    00297 #endif
    00298
    00304     void
    00305     getInstalledFunctionNames(InstalledFunctionNameVectorType&  theVector) const
    00306     {
    00307         XalanDOMString  theString;
    00308
    00309         for (int i = 0; i < TableSize; ++i)
    00310         {
    00311             if (m_functionTable[i] != 0)
    00312             {
    00313                 theString.assign(
    00314                     s_functionNames[i].m_name,
    00315                     s_functionNames[i].m_size);
    00316
    00317                 theVector.push_back(theString);
    00318             }
    00319         }
    00320     }
    00321 #else
    00322
    00328     template<class OutputIteratorType>
    00329     void
    00330     getInstalledFunctionNames(OutputIteratorType    theIterator) const
    00331     {
    00332         XalanDOMString  theString;
    00333
    00334         for (int i = 0; i < TableSize; ++i)
    00335         {
    00336             if (m_functionTable[i] != 0)
    00337             {
    00338                 theString.assign(
    00339                     s_functionNames[i].m_name,
    00340                     s_functionNames[i].m_size);
    00341
    00342                 *theIterator = theString;
    00343
    00344                 ++theIterator;
    00345             }
    00346         }
    00347     }
    00348 #endif
    00349
    00350     struct FunctionNameTableEntry
    00351     {
    00352         const XalanDOMChar*     m_name;
    00353
    00354         StringSizeType          m_size;
    00355     };
    00356
    00357     // These are static strings for the functions supported.
    00358     // Note that the XSLT functions are also here, since it's
    00359     // just easier to do it this way.
    00360
    00361     // The string "id"
    00362     static const XalanDOMChar   s_id[];
    00363
    00364     // The string "key"
    00365     static const XalanDOMChar   s_key[];
    00366
    00367     // The string "not"
    00368     static const XalanDOMChar   s_not[];
    00369
    00370     // The string "sum"
    00371     static const XalanDOMChar   s_sum[];
    00372
    00373     // The string "lang"
    00374     static const XalanDOMChar   s_lang[];
    00375
    00376     // The string "last"
    00377     static const XalanDOMChar   s_last[];
    00378
    00379     // The string "name"
    00380     static const XalanDOMChar   s_name[];
    00381
    00382     // The string "true"
    00383     static const XalanDOMChar   s_true[];
    00384
    00385     // The string "count"
    00386     static const XalanDOMChar   s_count[];
    00387
    00388     // The string "false"
    00389     static const XalanDOMChar   s_false[];
    00390
    00391     // The string "floor"
    00392     static const XalanDOMChar   s_floor[];
    00393
    00394     // The string "round"
    00395     static const XalanDOMChar   s_round[];
    00396
    00397     // The string "concat"
    00398     static const XalanDOMChar   s_concat[];
    00399
    00400     // The string "number"
    00401     static const XalanDOMChar   s_number[];
    00402
    00403     // The string "string"
    00404     static const XalanDOMChar   s_string[];
    00405
    00406     // The string "boolean"
    00407     static const XalanDOMChar   s_boolean[];
    00408
    00409     // The string "ceiling"
    00410     static const XalanDOMChar   s_ceiling[];
    00411
    00412     // The string "current"
    00413     static const XalanDOMChar   s_current[];
    00414
    00415     // The string "contains"
    00416     static const XalanDOMChar   s_contains[];
    00417
    00418     // The string "document"
    00419     static const XalanDOMChar   s_document[];
    00420
    00421     // The string "position"
    00422     static const XalanDOMChar   s_position[];
    00423
    00424     // The string "substring"
    00425     static const XalanDOMChar   s_substring[];
    00426
    00427     // The string "translate"
    00428     static const XalanDOMChar   s_translate[];
    00429
    00430     // The string "local-name"
    00431     static const XalanDOMChar   s_localName[];
    00432
    00433     // The string "generate-id"
    00434     static const XalanDOMChar   s_generateId[];
    00435
    00436     // The string "starts-with"
    00437     static const XalanDOMChar   s_startsWith[];
    00438
    00439     // The string "format-number"
    00440     static const XalanDOMChar   s_formatNumber[];
    00441
    00442     // The string "namespace-uri"
    00443     static const XalanDOMChar   s_namespaceUri[];
    00444
    00445     // The string "string-length"
    00446     static const XalanDOMChar   s_stringLength[];
    00447
    00448     // The string "normalize-space"
    00449     static const XalanDOMChar   s_normalizeSpace[];
    00450
    00451     // The string "substring-after"
    00452     static const XalanDOMChar   s_substringAfter[];
    00453
    00454     // The string "system-property"
    00455     static const XalanDOMChar   s_systemProperty[];
    00456
    00457     // The string "substring-before"
    00458     static const XalanDOMChar   s_substringBefore[];
    00459
    00460     // The string "element-available"
    00461     static const XalanDOMChar   s_elementAvailable[];
    00462
    00463     // The string "function-available"
    00464     static const XalanDOMChar   s_functionAvailable[];
    00465
    00466     // The string "unparsed-entity-uri"
    00467     static const XalanDOMChar   s_unparsedEntityUri[];
    00468
    00469     // A table of function names.
    00470     static const FunctionNameTableEntry         s_functionNames[];
    00471
    00472     // The size of the table.
    00473     static const SizeType                       s_functionNamesSize;
    00474
    00475 private:
    00476
    00477     static int
    00478     getFunctionIndex(const XalanDOMString&  theName)
    00479     {
    00480         return getFunctionIndex(
    00481                 theName.c_str(),
    00482                 theName.length());
    00483     }
    00484
    00485     static int
    00486     getFunctionIndex(const XalanDOMChar*    theName)
    00487     {
    00488         return getFunctionIndex(
    00489                 theName,
    00490                 XalanDOMString::length(theName));
    00491     }
    00492
    00493     static int
    00494     getFunctionIndex(
    00495             const XalanDOMChar*     theName,
    00496             StringSizeType          theNameLength);
    00497
    00498
    00499     const Function*             m_functionTable[TableSize];
    00500
    00501     const Function** const      m_functionTableEnd;
    00502
    00503     // The last one in the table of function names.
    00504     static const FunctionNameTableEntry* const  s_lastFunctionName;
    00505 };
    00506
    00507
    00508
    00509 XALAN_CPP_NAMESPACE_END
    00510
    00511
    00512
    00513 #endif  // XPATHFUNCTIONTABLE_HEADER_GUARD_1357924680

Interpreting class diagrams

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

Xalan-C++ XSLT Processor Version 1.5 Copyright © 2000, 2001, 2002, 2003 The Apache Software Foundation. All Rights Reserved.