Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.4

Main Page   Namespace List   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 #include <map>
00069 
00070 
00071 
00072 #include <XalanDOM/XalanDOMString.hpp>
00073 
00074 
00075 
00076 #include <Include/STLHelper.hpp>
00077 
00078 
00079 
00080 #include <XPath/Function.hpp>
00081 #include <XPath/XalanXPathException.hpp>
00082 
00083 
00084 
00085 class Locator;
00086 
00087 
00088 
00092 class XALAN_XPATH_EXPORT XPathExceptionFunctionNotAvailable : public XalanXPathException
00093 {
00094 public:
00095 
00096     XPathExceptionFunctionNotAvailable(int  theFunctionNumber);
00097 
00098     XPathExceptionFunctionNotAvailable(const XalanDOMString&    theFunctionName);
00099 
00100     XPathExceptionFunctionNotAvailable(
00101         int                 theFunctionNumber,
00102         const Locator&      theLocator);
00103 
00104     XPathExceptionFunctionNotAvailable(
00105         const XalanDOMString&   theFunctionName,
00106         const Locator&          theLocator);
00107 
00108     ~XPathExceptionFunctionNotAvailable();
00109 };
00110 
00111 
00112 
00116 class XALAN_XPATH_EXPORT XPathFunctionTable
00117 {
00118 public:
00119 
00120 #if defined(XALAN_NO_NAMESPACES)
00121     typedef vector<const Function*>         CollectionType;
00122     typedef map<XalanDOMString,
00123                 int,
00124                 less<XalanDOMString> >      FunctionNameIndexMapType;
00125 #else
00126     typedef std::vector<const Function*>    CollectionType;
00127     typedef std::map<XalanDOMString, int>   FunctionNameIndexMapType;
00128 #endif
00129 
00130     enum { eDefaultTableSize = 36 };
00131 
00132     typedef DeleteFunctor<Function>     DeleteFunctorType;
00133 
00139     XPathFunctionTable(bool     fCreateTable = true);
00140 
00141     ~XPathFunctionTable();
00142 
00146     void
00147     CreateTable();
00148 
00152     void
00153     DestroyTable();
00154 
00161     const Function&
00162     operator[](const XalanDOMString&    theFunctionName) const
00163     {
00164         FunctionNameIndexMapType::const_iterator    i =
00165             m_FunctionNameIndex.find(theFunctionName);
00166 
00167         if (i != m_FunctionNameIndex.end())
00168         {
00169             return *m_FunctionCollection[(*i).second];
00170         }
00171         else
00172         {
00173             throw XPathExceptionFunctionNotAvailable(theFunctionName);
00174         }
00175     }
00176 
00183     const Function&
00184     operator[](int  theFunctionID) const
00185     {
00186         assert(theFunctionID >= 0 &&
00187                CollectionType::size_type(theFunctionID) < m_FunctionCollection.size());
00188 
00189         return *m_FunctionCollection[theFunctionID];
00190     }
00191 
00192     enum { InvalidFunctionNumberID = -1 };
00193 
00200     const XalanDOMString
00201     idToName(int    theFunctionID) const
00202     {
00203         XalanDOMString  theName;
00204 
00205         if (theFunctionID >= 0 &&
00206             CollectionType::size_type(theFunctionID) < m_FunctionCollection.size())
00207         {
00208             FunctionNameIndexMapType::const_iterator    i =
00209                 m_FunctionNameIndex.begin();
00210 
00211             while (i != m_FunctionNameIndex.end())
00212             {
00213                 if ((*i).second == theFunctionID)
00214                 {
00215                     theName = (*i).first;
00216 
00217                     break;
00218                 }
00219             }
00220         }
00221 
00222         return theName;
00223     }
00224 
00231     int
00232     nameToID(const XalanDOMString&  theName) const
00233     {
00234         const FunctionNameIndexMapType::const_iterator  i =
00235             m_FunctionNameIndex.find(theName);
00236 
00237         if (i != m_FunctionNameIndex.end())
00238         {
00239             return (*i).second;
00240         }
00241         else
00242         {
00243             return InvalidFunctionNumberID;
00244         }
00245     }
00246 
00253     void
00254     InstallFunction(
00255             const XalanDOMString&   theFunctionName,
00256             const Function&         theFunction);
00257 
00264     bool
00265     UninstallFunction(const XalanDOMString&     theFunctionName);
00266 
00273     bool
00274     isInstalledFunction(const XalanDOMString&   theFunctionName) const
00275     {
00276         if (m_FunctionNameIndex.find(theFunctionName) != m_FunctionNameIndex.end())
00277         {
00278             return true;
00279         }
00280         else
00281         {
00282             return false;
00283         }
00284     }
00285 
00286 #if defined(XALAN_NO_MEMBER_TEMPLATES)
00287 
00288 #if defined(XALAN_NO_NAMESPACES)
00289     typedef vector<XalanDOMString>          InstalledFunctionNameVectorType;
00290 #else
00291     typedef std::vector<XalanDOMString>     InstalledFunctionNameVectorType;
00292 #endif
00293 
00299     void
00300     getInstalledFunctionNames(InstalledFunctionNameVectorType&  theVector) const
00301     {
00302         FunctionNameIndexMapType::const_iterator    i =
00303             m_FunctionNameIndex.begin();
00304 
00305         while(i != m_FunctionNameIndex.end())
00306         {
00307             theVector.push_back((*i).first);
00308 
00309             ++i;
00310         }
00311     }
00312 #else
00318     template<class OutputIteratorType>
00319     void
00320     getInstalledFunctionNames(OutputIteratorType    theIterator) const
00321     {
00322         FunctionNameIndexMapType::const_iterator    i =
00323             m_FunctionNameIndex.begin();
00324 
00325         while(i != m_FunctionNameIndex.end())
00326         {
00327             *theIterator = (*i).first;
00328 
00329             ++i;
00330             ++theIterator;
00331         }
00332     }
00333 #endif
00334 
00335 private:
00336 
00337     CollectionType              m_FunctionCollection;
00338 
00339     FunctionNameIndexMapType    m_FunctionNameIndex;
00340 
00341     // The string "id"
00342     static const XalanDOMChar   s_id[];
00343 
00344     // The string "not"
00345     static const XalanDOMChar   s_not[];
00346 
00347     // The string "sum"
00348     static const XalanDOMChar   s_sum[];
00349 
00350     // The string "lang"
00351     static const XalanDOMChar   s_lang[];
00352 
00353     // The string "last"
00354     static const XalanDOMChar   s_last[];
00355 
00356     // The string "name"
00357     static const XalanDOMChar   s_name[];
00358 
00359     // The string "true"
00360     static const XalanDOMChar   s_true[];
00361 
00362     // The string "count"
00363     static const XalanDOMChar   s_count[];
00364 
00365     // The string "false"
00366     static const XalanDOMChar   s_false[];
00367 
00368     // The string "floor"
00369     static const XalanDOMChar   s_floor[];
00370 
00371     // The string "round"
00372     static const XalanDOMChar   s_round[];
00373 
00374     // The string "concat"
00375     static const XalanDOMChar   s_concat[];
00376 
00377     // The string "number"
00378     static const XalanDOMChar   s_number[];
00379 
00380     // The string "string"
00381     static const XalanDOMChar   s_string[];
00382 
00383     // The string "boolean"
00384     static const XalanDOMChar   s_boolean[];
00385 
00386     // The string "ceiling"
00387     static const XalanDOMChar   s_ceiling[];
00388 
00389     // The string "contains"
00390     static const XalanDOMChar   s_contains[];
00391 
00392     // The string "position"
00393     static const XalanDOMChar   s_position[];
00394 
00395     // The string "substring"
00396     static const XalanDOMChar   s_substring[];
00397 
00398     // The string "translate"
00399     static const XalanDOMChar   s_translate[];
00400 
00401     // The string "local-name"
00402     static const XalanDOMChar   s_localName[];
00403 
00404     // The string "starts-with"
00405     static const XalanDOMChar   s_startsWith[];
00406 
00407     // The string "namespace-uri"
00408     static const XalanDOMChar   s_namespaceUri[];
00409 
00410     // The string "string-length"
00411     static const XalanDOMChar   s_stringLength[];
00412 
00413     // The string "normalize-space"
00414     static const XalanDOMChar   s_normalizeSpace[];
00415 
00416     // The string "substring-after"
00417     static const XalanDOMChar   s_substringAfter[];
00418 
00419     // The string "substring-before"
00420     static const XalanDOMChar   s_substringBefore[];
00421 };
00422 
00423 
00424 
00425 #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.4
Copyright © 2000, 2001, 2002 The Apache Software Foundation. All Rights Reserved.