## Xalan-C++ API Documentation

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

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

# 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 <xalanc/Include/XalanVector.hpp>
    00027 #include <xalanc/Include/XalanDeque.hpp>
    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 class XalanDOMString;
    00040
    00041
    00042
    00043 class XALAN_DOMSUPPORT_EXPORT XalanNamespacesStack
    00044 {
    00045 public:
    00046
    00047     class XALAN_DOMSUPPORT_EXPORT PrefixResolverProxy : public PrefixResolver
    00048     {
    00049     public:
    00050
    00059         PrefixResolverProxy(
    00060                 const XalanNamespacesStack&     theStack,
    00061                 const XalanDOMString&           theURI);
    00062
    00063         virtual
    00064         ~PrefixResolverProxy();
    00065
    00066         virtual const XalanDOMString*
    00067         getNamespaceForPrefix(const XalanDOMString&     prefix) const;
    00068
    00069         virtual const XalanDOMString&
    00070         getURI() const;
    00071
    00072     private:
    00073
    00074         const XalanNamespacesStack&     m_stack;
    00075
    00076         const XalanDOMString&           m_uri;
    00077     };
    00078
    00079     class XALAN_DOMSUPPORT_EXPORT XalanNamespacesStackEntry
    00080     {
    00081     public:
    00082
    00083         typedef XalanNamespace  value_type;
    00084
    00085         typedef XalanDeque<value_type>  NamespaceCollectionType;
    00086
    00087         typedef const XalanDOMString& (value_type::*MemberFunctionType)() const;
    00088
    00089         typedef NamespaceCollectionType::iterator                   iterator;
    00090         typedef NamespaceCollectionType::reverse_iterator           reverse_iterator;
    00091         typedef NamespaceCollectionType::const_iterator             const_iterator;
    00092         typedef NamespaceCollectionType::const_reverse_iterator     const_reverse_iterator;
    00093
    00094         XalanNamespacesStackEntry(MemoryManagerType& theManager);
    00095
    00096         XalanNamespacesStackEntry(const XalanNamespacesStackEntry&  theSource,
    00097                                     MemoryManagerType&              theManager);
    00098
    00099         ~XalanNamespacesStackEntry();
    00100
    00101         XalanNamespacesStackEntry&
    00102         set(const XalanNamespacesStackEntry&    theRHS,
    00103                   MemoryManagerType&                theManager);
    00104
    00105         void
    00106         addDeclaration(
    00107                 const XalanDOMString&       thePrefix,
    00108                 const XalanDOMChar*         theNamespaceURI,
    00109                 XalanDOMString::size_type   theLength);
    00110
    00117         const XalanDOMString*
    00118         getNamespaceForPrefix(const XalanDOMString&     thePrefix) const
    00119         {
    00120             return findEntry(thePrefix, &XalanNamespace::getPrefix, &XalanNamespace::getURI);
    00121         }
    00122
    00129         const XalanDOMString*
    00130         getPrefixForNamespace(const XalanDOMString&     theURI) const
    00131         {
    00132             return findEntry(theURI, &XalanNamespace::getURI, &XalanNamespace::getPrefix);
    00133         }
    00134
    00135         bool
    00136         isPrefixPresent(const XalanDOMString&   thePrefix) const
    00137         {
    00138             return getNamespaceForPrefix(thePrefix) == 0 ? false : true;
    00139         }
    00140
    00141         iterator
    00142         begin()
    00143         {
    00144             return m_namespaces.begin();
    00145         }
    00146
    00147         const_iterator
    00148         begin() const
    00149         {
    00150             return m_namespaces.begin();
    00151         }
    00152
    00153         iterator
    00154         end()
    00155         {
    00156             return m_position;
    00157         }
    00158
    00159         const_iterator
    00160         end() const
    00161         {
    00162             return const_iterator(m_position);
    00163         }
    00164
    00165         reverse_iterator
    00166         rbegin()
    00167         {
    00168             return reverse_iterator(end());
    00169         }
    00170
    00171         const_reverse_iterator
    00172         rbegin() const
    00173         {
    00174             return const_reverse_iterator(end());
    00175         }
    00176
    00177         reverse_iterator
    00178         rend()
    00179         {
    00180             return reverse_iterator(begin());
    00181         }
    00182
    00183         const_reverse_iterator
    00184         rend() const
    00185         {
    00186             return const_reverse_iterator(begin());
    00187         }
    00188
    00189         void
    00190         clear();
    00191
    00192         void
    00193         reset()
    00194         {
    00195             m_position = m_namespaces.begin();
    00196         }
    00197
    00198         void
    00199         swap(XalanNamespacesStackEntry&     theOther);
    00200
    00201     private:
    00202         //Not implemented
    00203         XalanNamespacesStackEntry();
    00204         XalanNamespacesStackEntry(const XalanNamespacesStackEntry&  theSource);
    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     typedef XalanDeque<value_type, ConstructWithMemoryManagerTraits<value_type> >       NamespacesStackType;
    00221     typedef XalanVector<bool>           BoolVectorType;
    00222
    00223     typedef NamespacesStackType::iterator                   iterator;
    00224     typedef NamespacesStackType::reverse_iterator           reverse_iterator;
    00225     typedef NamespacesStackType::const_iterator             const_iterator;
    00226     typedef NamespacesStackType::const_reverse_iterator     const_reverse_iterator;
    00227
    00228     typedef NamespacesStackType::size_type  size_type;
    00229
    00230     typedef const XalanDOMString* (value_type::*MemberFunctionType)(const XalanDOMString&) const;
    00231
    00232
    00233     explicit
    00234     XalanNamespacesStack(MemoryManagerType& theManager);
    00235
    00236     ~XalanNamespacesStack();
    00237
    00238     void
    00239     addDeclaration(
    00240             const XalanDOMString&   thePrefix,
    00241             const XalanDOMString&   theURI)
    00242     {
    00243         addDeclaration(
    00244             thePrefix,
    00245             theURI.c_str(),
    00246             theURI.length());
    00247     }
    00248
    00249     void
    00250     addDeclaration(
    00251             const XalanDOMString&   thePrefix,
    00252             const XalanDOMChar*     theURI)
    00253     {
    00254         addDeclaration(
    00255             thePrefix,
    00256             theURI,
    00257             length(theURI));
    00258     }
    00259
    00260     void
    00261     addDeclaration(
    00262             const XalanDOMString&       thePrefix,
    00263             const XalanDOMChar*         theURI,
    00264             XalanDOMString::size_type   theLength);
    00265
    00266     void
    00267     pushContext();
    00268
    00269     void
    00270     popContext();
    00271
    00272     const XalanDOMString*
    00273     getNamespaceForPrefix(const XalanDOMString&     thePrefix) const;
    00274
    00275     const XalanDOMString*
    00276     getPrefixForNamespace(const XalanDOMString&     theURI) const
    00277     {
    00278         return findEntry(theURI, &value_type::getPrefixForNamespace);
    00279     }
    00280
    00285     bool
    00286     prefixIsPresentLocal(const XalanDOMString&  thePrefix);
    00287
    00288     void
    00289     clear();
    00290
    00291     iterator
    00292     begin()
    00293     {
    00294         return m_stackBegin + 1;
    00295     }
    00296
    00297     const_iterator
    00298     begin() const
    00299     {
    00300         return const_iterator(m_stackBegin + 1);
    00301     }
    00302
    00303     iterator
    00304     end()
    00305     {
    00306         return m_stackPosition + 1;
    00307     }
    00308
    00309     const_iterator
    00310     end() const
    00311     {
    00312         return const_iterator(m_stackPosition + 1);
    00313     }
    00314
    00315     reverse_iterator
    00316     rbegin()
    00317     {
    00318         return reverse_iterator(end());
    00319     }
    00320
    00321     const_reverse_iterator
    00322     rbegin() const
    00323     {
    00324         return const_reverse_iterator(end());
    00325     }
    00326
    00327     reverse_iterator
    00328     rend()
    00329     {
    00330         return reverse_iterator(begin());
    00331     }
    00332
    00333     const_reverse_iterator
    00334     rend() const
    00335     {
    00336         return const_reverse_iterator(begin());
    00337     }
    00338
    00339     size_type
    00340     size() const
    00341     {
    00342         return m_resultNamespaces.size() - 1;
    00343     }
    00344
    00345     bool
    00346     empty() const
    00347     {
    00348         return NamespacesStackType::const_iterator(m_stackPosition) == m_resultNamespaces.begin() ? true : false;
    00349     }
    00350
    00351 private:
    00352
    00353     // not implemented
    00354     XalanNamespacesStack(const XalanNamespacesStack&);
    00355     XalanNamespacesStack();
    00356     XalanNamespacesStackEntry&
    00357     operator=(const XalanNamespacesStackEntry&  theRHS);
    00358
    00359     bool
    00360     operator==(const XalanNamespacesStack&) const;
    00361
    00362     XalanNamespacesStack&
    00363     operator=(const XalanNamespacesStack&);
    00364
    00365     enum { eDefaultCreateNewContextStackSize = 25 };
    00366
    00367     const XalanDOMString*
    00368     findEntry(
    00369             const XalanDOMString&   theKey,
    00370             MemberFunctionType      theFunction) const;
    00371
    00375     NamespacesStackType             m_resultNamespaces;
    00376
    00377     NamespacesStackType::iterator   m_stackBegin;
    00378
    00379     NamespacesStackType::iterator   m_stackPosition;
    00380
    00381     BoolVectorType                  m_createNewContextStack;
    00382 };
    00383
    00384
    00385
    00386 XALAN_CPP_NAMESPACE_END
    00387
    00388
    00389
    00390 #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.10 Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.