00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 #if !defined(XPATHENVSUPPORTDEFAULT_HEADER_GUARD_1357924680) 00019 #define XPATHENVSUPPORTDEFAULT_HEADER_GUARD_1357924680 00020 00021 00022 00023 // Base include file. Must be first. 00024 #include <xalanc/XPath/XPathDefinitions.hpp> 00025 #include <xalanc/XPath/XPathEnvSupport.hpp> 00026 00027 00028 00029 #include<xalanc/PlatformSupport/DOMStringHelper.hpp> 00030 00031 00032 00033 #include<xalanc/Include/XalanMap.hpp> 00034 00035 00036 00037 XALAN_CPP_NAMESPACE_BEGIN 00038 00039 00040 00041 typedef XalanMap<XalanDOMString, const Function*> FunctionTableTypeDefinition; 00042 XALAN_USES_MEMORY_MANAGER(FunctionTableTypeDefinition) 00043 00044 00045 00046 class XALAN_XPATH_EXPORT XPathEnvSupportDefault : public XPathEnvSupport 00047 { 00048 public: 00049 00050 typedef XalanMap<XalanDOMString, XalanDocument*> SourceDocsTableType; 00051 typedef FunctionTableTypeDefinition FunctionTableType; 00052 typedef XalanMap<XalanDOMString, FunctionTableType> NamespaceFunctionTablesType; 00053 00054 /** 00055 * Perform initialization of statics -- must be called before any 00056 * processing occurs. See class XPathInit. 00057 */ 00058 static void 00059 initialize(MemoryManager& theManager); 00060 00061 /** 00062 * Perform termination of statics. See class XPathInit. 00063 */ 00064 static void 00065 terminate(); 00066 00067 00068 XPathEnvSupportDefault(MemoryManager& theManager XALAN_DEFAULT_MEMMGR); 00069 00070 virtual 00071 ~XPathEnvSupportDefault(); 00072 00073 MemoryManager& 00074 getMemoryManager() const 00075 { 00076 return m_memoryManager; 00077 } 00078 00079 virtual void 00080 setPrintWriter(PrintWriter* pw); 00081 00082 virtual void 00083 problem( 00084 eSource source, 00085 eClassification classification, 00086 const XalanDOMString& msg, 00087 const Locator* locator, 00088 const XalanNode* sourceNode); 00089 00090 virtual void 00091 problem( 00092 eSource source, 00093 eClassification classification, 00094 const XalanDOMString& msg, 00095 const XalanNode* sourceNode); 00096 00097 // Interfaces to install and uninstall external functions globally. 00098 // These calls are not thread-safe, and should happen during 00099 // processing. 00100 00101 /** 00102 * Install an external function in the global space. 00103 * 00104 * @param theNamespace The namespace for the functionl 00105 * @param functionName The name of the function. 00106 * @param function The function to install. 00107 */ 00108 static void 00109 installExternalFunctionGlobal( 00110 const XalanDOMString& theNamespace, 00111 const XalanDOMString& functionName, 00112 const Function& function); 00113 00114 /** 00115 * Uninstall an external function from the global space. 00116 * 00117 * @param theNamespace The namespace for the functionl 00118 * @param functionName The name of the function. 00119 */ 00120 static void 00121 uninstallExternalFunctionGlobal( 00122 const XalanDOMString& theNamespace, 00123 const XalanDOMString& functionName); 00124 00125 // Interfaces to install and uninstall external functions in this instance. 00126 00127 /** 00128 * Install an external function in the local space. 00129 * 00130 * @param theNamespace The namespace for the functionl 00131 * @param functionName The name of the function. 00132 * @param function The function to install. 00133 */ 00134 virtual void 00135 installExternalFunctionLocal( 00136 const XalanDOMString& theNamespace, 00137 const XalanDOMString& functionName, 00138 const Function& function); 00139 00140 /** 00141 * Uninstall an external function from the local space. 00142 * 00143 * @param theNamespace The namespace for the functionl 00144 * @param functionName The name of the function. 00145 */ 00146 virtual void 00147 uninstallExternalFunctionLocal( 00148 const XalanDOMString& theNamespace, 00149 const XalanDOMString& functionName); 00150 00151 00152 // These interfaces are inherited from XPathEnvSupport... 00153 00154 virtual XalanDocument* 00155 parseXML( 00156 MemoryManager& theManager, 00157 const XalanDOMString& urlString, 00158 const XalanDOMString& base, 00159 ErrorHandler* theErrorHandler = 0); 00160 00161 virtual XalanDocument* 00162 getSourceDocument(const XalanDOMString& theURI) const; 00163 00164 virtual void 00165 setSourceDocument( 00166 const XalanDOMString& theURI, 00167 XalanDocument* theDocument); 00168 00169 virtual const XalanDOMString& 00170 findURIFromDoc(const XalanDocument* owner) const; 00171 00172 virtual bool 00173 elementAvailable( 00174 const XalanDOMString& theNamespace, 00175 const XalanDOMString& elementName) const; 00176 00177 virtual bool 00178 functionAvailable( 00179 const XalanDOMString& theNamespace, 00180 const XalanDOMString& functionName) const; 00181 00182 virtual XObjectPtr 00183 extFunction( 00184 XPathExecutionContext& executionContext, 00185 const XalanDOMString& theNamespace, 00186 const XalanDOMString& functionName, 00187 XalanNode* context, 00188 const XObjectArgVectorType& argVec, 00189 const Locator* locator) const; 00190 00191 virtual void 00192 reset(); 00193 00194 // Delete functor for table cleanup... 00195 struct NamespaceFunctionTableDeleteFunctor 00196 { 00197 typedef FunctionTableType FunctionTableInnerType; 00198 typedef NamespaceFunctionTablesType NamespaceFunctionTablesInnerType; 00199 00200 NamespaceFunctionTableDeleteFunctor(MemoryManager& theManager); 00201 /** 00202 * Delete the value object in a map value pair. The value of the pair must 00203 * be of pointer type. 00204 * 00205 * @param thePair key-value pair 00206 */ 00207 void 00208 operator()(const NamespaceFunctionTablesInnerType::value_type& thePair) const; 00209 00210 private: 00211 00212 MemoryManager& m_memoryManager; 00213 }; 00214 00215 protected: 00216 00217 /** 00218 * Find an external function. 00219 * 00220 * @param theNamespace The namespace for the function. 00221 * @param functionName The name of the function. 00222 * @return a pointer to the function if found, or 0 if not found. 00223 */ 00224 const Function* 00225 findFunction( 00226 const XalanDOMString& theNamespace, 00227 const XalanDOMString& functionName) const; 00228 00229 private: 00230 00231 // These are not implemented... 00232 XPathEnvSupportDefault(const XPathEnvSupportDefault&); 00233 00234 XPathEnvSupportDefault& 00235 operator=(const XPathEnvSupportDefault&); 00236 00237 bool 00238 operator==(const XPathEnvSupportDefault&) const; 00239 00240 /** 00241 * Update the supplied function table. If the parameter 00242 * function is 0, and a function with the supplied 00243 * namespace and name exists in the table, it will be 00244 * removed. If function is not 0, and a function with 00245 * the supplied namespace and name exists in the table, 00246 * it will be replaced with the new function. Otherwise, 00247 * the function will be added. 00248 * 00249 * @param theNamespace The namespace for the functionl 00250 * @param functionName The name of the function. 00251 * @param function The function to install. 00252 */ 00253 static void 00254 updateFunctionTable( 00255 NamespaceFunctionTablesType& theTable, 00256 const XalanDOMString& theNamespace, 00257 const XalanDOMString& functionName, 00258 const Function* function); 00259 00260 /** 00261 * Find an external function in the supplied table. 00262 * 00263 * @param theTable The table to search. 00264 * @param theNamespace The namespace for the function. 00265 * @param functionName The name of the function. 00266 * @return a pointer to the function if found, or 0 if not found. 00267 */ 00268 const Function* 00269 findFunction( 00270 const NamespaceFunctionTablesType& theTable, 00271 const XalanDOMString& theNamespace, 00272 const XalanDOMString& functionName) const; 00273 00274 // Data members... 00275 00276 SourceDocsTableType m_sourceDocs; 00277 00278 NamespaceFunctionTablesType m_externalFunctions; 00279 00280 MemoryManager& m_memoryManager; 00281 00282 PrintWriter* m_pw; 00283 00284 static NamespaceFunctionTablesType s_externalFunctions; 00285 00286 static const XalanDOMString s_emptyString; 00287 }; 00288 00289 XALAN_CPP_NAMESPACE_END 00290 00291 00292 00293 #endif // XPATHENVSUPPORTDEFAULT_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.11 |
|