## Xalan-C++ API Documentation

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

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  * 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(XALAN_XALANNAMESPACESSTACK_HEADER_GUARD)
    00058 #define XALAN_XALANNAMESPACESSTACK_HEADER_GUARD
    00059
    00060
    00061
    00062 // Base include file.  Must be first.
    00063 #include <xalanc/DOMSupport/DOMSupportDefinitions.hpp>
    00064
    00065
    00066
    00067 #include <deque>
    00068 #include <vector>
    00069
    00070
    00071
    00072 #include <xalanc/PlatformSupport/PrefixResolver.hpp>
    00073 #include <xalanc/PlatformSupport/XalanNamespace.hpp>
    00074
    00075
    00076
    00077 XALAN_CPP_NAMESPACE_BEGIN
    00078
    00079
    00080
    00081 class XalanDOMString;
    00082
    00083
    00084
    00085 class XALAN_DOMSUPPORT_EXPORT XalanNamespacesStack
    00086 {
    00087 public:
    00088
    00089     class XALAN_DOMSUPPORT_EXPORT PrefixResolverProxy : public PrefixResolver
    00090     {
    00091     public:
    00092
    00101         PrefixResolverProxy(
    00102                 const XalanNamespacesStack&     theStack,
    00103                 const XalanDOMString&           theURI);
    00104
    00105         virtual
    00106         ~PrefixResolverProxy();
    00107
    00108         virtual const XalanDOMString*
    00109         getNamespaceForPrefix(const XalanDOMString&     prefix) const;
    00110
    00111         virtual const XalanDOMString&
    00112         getURI() const;
    00113
    00114     private:
    00115
    00116         const XalanNamespacesStack&     m_stack;
    00117
    00118         const XalanDOMString&           m_uri;
    00119     };
    00120
    00121     class XALAN_DOMSUPPORT_EXPORT XalanNamespacesStackEntry
    00122     {
    00123     public:
    00124
    00125         typedef XalanNamespace  value_type;
    00126
    00127 #if defined(XALAN_NO_STD_NAMESPACE)
    00128         typedef deque<value_type>       NamespaceCollectionType;
    00129 #else
    00130         typedef std::deque<value_type>  NamespaceCollectionType;
    00131 #endif
    00132
    00133         typedef const XalanDOMString& (value_type::*MemberFunctionType)() const;
    00134
    00135         typedef NamespaceCollectionType::iterator                   iterator;
    00136         typedef NamespaceCollectionType::reverse_iterator           reverse_iterator;
    00137         typedef NamespaceCollectionType::const_iterator             const_iterator;
    00138         typedef NamespaceCollectionType::const_reverse_iterator     const_reverse_iterator;
    00139
    00140         XalanNamespacesStackEntry();
    00141
    00142         XalanNamespacesStackEntry(const XalanNamespacesStackEntry&  theSource);
    00143
    00144         ~XalanNamespacesStackEntry();
    00145
    00146         XalanNamespacesStackEntry&
    00147         operator=(const XalanNamespacesStackEntry&  theRHS);
    00148
    00149         void
    00150         addDeclaration(
    00151                 const XalanDOMString&       thePrefix,
    00152                 const XalanDOMChar*         theNamespaceURI,
    00153                 XalanDOMString::size_type   theLength);
    00154
    00161         const XalanDOMString*
    00162         getNamespaceForPrefix(const XalanDOMString&     thePrefix) const
    00163         {
    00164             return findEntry(thePrefix, &XalanNamespace::getPrefix, &XalanNamespace::getURI);
    00165         }
    00166
    00173         const XalanDOMString*
    00174         getPrefixForNamespace(const XalanDOMString&     theURI) const
    00175         {
    00176             return findEntry(theURI, &XalanNamespace::getURI, &XalanNamespace::getPrefix);
    00177         }
    00178
    00179         bool
    00180         isPrefixPresent(const XalanDOMString&   thePrefix) const
    00181         {
    00182             return getNamespaceForPrefix(thePrefix) == 0 ? false : true;
    00183         }
    00184
    00185         iterator
    00186         begin()
    00187         {
    00188             return m_namespaces.begin();
    00189         }
    00190
    00191         const_iterator
    00192         begin() const
    00193         {
    00194             return m_namespaces.begin();
    00195         }
    00196
    00197         iterator
    00198         end()
    00199         {
    00200             return m_position;
    00201         }
    00202
    00203         const_iterator
    00204         end() const
    00205         {
    00206             return const_iterator(m_position);
    00207         }
    00208
    00209         reverse_iterator
    00210         rbegin()
    00211         {
    00212             return reverse_iterator(end());
    00213         }
    00214
    00215         const_reverse_iterator
    00216         rbegin() const
    00217         {
    00218             return const_reverse_iterator(end());
    00219         }
    00220
    00221         reverse_iterator
    00222         rend()
    00223         {
    00224             return reverse_iterator(begin());
    00225         }
    00226
    00227         const_reverse_iterator
    00228         rend() const
    00229         {
    00230             return const_reverse_iterator(begin());
    00231         }
    00232
    00233         void
    00234         clear();
    00235
    00236         void
    00237         reset()
    00238         {
    00239             m_position = m_namespaces.begin();
    00240         }
    00241
    00242         void
    00243         swap(XalanNamespacesStackEntry&     theOther);
    00244
    00245     private:
    00246
    00247         const XalanDOMString*
    00248         findEntry(
    00249             const XalanDOMString&   theKey,
    00250             MemberFunctionType      theKeyFunction,
    00251             MemberFunctionType      theValueFunction) const;
    00252
    00253         NamespaceCollectionType     m_namespaces;
    00254
    00255         iterator                    m_position;
    00256     };
    00257
    00258
    00259     typedef XalanNamespacesStackEntry   value_type;
    00260
    00261 #if defined(XALAN_NO_STD_NAMESPACE)
    00262     typedef deque<value_type>       NamespacesStackType;
    00263 #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
    00264     typedef deque<bool>             BoolVectorType;
    00265 #else
    00266     typedef vector<bool>            BoolVectorType;
    00267 #endif
    00268 #else
    00269     typedef std::deque<value_type>  NamespacesStackType;
    00270 #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
    00271     typedef std::deque<bool>        BoolVectorType;
    00272 #else
    00273     typedef std::vector<bool>       BoolVectorType;
    00274 #endif
    00275 #endif
    00276
    00277     typedef NamespacesStackType::iterator                   iterator;
    00278     typedef NamespacesStackType::reverse_iterator           reverse_iterator;
    00279     typedef NamespacesStackType::const_iterator             const_iterator;
    00280     typedef NamespacesStackType::const_reverse_iterator     const_reverse_iterator;
    00281
    00282     typedef NamespacesStackType::size_type  size_type;
    00283
    00284     typedef const XalanDOMString* (value_type::*MemberFunctionType)(const XalanDOMString&) const;
    00285
    00286
    00287     explicit
    00288     XalanNamespacesStack();
    00289
    00290     ~XalanNamespacesStack();
    00291
    00292     void
    00293     addDeclaration(
    00294             const XalanDOMString&   thePrefix,
    00295             const XalanDOMString&   theURI)
    00296     {
    00297         addDeclaration(
    00298             thePrefix,
    00299             theURI.c_str(),
    00300             theURI.length());
    00301     }
    00302
    00303     void
    00304     addDeclaration(
    00305             const XalanDOMString&   thePrefix,
    00306             const XalanDOMChar*     theURI)
    00307     {
    00308         addDeclaration(
    00309             thePrefix,
    00310             theURI,
    00311             length(theURI));
    00312     }
    00313
    00314     void
    00315     addDeclaration(
    00316             const XalanDOMString&       thePrefix,
    00317             const XalanDOMChar*         theURI,
    00318             XalanDOMString::size_type   theLength);
    00319
    00320     void
    00321     pushContext();
    00322
    00323     void
    00324     popContext();
    00325
    00326     const XalanDOMString*
    00327     getNamespaceForPrefix(const XalanDOMString&     thePrefix) const;
    00328
    00329     const XalanDOMString*
    00330     getPrefixForNamespace(const XalanDOMString&     theURI) const
    00331     {
    00332         return findEntry(theURI, &value_type::getPrefixForNamespace);
    00333     }
    00334
    00339     bool
    00340     prefixIsPresentLocal(const XalanDOMString&  thePrefix);
    00341
    00342     void
    00343     clear();
    00344
    00345     iterator
    00346     begin()
    00347     {
    00348         return m_stackBegin + 1;
    00349     }
    00350
    00351     const_iterator
    00352     begin() const
    00353     {
    00354         return const_iterator(m_stackBegin + 1);
    00355     }
    00356
    00357     iterator
    00358     end()
    00359     {
    00360         return m_stackPosition + 1;
    00361     }
    00362
    00363     const_iterator
    00364     end() const
    00365     {
    00366         return const_iterator(m_stackPosition + 1);
    00367     }
    00368
    00369     reverse_iterator
    00370     rbegin()
    00371     {
    00372         return reverse_iterator(end());
    00373     }
    00374
    00375     const_reverse_iterator
    00376     rbegin() const
    00377     {
    00378         return const_reverse_iterator(end());
    00379     }
    00380
    00381     reverse_iterator
    00382     rend()
    00383     {
    00384         return reverse_iterator(begin());
    00385     }
    00386
    00387     const_reverse_iterator
    00388     rend() const
    00389     {
    00390         return const_reverse_iterator(begin());
    00391     }
    00392
    00393     size_type
    00394     size() const
    00395     {
    00396         return m_resultNamespaces.size() - 1;
    00397     }
    00398
    00399     bool
    00400     empty() const
    00401     {
    00402         return NamespacesStackType::const_iterator(m_stackPosition) == m_resultNamespaces.begin() ? true : false;
    00403     }
    00404
    00405 private:
    00406
    00407     // not implemented
    00408     XalanNamespacesStack(const XalanNamespacesStack&);
    00409
    00410     bool
    00411     operator==(const XalanNamespacesStack&) const;
    00412
    00413     XalanNamespacesStack&
    00414     operator=(const XalanNamespacesStack&);
    00415
    00416     enum { eDefaultCreateNewContextStackSize = 25 };
    00417
    00418     const XalanDOMString*
    00419     findEntry(
    00420             const XalanDOMString&   theKey,
    00421             MemberFunctionType      theFunction) const;
    00422
    00426     NamespacesStackType             m_resultNamespaces;
    00427
    00428     NamespacesStackType::iterator   m_stackBegin;
    00429
    00430     NamespacesStackType::iterator   m_stackPosition;
    00431
    00432     BoolVectorType                  m_createNewContextStack;
    00433 };
    00434
    00435
    00436
    00437 XALAN_CPP_NAMESPACE_END
    00438
    00439
    00440
    00441 #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.6 Copyright © 2000, 2001, 2002, 2003 The Apache Software Foundation. All Rights Reserved.