## Xalan-C++ API Documentation

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

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

# XalanArrayKeyMap.hpp

Go to the documentation of this file.

    00001 /*
    00002  * The Apache Software License, Version 1.1
    00003  *
    00004  *
    00005  * Copyright (c) 1999-2004 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_ARRAYKEYMAP_HEADER_GUARD)
    00058 #define XALAN_ARRAYKEYMAP_HEADER_GUARD
    00059
    00060
    00061
    00062 #include <deque>
    00063 #include <map>
    00064 #include <vector>
    00065
    00066
    00067
    00068 XALAN_CPP_NAMESPACE_BEGIN
    00069
    00070
    00071
    00072 template<class KeyType, class ValueType, class CompareType>
    00073 class XalanArrayKeyMap
    00074 {
    00075 public:
    00076
    00077 #if defined(XALAN_NO_STD_NAMESPACE)
    00078     typedef vector<KeyType>                                 VectorType;
    00079     typedef map<const KeyType*, ValueType, CompareType>     MapType;
    00080     typedef deque<VectorType>                               VectorHolderType;
    00081 #else
    00082     typedef std::vector<KeyType>                                VectorType;
    00083     typedef std::map<const KeyType*, ValueType, CompareType>    MapType;
    00084     typedef std::deque<VectorType>                              VectorHolderType;
    00085 #endif
    00086
    00087     typedef typename MapType::key_type                  key_type;
    00088     typedef typename MapType::value_type                value_type;
    00089     typedef ValueType                                   referent_type;
    00090     typedef CompareType                                 key_compare;
    00091 #if !defined(XALAN_NO_STD_ALLOCATORS)
    00092     typedef typename MapType::allocator_type            allocator_type;
    00093 #endif
    00094     typedef typename MapType::size_type                 size_type;
    00095     typedef typename MapType::difference_type           difference_type;
    00096     typedef typename MapType::reference                 reference;
    00097     typedef typename MapType::const_reference           const_reference;
    00098     typedef typename MapType::iterator                  iterator;
    00099     typedef typename MapType::const_iterator            const_iterator;
    00100     typedef typename MapType::reverse_iterator          reverse_iterator;
    00101     typedef typename MapType::const_reverse_iterator    const_reverse_iterator;
    00102
    00103 #if defined(XALAN_NO_STD_NAMESPACE)
    00104     typedef pair<iterator, bool>                    insert_pair_type;
    00105     typedef pair<iterator, iterator>                range_pair_type;
    00106     typedef pair<const_iterator, const_iterator>    const_range_pair_type;
    00107 #else
    00108     typedef std::pair<iterator, bool>                   insert_pair_type;
    00109     typedef std::pair<iterator, iterator>               range_pair_type;
    00110     typedef std::pair<const_iterator, const_iterator>   const_range_pair_type;
    00111 #endif
    00112
    00113     explicit
    00114     XalanArrayKeyMap() :
    00115         m_map(),
    00116         m_keyData()
    00117     {
    00118     }
    00119
    00120     XalanArrayKeyMap(const XalanArrayKeyMap<KeyType, ValueType, CompareType>&   theOther)
    00121     {
    00122         *this = theOther;
    00123     }
    00124
    00125     ~XalanArrayKeyMap()
    00126     {
    00127     }
    00128
    00129     XalanArrayKeyMap<KeyType, ValueType, CompareType>&
    00130 	operator=(const XalanArrayKeyMap<KeyType, ValueType, CompareType>& theRHS)
    00131     {
    00132         if (&theRHS != this)
    00133         {
    00134             XalanArrayKeyMap<KeyType, ValueType, CompareType>   theTemp;
    00135
    00136             const const_iterator    theEnd =
    00137                 theRHS.end();
    00138
    00139             const_iterator  i = theRHS.begin();
    00140
    00141             while(i != theEnd)
    00142             {
    00143                 theTemp.insert(*i);
    00144
    00145                 ++i;
    00146             }
    00147
    00148             swap(theTemp);
    00149         }
    00150
    00151         return *this;
    00152     }
    00153
    00154     bool
    00155 	operator==(const XalanArrayKeyMap<KeyType, ValueType, CompareType>&        theRHS) const
    00156     {
    00157         return m_map == theRHS.m_map;
    00158     }
    00159
    00160     size_type
    00161     size() const
    00162     {
    00163         return m_map.size();
    00164     }
    00165
    00166     size_type
    00167     max_size() const
    00168     {
    00169         return m_map.max_size();
    00170     }
    00171
    00172     bool
    00173     empty() const
    00174     {
    00175         return m_map.empty();
    00176     }
    00177
    00178     iterator
    00179     begin()
    00180     {
    00181         return m_map.begin();
    00182     }
    00183
    00184     const_iterator
    00185     begin() const
    00186     {
    00187         return m_map.begin();
    00188     }
    00189
    00190     iterator
    00191     end()
    00192     {
    00193         return m_map.end();
    00194     }
    00195
    00196     const_iterator
    00197     end() const
    00198     {
    00199         return m_map.end();
    00200     }
    00201
    00202     reverse_iterator
    00203     rbegin()
    00204     {
    00205         return m_map.rbegin();
    00206     }
    00207
    00208     const_reverse_iterator
    00209     rbegin() const
    00210     {
    00211         return m_map.rbegin();
    00212     }
    00213
    00214     reverse_iterator
    00215     rend()
    00216     {
    00217         return m_map.rend();
    00218     }
    00219
    00220     const_reverse_iterator
    00221     rend() const
    00222     {
    00223         return m_map.rend();
    00224     }
    00225
    00226     insert_pair_type
    00227     insert(const value_type&    thePair)
    00228     {
    00229         m_keyData.push_back(VectorHolderType::value_type(thePair.first, thePair.first + (length(thePair.first) + 1)));
    00230
    00231         return m_map.insert(value_type(&*m_keyData.back().begin(), thePair.second));
    00232     }
    00233
    00234     referent_type&
    00235 	operator[](const key_type& theKey)
    00236     {
    00237         const iterator  i = find(theKey);
    00238
    00239         if (i == end())
    00240         {
    00241             return (*(insert(value_type(theKey, referent_type()))).first).second;
    00242         }
    00243         else
    00244         {
    00245             return (*i).second;
    00246         }
    00247     }
    00248
    00249     iterator
    00250     find(const key_type&    theKey)
    00251     {
    00252         return m_map.find(theKey);
    00253     }
    00254
    00255     const_iterator
    00256     find(const key_type&    theKey) const
    00257     {
    00258         return m_map.find(theKey);
    00259     }
    00260
    00261     iterator
    00262     lower_bound(const key_type&     theKey)
    00263     {
    00264         return m_map.lower_bound(theKey);
    00265     }
    00266
    00267     const_iterator
    00268     lower_bound(const key_type&     theKey) const
    00269     {
    00270         return m_map.lower_bound(theKey);
    00271     }
    00272
    00273     iterator
    00274     upper_bound(const key_type&     theKey)
    00275     {
    00276         return m_map.upper_bound(theKey);
    00277     }
    00278
    00279     const_iterator
    00280     upper_bound(const key_type&     theKey) const
    00281     {
    00282         return m_map.upper_bound(theKey);
    00283     }
    00284
    00285     range_pair_type
    00286     equal_range(const key_type&     theKey)
    00287     {
    00288         return m_map.equal_range(theKey);
    00289     }
    00290
    00291     const_range_pair_type
    00292     equal_range(const key_type&     theKey) const
    00293     {
    00294         return m_map.equal_range(theKey);
    00295     }
    00296
    00297 #if defined(XALAN_STLPORT_STL) && !defined(__STL_MEMBER_TEMPLATES)
    00298     void
    00299     erase(iterator  theIterator)
    00300     {
    00301         // $$$ ToDo: Does not empty vector in the
    00302         // deque!!!
    00303         m_map.erase(theIterator);
    00304     }
    00305
    00306     void
    00307     erase(
    00308             iterator    theFirst,
    00309             iterator    theLast)
    00310     {
    00311         // $$$ ToDo: Does not empty vector in the
    00312         // deque!!!
    00313         m_map.erase(theFirst, theLast);
    00314     }
    00315 #else
    00316     iterator
    00317     erase(iterator  theIterator)
    00318     {
    00319         // $$$ ToDo: Does not empty vector in the
    00320         // deque!!!
    00321         return m_map.erase(theIterator);
    00322     }
    00323
    00324     iterator
    00325     erase(
    00326             iterator    theFirst,
    00327             iterator    theLast)
    00328     {
    00329         // $$$ ToDo: Does not empty vector in the
    00330         // deque!!!
    00331         return m_map.erase(theFirst, theLast);
    00332     }
    00333 #endif
    00334
    00335     size_type
    00336     erase(const key_type&   theKey)
    00337     {
    00338         // $$$ ToDo: Does not empty vector in the
    00339         // deque!!!
    00340         return m_map.erase(theKey);
    00341     }
    00342
    00343     void
    00344     swap(XalanArrayKeyMap<KeyType, ValueType, CompareType>&     theOther)
    00345     {
    00346         m_map.swap(theOther.m_map);
    00347
    00348         m_keyData.swap(theOther.m_keyData);
    00349     }
    00350
    00351 private:
    00352
    00353     size_type
    00354     length(const key_type&  theKey)
    00355     {
    00356         key_type    theCurrent = theKey;
    00357
    00358         while(*theCurrent != 0)
    00359         {
    00360             ++theCurrent;
    00361         }
    00362
    00363         return theCurrent - theKey;
    00364     }
    00365
    00366     MapType             m_map;
    00367
    00368     VectorHolderType    m_keyData;
    00369 };
    00370
    00371
    00372
    00373 XALAN_CPP_NAMESPACE_END
    00374
    00375
    00376
    00377 #endif

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