Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.8

Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

XalanNamespacesStack.hpp

Go to the documentation of this file.
00001 /* 00002 * Copyright 1999-2004 The Apache Software Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #if !defined(XALAN_XALANNAMESPACESSTACK_HEADER_GUARD) 00017 #define XALAN_XALANNAMESPACESSTACK_HEADER_GUARD 00018 00019 00020 00021 // Base include file. Must be first. 00022 #include <xalanc/DOMSupport/DOMSupportDefinitions.hpp> 00023 00024 00025 00026 #include <deque> 00027 #include <vector> 00028 00029 00030 00031 #include <xalanc/PlatformSupport/PrefixResolver.hpp> 00032 #include <xalanc/PlatformSupport/XalanNamespace.hpp> 00033 00034 00035 00036 XALAN_CPP_NAMESPACE_BEGIN 00037 00038 00039 00040 class XalanDOMString; 00041 00042 00043 00044 class XALAN_DOMSUPPORT_EXPORT XalanNamespacesStack 00045 { 00046 public: 00047 00048 class XALAN_DOMSUPPORT_EXPORT PrefixResolverProxy : public PrefixResolver 00049 { 00050 public: 00051 00060 PrefixResolverProxy( 00061 const XalanNamespacesStack& theStack, 00062 const XalanDOMString& theURI); 00063 00064 virtual 00065 ~PrefixResolverProxy(); 00066 00067 virtual const XalanDOMString* 00068 getNamespaceForPrefix(const XalanDOMString& prefix) const; 00069 00070 virtual const XalanDOMString& 00071 getURI() const; 00072 00073 private: 00074 00075 const XalanNamespacesStack& m_stack; 00076 00077 const XalanDOMString& m_uri; 00078 }; 00079 00080 class XALAN_DOMSUPPORT_EXPORT XalanNamespacesStackEntry 00081 { 00082 public: 00083 00084 typedef XalanNamespace value_type; 00085 00086 #if defined(XALAN_NO_STD_NAMESPACE) 00087 typedef deque<value_type> NamespaceCollectionType; 00088 #else 00089 typedef std::deque<value_type> NamespaceCollectionType; 00090 #endif 00091 00092 typedef const XalanDOMString& (value_type::*MemberFunctionType)() const; 00093 00094 typedef NamespaceCollectionType::iterator iterator; 00095 typedef NamespaceCollectionType::reverse_iterator reverse_iterator; 00096 typedef NamespaceCollectionType::const_iterator const_iterator; 00097 typedef NamespaceCollectionType::const_reverse_iterator const_reverse_iterator; 00098 00099 XalanNamespacesStackEntry(); 00100 00101 XalanNamespacesStackEntry(const XalanNamespacesStackEntry& theSource); 00102 00103 ~XalanNamespacesStackEntry(); 00104 00105 XalanNamespacesStackEntry& 00106 operator=(const XalanNamespacesStackEntry& theRHS); 00107 00108 void 00109 addDeclaration( 00110 const XalanDOMString& thePrefix, 00111 const XalanDOMChar* theNamespaceURI, 00112 XalanDOMString::size_type theLength); 00113 00120 const XalanDOMString* 00121 getNamespaceForPrefix(const XalanDOMString& thePrefix) const 00122 { 00123 return findEntry(thePrefix, &XalanNamespace::getPrefix, &XalanNamespace::getURI); 00124 } 00125 00132 const XalanDOMString* 00133 getPrefixForNamespace(const XalanDOMString& theURI) const 00134 { 00135 return findEntry(theURI, &XalanNamespace::getURI, &XalanNamespace::getPrefix); 00136 } 00137 00138 bool 00139 isPrefixPresent(const XalanDOMString& thePrefix) const 00140 { 00141 return getNamespaceForPrefix(thePrefix) == 0 ? false : true; 00142 } 00143 00144 iterator 00145 begin() 00146 { 00147 return m_namespaces.begin(); 00148 } 00149 00150 const_iterator 00151 begin() const 00152 { 00153 return m_namespaces.begin(); 00154 } 00155 00156 iterator 00157 end() 00158 { 00159 return m_position; 00160 } 00161 00162 const_iterator 00163 end() const 00164 { 00165 return const_iterator(m_position); 00166 } 00167 00168 reverse_iterator 00169 rbegin() 00170 { 00171 return reverse_iterator(end()); 00172 } 00173 00174 const_reverse_iterator 00175 rbegin() const 00176 { 00177 return const_reverse_iterator(end()); 00178 } 00179 00180 reverse_iterator 00181 rend() 00182 { 00183 return reverse_iterator(begin()); 00184 } 00185 00186 const_reverse_iterator 00187 rend() const 00188 { 00189 return const_reverse_iterator(begin()); 00190 } 00191 00192 void 00193 clear(); 00194 00195 void 00196 reset() 00197 { 00198 m_position = m_namespaces.begin(); 00199 } 00200 00201 void 00202 swap(XalanNamespacesStackEntry& theOther); 00203 00204 private: 00205 00206 const XalanDOMString* 00207 findEntry( 00208 const XalanDOMString& theKey, 00209 MemberFunctionType theKeyFunction, 00210 MemberFunctionType theValueFunction) const; 00211 00212 NamespaceCollectionType m_namespaces; 00213 00214 iterator m_position; 00215 }; 00216 00217 00218 typedef XalanNamespacesStackEntry value_type; 00219 00220 #if defined(XALAN_NO_STD_NAMESPACE) 00221 typedef deque<value_type> NamespacesStackType; 00222 #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL) 00223 typedef deque<bool> BoolVectorType; 00224 #else 00225 typedef vector<bool> BoolVectorType; 00226 #endif 00227 #else 00228 typedef std::deque<value_type> NamespacesStackType; 00229 #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL) 00230 typedef std::deque<bool> BoolVectorType; 00231 #else 00232 typedef std::vector<bool> BoolVectorType; 00233 #endif 00234 #endif 00235 00236 typedef NamespacesStackType::iterator iterator; 00237 typedef NamespacesStackType::reverse_iterator reverse_iterator; 00238 typedef NamespacesStackType::const_iterator const_iterator; 00239 typedef NamespacesStackType::const_reverse_iterator const_reverse_iterator; 00240 00241 typedef NamespacesStackType::size_type size_type; 00242 00243 typedef const XalanDOMString* (value_type::*MemberFunctionType)(const XalanDOMString&) const; 00244 00245 00246 explicit 00247 XalanNamespacesStack(); 00248 00249 ~XalanNamespacesStack(); 00250 00251 void 00252 addDeclaration( 00253 const XalanDOMString& thePrefix, 00254 const XalanDOMString& theURI) 00255 { 00256 addDeclaration( 00257 thePrefix, 00258 theURI.c_str(), 00259 theURI.length()); 00260 } 00261 00262 void 00263 addDeclaration( 00264 const XalanDOMString& thePrefix, 00265 const XalanDOMChar* theURI) 00266 { 00267 addDeclaration( 00268 thePrefix, 00269 theURI, 00270 length(theURI)); 00271 } 00272 00273 void 00274 addDeclaration( 00275 const XalanDOMString& thePrefix, 00276 const XalanDOMChar* theURI, 00277 XalanDOMString::size_type theLength); 00278 00279 void 00280 pushContext(); 00281 00282 void 00283 popContext(); 00284 00285 const XalanDOMString* 00286 getNamespaceForPrefix(const XalanDOMString& thePrefix) const; 00287 00288 const XalanDOMString* 00289 getPrefixForNamespace(const XalanDOMString& theURI) const 00290 { 00291 return findEntry(theURI, &value_type::getPrefixForNamespace); 00292 } 00293 00298 bool 00299 prefixIsPresentLocal(const XalanDOMString& thePrefix); 00300 00301 void 00302 clear(); 00303 00304 iterator 00305 begin() 00306 { 00307 return m_stackBegin + 1; 00308 } 00309 00310 const_iterator 00311 begin() const 00312 { 00313 return const_iterator(m_stackBegin + 1); 00314 } 00315 00316 iterator 00317 end() 00318 { 00319 return m_stackPosition + 1; 00320 } 00321 00322 const_iterator 00323 end() const 00324 { 00325 return const_iterator(m_stackPosition + 1); 00326 } 00327 00328 reverse_iterator 00329 rbegin() 00330 { 00331 return reverse_iterator(end()); 00332 } 00333 00334 const_reverse_iterator 00335 rbegin() const 00336 { 00337 return const_reverse_iterator(end()); 00338 } 00339 00340 reverse_iterator 00341 rend() 00342 { 00343 return reverse_iterator(begin()); 00344 } 00345 00346 const_reverse_iterator 00347 rend() const 00348 { 00349 return const_reverse_iterator(begin()); 00350 } 00351 00352 size_type 00353 size() const 00354 { 00355 return m_resultNamespaces.size() - 1; 00356 } 00357 00358 bool 00359 empty() const 00360 { 00361 return NamespacesStackType::const_iterator(m_stackPosition) == m_resultNamespaces.begin() ? true : false; 00362 } 00363 00364 private: 00365 00366 // not implemented 00367 XalanNamespacesStack(const XalanNamespacesStack&); 00368 00369 bool 00370 operator==(const XalanNamespacesStack&) const; 00371 00372 XalanNamespacesStack& 00373 operator=(const XalanNamespacesStack&); 00374 00375 enum { eDefaultCreateNewContextStackSize = 25 }; 00376 00377 const XalanDOMString* 00378 findEntry( 00379 const XalanDOMString& theKey, 00380 MemberFunctionType theFunction) const; 00381 00385 NamespacesStackType m_resultNamespaces; 00386 00387 NamespacesStackType::iterator m_stackBegin; 00388 00389 NamespacesStackType::iterator m_stackPosition; 00390 00391 BoolVectorType m_createNewContextStack; 00392 }; 00393 00394 00395 00396 XALAN_CPP_NAMESPACE_END 00397 00398 00399 00400 #endif // XALAN_XALANNAMESPACESSTACK_HEADER_GUARD

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.8
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.