00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999 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 <PlatformSupport/STLHelper.hpp> 00077 00078 00079 00080 #include <XPath/Function.hpp> 00081 #include <XPath/XPathException.hpp> 00082 00083 00084 00088 class XALAN_XPATH_EXPORT XPathExceptionFunctionNotAvailable : public XPathException 00089 { 00090 public: 00091 00092 XPathExceptionFunctionNotAvailable( 00093 int theFunctionName, 00094 const XalanNode* styleNode = 0); 00095 00096 XPathExceptionFunctionNotAvailable( 00097 const XalanDOMString& theFunctionName, 00098 const XalanNode* styleNode = 0); 00099 00100 ~XPathExceptionFunctionNotAvailable(); 00101 }; 00102 00103 00104 00108 class XALAN_XPATH_EXPORT XPathFunctionTable 00109 { 00110 public: 00111 00112 #if defined(XALAN_NO_NAMESPACES) 00113 typedef vector<Function*> CollectionType; 00114 typedef map<XalanDOMString, 00115 int, 00116 less<XalanDOMString> > FunctionNameIndexMapType; 00117 #else 00118 typedef std::vector<Function*> CollectionType; 00119 typedef std::map<XalanDOMString, int> FunctionNameIndexMapType; 00120 #endif 00121 00122 typedef DeleteFunctor<Function> DeleteFunctorType; 00123 00129 XPathFunctionTable(bool fCreateTable = true); 00130 00131 ~XPathFunctionTable(); 00132 00136 void 00137 CreateTable(); 00138 00142 void 00143 DestroyTable(); 00144 00151 Function& 00152 operator[](const XalanDOMString& theFunctionName) const 00153 { 00154 FunctionNameIndexMapType::const_iterator i = 00155 m_FunctionNameIndex.find(theFunctionName); 00156 00157 if (i != m_FunctionNameIndex.end()) 00158 { 00159 return *m_FunctionCollection[(*i).second]; 00160 } 00161 else 00162 { 00163 throw XPathExceptionFunctionNotAvailable(theFunctionName); 00164 } 00165 } 00166 00173 Function& 00174 operator[](int theFunctionID) const 00175 { 00176 if (theFunctionID >= 0 && 00177 CollectionType::size_type(theFunctionID) < m_FunctionCollection.size()) 00178 { 00179 return *m_FunctionCollection[theFunctionID]; 00180 } 00181 else 00182 { 00183 throw XPathExceptionFunctionNotAvailable(theFunctionID); 00184 } 00185 } 00186 00187 enum { InvalidFunctionNumberID = -1 }; 00188 00195 const XalanDOMString 00196 idToName(int theFunctionID) const 00197 { 00198 XalanDOMString theName; 00199 00200 if (theFunctionID >= 0 && 00201 CollectionType::size_type(theFunctionID) < m_FunctionCollection.size()) 00202 { 00203 FunctionNameIndexMapType::const_iterator i = 00204 m_FunctionNameIndex.begin(); 00205 00206 while (i != m_FunctionNameIndex.end()) 00207 { 00208 if ((*i).second == theFunctionID) 00209 { 00210 theName = (*i).first; 00211 00212 break; 00213 } 00214 } 00215 } 00216 00217 return theName; 00218 } 00219 00226 int 00227 nameToID(const XalanDOMString& theName) const 00228 { 00229 const FunctionNameIndexMapType::const_iterator i = 00230 m_FunctionNameIndex.find(theName); 00231 00232 if (i != m_FunctionNameIndex.end()) 00233 { 00234 return (*i).second; 00235 } 00236 else 00237 { 00238 return InvalidFunctionNumberID; 00239 } 00240 } 00241 00248 void 00249 InstallFunction( 00250 const XalanDOMString& theFunctionName, 00251 const Function& theFunction); 00252 00259 bool 00260 UninstallFunction(const XalanDOMString& theFunctionName); 00261 00268 bool 00269 isInstalledFunction(const XalanDOMString& theFunctionName) const 00270 { 00271 if (m_FunctionNameIndex.find(theFunctionName) != m_FunctionNameIndex.end()) 00272 { 00273 return true; 00274 } 00275 else 00276 { 00277 return false; 00278 } 00279 } 00280 00281 #if defined(XALAN_NO_MEMBER_TEMPLATES) 00282 typedef vector<XalanDOMString> InstalledFunctionNameVectorType; 00283 00289 void 00290 getInstalledFunctionNames(InstalledFunctionNameVectorType& theVector) const 00291 { 00292 FunctionNameIndexMapType::const_iterator i = 00293 m_FunctionNameIndex.begin(); 00294 00295 while(i != m_FunctionNameIndex.end()) 00296 { 00297 theVector.push_back((*i).first); 00298 00299 ++i; 00300 } 00301 } 00302 #else 00308 template<class OutputIteratorType> 00309 void 00310 getInstalledFunctionNames(OutputIteratorType theIterator) const 00311 { 00312 FunctionNameIndexMapType::const_iterator i = 00313 m_FunctionNameIndex.begin(); 00314 00315 while(i != m_FunctionNameIndex.end()) 00316 { 00317 *theIterator = (*i).first; 00318 00319 ++i; 00320 ++theIterator; 00321 } 00322 } 00323 #endif 00324 00325 private: 00326 00327 CollectionType m_FunctionCollection; 00328 00329 FunctionNameIndexMapType m_FunctionNameIndex; 00330 }; 00331 00332 00333 00334 #endif // XPATHFUNCTIONTABLE_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSL Transformer Version 1.0 |
|