Xalan-C++ API Documentation

The Xalan C++ XSL Transformer Version 1.1

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

XalanDOMString.hpp

Go to the documentation of this file.
00001 /*
00002  * The Apache Software License, Version 1.1
00003  *
00004  *
00005  * Copyright (c) 1999 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(XALANDOMSTRING_HEADER_GUARD_1357924680)
00058 #define XALANDOMSTRING_HEADER_GUARD_1357924680
00059 
00060 
00061 
00062 #include <XalanDOM/XalanDOMDefinitions.hpp>
00063 
00064 
00065 
00066 #include <vector>
00067 
00068 
00069 
00070 #include <XalanDOM/XalanDOMException.hpp>
00071 
00072 
00073 
00074 // UTF-16 character...
00075 typedef unsigned short  XalanDOMChar;
00076 
00077 
00078 
00079 #include <cassert>
00080 
00081 
00082 
00083 class XALAN_DOM_EXPORT XalanDOMString
00084 {
00085 public:
00086 
00087 #if defined(XALAN_NO_NAMESPACES)
00088     typedef vector<XalanDOMChar>        XalanDOMCharVectorType;
00089     typedef vector<char>                CharVectorType;
00090     typedef vector<wchar_t>             WideCharVectorType;
00091 #else
00092     typedef std::vector<XalanDOMChar>   XalanDOMCharVectorType;
00093     typedef std::vector<char>           CharVectorType;
00094     typedef std::vector<wchar_t>        WideCharVectorType;
00095 #endif
00096 
00097     typedef XalanDOMChar                value_type;
00098     typedef XalanDOMChar&               reference;
00099     typedef const XalanDOMChar&         const_reference;
00100 
00101     // We're stuck with 32-bit lengths because of the DOMs IDL
00102     // bindings.  Ideally, we'ed like to re-visit this in the
00103     // future.  See typedef below of real_size_type.
00104     typedef unsigned int                                    size_type;
00105     typedef XalanDOMCharVectorType::size_type               real_size_type;
00106 
00107     typedef XalanDOMCharVectorType::iterator                iterator;
00108     typedef XalanDOMCharVectorType::const_iterator          const_iterator;
00109     typedef XalanDOMCharVectorType::reverse_iterator        reverse_iterator;
00110     typedef XalanDOMCharVectorType::const_reverse_iterator  const_reverse_iterator;
00111 
00112 #if defined(XALAN_INLINE_INITIALIZATION)
00113     static const size_type  npos = ~0u;
00114 #else
00115     enum { npos = -1 };
00116 #endif
00117 
00118     explicit
00119     XalanDOMString();
00120 
00121     explicit
00122     XalanDOMString(
00123             const char*     theString,
00124             size_type       theCount = size_type(npos));
00125 
00126     XalanDOMString(
00127             const XalanDOMString&   theSource,
00128             size_type               theStartPosition = 0,
00129             size_type               theCount = size_type(npos));
00130 
00131     explicit
00132     XalanDOMString(
00133             const XalanDOMChar*     theString,
00134             size_type               theCount = size_type(npos));
00135 
00136     XalanDOMString(
00137             size_type       theCount,
00138             XalanDOMChar    theChar);
00139 
00140     ~XalanDOMString()
00141     {
00142     }
00143 
00144     XalanDOMString&
00145     operator=(const XalanDOMString& theRHS)
00146     {
00147         return assign(theRHS);
00148     }
00149 
00150     XalanDOMString&
00151     operator=(const XalanDOMChar*   theRHS)
00152     {
00153         return assign(theRHS);
00154     }
00155 
00156     XalanDOMString&
00157     operator=(const char*   theRHS)
00158     {
00159         return assign(theRHS);
00160     }
00161 
00162     XalanDOMString&
00163     operator=(XalanDOMChar  theRHS)
00164     {
00165         return assign(1, theRHS);
00166     }
00167 
00168     iterator
00169     begin()
00170     {
00171         invariants();
00172 
00173         return m_data.begin();
00174     }
00175 
00176     const_iterator
00177     begin() const
00178     {
00179         invariants();
00180 
00181         return m_data.begin();
00182     }
00183 
00184     reverse_iterator
00185     rbegin()
00186     {
00187         invariants();
00188 
00189         return m_data.rbegin();
00190     }
00191 
00192     const_reverse_iterator
00193     rbegin() const
00194     {
00195         invariants();
00196 
00197         return m_data.rbegin();
00198     }
00199 
00200     size_type
00201     size() const
00202     {
00203         invariants();
00204 
00205         return m_size;
00206     }
00207 
00208     size_type
00209     length() const
00210     {
00211         invariants();
00212 
00213         return size();
00214     }
00215 
00216     size_type
00217     max_size() const
00218     {
00219         invariants();
00220 
00221         return size_type(~0);
00222     }
00223 
00224     void
00225     resize(
00226             size_type       theCount,
00227             XalanDOMChar    theChar);
00228 
00229     void
00230     resize(size_type    theCount)
00231     {
00232         invariants();
00233 
00234         resize(theCount, XalanDOMChar(0));
00235     }
00236 
00237     size_type
00238     capacity() const
00239     {
00240         invariants();
00241 
00242         assert(real_size_type(size_type(m_data.capacity())) == m_data.capacity());
00243 
00244         return size_type(m_data.capacity()) - 1;
00245     }
00246 
00247     void
00248     reserve(size_type   theCount = 0)
00249     {
00250         invariants();
00251 
00252         m_data.reserve(real_size_type(theCount) + 1);
00253     }
00254 
00255     void
00256     clear()
00257     {
00258         invariants();
00259 
00260         m_data.erase(m_data.begin(), m_data.end());
00261 
00262         m_size = 0;
00263 
00264         invariants();
00265     }
00266 
00267     void
00268     erase(
00269             size_type   theStartPosition = 0,
00270             size_type   theCount = size_type(npos));
00271 
00272     bool
00273     empty() const
00274     {
00275         invariants();
00276 
00277         return m_size == 0 ? true : false;
00278     }
00279 
00280     const_reference
00281     operator[](size_type    theIndex) const
00282     {
00283         invariants();
00284 
00285         return m_data[real_size_type(theIndex)];
00286     }
00287 
00288     reference
00289     operator[](size_type    theIndex)
00290     {
00291         invariants();
00292 
00293         return m_data[real_size_type(theIndex)];
00294     }
00295 
00296 #if 0
00297     // $$$ ToDo: at() is not supported in the current version of GCC's vector<>
00298     // implementation.  Eventually, it should be.
00299     const_reference
00300     at(size_type    theIndex) const
00301     {
00302         invariants();
00303 
00304         return m_data.at(real_size_type(theIndex));
00305     }
00306 
00307     reference
00308     at(size_type    theIndex)
00309     {
00310         invariants();
00311 
00312         return m_data.at(real_size_type(theIndex));
00313     }
00314 #endif
00315 
00316     const XalanDOMChar*
00317     c_str() const
00318     {
00319         invariants();
00320 
00321         // $$$ ToDo: Do we really want to do this?
00322         // for convenience, we will return a pointer to
00323         // a default empty string so that c_str() never
00324         // returns a null pointer...
00325         return m_data.size() == 0 ? &s_empty : &m_data[0];
00326     }
00327 
00328     const XalanDOMChar*
00329     data() const
00330     {
00331         invariants();
00332 
00333         return c_str();
00334     }
00335 
00336     void
00337     swap(XalanDOMString&    theOther)
00338     {
00339         invariants();
00340 
00341         m_data.swap(theOther.m_data);
00342 
00343 #if defined(XALAN_NO_NAMESPACES)
00344         ::swap(m_size, theOther.m_size);
00345 #else
00346         std::swap(m_size, theOther.m_size);
00347 #endif
00348     }
00349 
00350     XalanDOMString&
00351     operator+=(const XalanDOMString&    theSource)
00352     {
00353         return append(theSource);
00354     }
00355 
00356     XalanDOMString&
00357     operator+=(const XalanDOMChar*  theString)
00358     {
00359         return append(theString);
00360     }
00361 
00362     XalanDOMString&
00363     operator+=(XalanDOMChar theChar)
00364     {
00365         append(1, theChar);
00366 
00367         return *this;
00368     }
00369 
00370     XalanDOMString&
00371     assign(const XalanDOMChar*  theSource)
00372     {
00373         invariants();
00374 
00375         erase();
00376 
00377         invariants();
00378 
00379         return append(theSource);
00380     }
00381 
00382     XalanDOMString&
00383     assign(
00384             const XalanDOMChar*     theSource,
00385             size_type               theCount)
00386     {
00387         invariants();
00388 
00389         erase();
00390 
00391         invariants();
00392 
00393         return append(theSource, theCount);
00394     }
00395 
00396     XalanDOMString&
00397     assign(const char*  theSource)
00398     {
00399         invariants();
00400 
00401         erase();
00402 
00403         invariants();
00404 
00405         return append(theSource);
00406     }
00407 
00408     XalanDOMString&
00409     assign(
00410             const char*     theSource,
00411             size_type       theCount)
00412     {
00413         invariants();
00414 
00415         erase();
00416 
00417         invariants();
00418 
00419         return append(theSource, theCount);
00420     }
00421 
00422     XalanDOMString&
00423     assign(
00424             const XalanDOMString&   theSource,
00425             size_type               thePosition,
00426             size_type               theCount)
00427     {
00428         invariants();
00429 
00430         if (&theSource != this)
00431         {
00432             erase();
00433 
00434             append(theSource, thePosition, theCount);
00435         }
00436 
00437         invariants();
00438 
00439         return *this;
00440     }
00441 
00442     XalanDOMString&
00443     assign(const XalanDOMString&    theSource)
00444     {
00445         invariants();
00446 
00447         if (&theSource != this)
00448         {
00449             m_data = theSource.m_data;
00450 
00451             m_size = theSource.m_size;
00452         }
00453 
00454         invariants();
00455 
00456         return *this;
00457     }
00458 
00459     XalanDOMString&
00460     assign(
00461             size_type       theCount,
00462             XalanDOMChar    theChar)
00463     {
00464         invariants();
00465 
00466         erase();
00467 
00468         invariants();
00469 
00470         return append(theCount, theChar);
00471     }
00472 
00473     XalanDOMString&
00474     assign(
00475         const_iterator  theFirstPosition,
00476         const_iterator  theLastPosition);
00477 
00478     XalanDOMString&
00479     append(const XalanDOMString&    theSource)
00480     {
00481         return append(theSource.c_str(), theSource.length());
00482     }
00483 
00484     XalanDOMString&
00485     append(
00486             const XalanDOMString&   theSource,
00487             size_type               thePosition,
00488             size_type               theCount)
00489     {
00490         assert(thePosition < theSource.length() &&
00491                (theCount == size_type(npos) || thePosition + theCount <= theSource.length()));
00492 
00493         return append(theSource.c_str() + thePosition, theCount);
00494     }
00495 
00496     XalanDOMString&
00497     append(
00498             const XalanDOMChar*     theString,
00499             size_type               theCount);
00500 
00501     XalanDOMString&
00502     append(const XalanDOMChar*  theString)
00503     {
00504         return append(theString, length(theString));
00505     }
00506 
00507     XalanDOMString&
00508     append(
00509             const char*     theString,
00510             size_type       theCount);
00511 
00512     XalanDOMString&
00513     append(const char*  theString)
00514     {
00515         return append(theString, length(theString));
00516     }
00517 
00518     XalanDOMString&
00519     append(
00520             size_type       theCount,
00521             XalanDOMChar    theChar);
00522 
00523     void
00524     push_back(XalanDOMChar  theChar)
00525     {
00526         invariants();
00527 
00528         append(1, theChar);
00529 
00530         invariants();
00531     }
00532 
00533     XalanDOMString&
00534     insert(
00535             size_type               thePosition,
00536             const XalanDOMString&   theString)
00537     {
00538         return insert(thePosition, theString.c_str(), theString.length());
00539     }
00540 
00541     XalanDOMString&
00542     insert(
00543             size_type               thePosition1,
00544             const XalanDOMString&   theString,
00545             size_type               thePosition2,
00546             size_type               theCount)
00547     {
00548         return insert(thePosition1, theString.c_str() + thePosition2, theCount);
00549     }
00550 
00551     XalanDOMString&
00552     insert(
00553             size_type               thePosition,
00554             const XalanDOMChar*     theString,
00555             size_type               theCount);
00556 
00557     XalanDOMString&
00558     insert(
00559             size_type               thePosition,
00560             const XalanDOMChar*     theString)
00561     {
00562         return insert(thePosition, theString, length(theString));
00563     }
00564 
00565     XalanDOMString&
00566     insert(
00567             size_type       thePosition,
00568             size_type       theCount,
00569             XalanDOMChar    theChar);
00570 
00571     iterator
00572     insert(
00573             iterator        thePosition,
00574             XalanDOMChar    theChar);
00575 
00576     void
00577     insert(
00578             iterator        thePosition,
00579             size_type       theCount,
00580             XalanDOMChar    theChar);
00581 
00582     void
00583     insert(
00584         iterator        theInsertPosition,
00585         const_iterator  theFirstPosition,
00586         const_iterator  theLastPosition);
00587 
00588     XalanDOMString
00589     substr(
00590             size_type   thePosition = 0,
00591             size_type   theCount = size_type(npos)) const
00592     {
00593         assert(theCount == size_type(npos) && thePosition < length() ||
00594                thePosition + theCount <= length());
00595 
00596         invariants();
00597 
00598         return XalanDOMString(*this, thePosition, theCount);
00599     }
00600 
00601     XalanDOMString&
00602     substr(
00603             XalanDOMString&     theSubstring,
00604             size_type           thePosition = 0,
00605             size_type           theCount = size_type(npos)) const
00606     {
00607         assert(theCount == size_type(npos) && thePosition < length() ||
00608                thePosition + theCount <= length());
00609 
00610         invariants();
00611 
00612         return theSubstring.assign(*this, thePosition, theCount);
00613     }
00614 
00615     int
00616     compare(const XalanDOMString&   theString) const
00617     {
00618         invariants();
00619 
00620         return compare(theString.c_str());
00621     }
00622 
00623     int
00624     compare(
00625             size_type               thePosition1,
00626             size_type               theCount1,
00627             const XalanDOMString&   theString) const
00628     {
00629         invariants();
00630 
00631         return compare(thePosition1, theCount1, theString.c_str(), theString.length());
00632     }
00633 
00634     int
00635     compare(
00636             size_type               thePosition1,
00637             size_type               theCount1,
00638             const XalanDOMString&   theString,
00639             size_type               thePosition2,
00640             size_type               theCount2) const
00641     {
00642         invariants();
00643 
00644         return compare(thePosition1, theCount1, theString.c_str() + thePosition2, theCount2);
00645     }
00646 
00647     int
00648     compare(const XalanDOMChar*     theString) const;
00649 
00650     int
00651     compare(
00652             size_type               thePosition1,
00653             size_type               theCount1,
00654             const XalanDOMChar*     theString,
00655             size_type               theCount2 = size_type(npos)) const;
00656 
00657     int
00658     compare(const char*     theString) const
00659     {
00660         invariants();
00661 
00662         return compare(XalanDOMString(theString));
00663     }
00664 
00665     int
00666     compare(
00667             size_type       thePosition1,
00668             size_type       theCount1,
00669             const char*     theString,
00670             size_type       theCount2 = size_type(npos)) const
00671     {
00672         invariants();
00673 
00674         return compare(thePosition1, theCount1, XalanDOMString(theString, theCount2));
00675     }
00676 
00677     CharVectorType
00678     transcode() const;
00679 
00680     static bool
00681     equals(
00682             const XalanDOMChar*     theLHS,
00683             size_type               theLHSLength,
00684             const XalanDOMChar*     theRHS,
00685             size_type               theRHSLength);
00686 
00687     static bool
00688     equals(
00689             const XalanDOMChar*     theLHS,
00690             const XalanDOMChar*     theRHS)
00691     {
00692         return equals(theLHS, length(theLHS), theRHS, length(theRHS));
00693     }
00694 
00695     static bool
00696     equals(
00697             const XalanDOMString&   theLHS,
00698             const XalanDOMString&   theRHS);
00699 
00700     static bool
00701     equals(
00702             const XalanDOMString&   theLHS,
00703             const XalanDOMChar*     theRHS)
00704     {
00705         return equals(theLHS.c_str(), theRHS);
00706     }
00707 
00708     static bool
00709     equals(
00710             const XalanDOMChar*     theLHS,
00711             const XalanDOMString&   theRHS)
00712     {
00713         return equals(theLHS, theRHS.c_str());
00714     }
00715 
00716     /*
00717      * Helper function to determine the length of a null-
00718      * terminated string.
00719      *
00720      * @theString The string
00721      * @return the length
00722      */
00723     static size_type
00724     length(const XalanDOMChar*  theString);
00725 
00726     /*
00727      * Helper function to determine the length of a null-
00728      * terminated string.
00729      *
00730      * @theString The string
00731      * @return the length
00732      */
00733     static size_type
00734     length(const char*  theString);
00735 
00736     class TranscodingError : public XalanDOMException
00737     {
00738     public:
00739 
00740         TranscodingError() :
00741             XalanDOMException(TRANSCODING_ERR)
00742         {
00743         }
00744 
00745         virtual
00746         ~TranscodingError()
00747         {
00748         }
00749     };
00750 
00751 protected:
00752 
00753     /*
00754      * Function to assert invariant conditions for the class.
00755      *
00756      * @return the iterator
00757      */
00758     void
00759     invariants() const
00760     {
00761 #if !defined(NDEBUG)
00762         assert((m_data.size() == 0 && m_size == 0) || m_size == m_data.size() - 1);
00763         assert(m_data.size() == 0 || m_data.back() == 0);
00764 #endif
00765     }
00766 
00767     /*
00768      * Get an iterator to the position of the terminating null.
00769      *
00770      * @return the iterator
00771      */
00772     iterator
00773     getBackInsertIterator()
00774     {
00775         invariants();
00776 
00777         return m_data.size() == 0 ? m_data.end() : m_data.end() - 1;
00778     }
00779 
00780     const_iterator
00781     getBackInsertIterator() const
00782     {
00783         invariants();
00784 
00785         return m_data.size() == 0 ? m_data.end() : m_data.end() - 1;
00786     }
00787 
00788     iterator
00789     getIteratorForPosition(size_type    thePosition)
00790     {
00791         invariants();
00792 
00793         return m_data.begin() + thePosition;
00794     }
00795 
00796     const_iterator
00797     getIteratorForPosition(size_type    thePosition) const
00798     {
00799         invariants();
00800 
00801         return m_data.begin() + thePosition;
00802     }
00803 
00804 private:
00805 
00806     XalanDOMCharVectorType      m_data;
00807 
00808     size_type                   m_size;
00809 
00810     static const XalanDOMChar   s_empty;
00811 };
00812 
00813 
00814 
00815 inline bool
00816 operator==(
00817             const XalanDOMString&   theLHS,
00818             const XalanDOMString&   theRHS)
00819 {
00820     return XalanDOMString::equals(theLHS, theRHS);
00821 }
00822 
00823 
00824 
00825 inline bool
00826 operator==(
00827             const XalanDOMString&   theLHS,
00828             const XalanDOMChar*     theRHS)
00829 {
00830     return XalanDOMString::equals(theLHS, theRHS);
00831 }
00832 
00833 
00834 
00835 inline bool
00836 operator==(
00837             const XalanDOMChar*     theLHS,
00838             const XalanDOMString&   theRHS)
00839 {
00840     // Note reversing of operands...
00841     return XalanDOMString::equals(theLHS, theRHS);
00842 }
00843 
00844 
00845 
00846 inline bool
00847 operator!=(
00848             const XalanDOMString&   theLHS,
00849             const XalanDOMString&   theRHS)
00850 {
00851     return !(theLHS == theRHS);
00852 }
00853 
00854 
00855 
00856 inline bool
00857 operator!=(
00858             const XalanDOMChar*     theLHS,
00859             const XalanDOMString&   theRHS)
00860 {
00861     return !(theLHS == theRHS);
00862 }
00863 
00864 
00865 
00866 inline bool
00867 operator!=(
00868             const XalanDOMString&   theLHS,
00869             const XalanDOMChar*     theRHS)
00870 {
00871     return !(theRHS == theLHS);
00872 }
00873 
00874 
00875 
00876 inline XalanDOMString
00877 operator+(
00878             const XalanDOMString&   theLHS,
00879             const XalanDOMString&   theRHS)
00880 {
00881     XalanDOMString  theTemp(theLHS);
00882 
00883     return theTemp += theRHS;
00884 }
00885 
00886 
00887 
00888 inline XalanDOMString
00889 operator+(
00890             const XalanDOMString&   theLHS,
00891             const XalanDOMChar*     theRHS)
00892 {
00893     XalanDOMString  theTemp(theLHS);
00894 
00895     return theTemp += theRHS;
00896 }
00897 
00898 
00899 
00900 inline XalanDOMString
00901 operator+(
00902             const XalanDOMChar*     theLHS,
00903             const XalanDOMString&   theRHS)
00904 {
00905     XalanDOMString  theTemp(theLHS);
00906 
00907     return theTemp += theRHS;
00908 }
00909 
00910 
00911 
00912 inline const XalanDOMString
00913 operator+(
00914             const char*             theLHS,
00915             const XalanDOMString&   theRHS)
00916 {
00917     return XalanDOMString(theLHS) + theRHS;
00918 }
00919 
00920 
00921 
00922 inline const XalanDOMString
00923 operator+(
00924             const XalanDOMString&   theLHS,
00925             const char*             theRHS)
00926 {
00927     return theLHS + XalanDOMString(theRHS);
00928 }
00929 
00930 
00931 
00932 // Standard vector of XalanDOMChars and chars
00933 #if defined(XALAN_NO_NAMESPACES)
00934 typedef vector<XalanDOMChar>        XalanDOMCharVectorType;
00935 
00936 typedef vector<char>                CharVectorType;
00937 #else
00938 typedef std::vector<XalanDOMChar>   XalanDOMCharVectorType;
00939 
00940 typedef std::vector<char>           CharVectorType;
00941 #endif
00942 
00943 
00944 
00956 XALAN_DOM_EXPORT_FUNCTION(bool)
00957 TranscodeToLocalCodePage(
00958             const XalanDOMChar*         theSourceString,
00959             XalanDOMString::size_type   theSourceStringLength,
00960             CharVectorType&             targetVector,
00961             bool                        terminate = false);
00962 
00963 
00964 
00975 XALAN_DOM_EXPORT_FUNCTION(bool)
00976 TranscodeToLocalCodePage(
00977             const XalanDOMChar*     theSourceString,
00978             CharVectorType&         targetVector,
00979             bool                    terminate = false);
00980 
00981 
00982 
00991 inline const CharVectorType
00992 TranscodeToLocalCodePage(const XalanDOMChar*    theSourceString)
00993 {
00994     CharVectorType  theResult;
00995 
00996     TranscodeToLocalCodePage(theSourceString, theResult, true);
00997 
00998     return theResult;
00999 }
01000 
01001 
01002 
01012 inline bool
01013 TranscodeToLocalCodePage(
01014             const XalanDOMString&   theSourceString,
01015             CharVectorType&         targetVector,
01016             bool                    terminate = false)
01017 {
01018     return TranscodeToLocalCodePage(theSourceString.c_str(), targetVector, terminate);
01019 }
01020 
01021 
01022 
01031 inline const CharVectorType
01032 TranscodeToLocalCodePage(const XalanDOMString&  theSourceString)
01033 {
01034     CharVectorType  theResult;
01035 
01036     TranscodeToLocalCodePage(theSourceString, theResult, true);
01037 
01038     return theResult;
01039 }
01040 
01041 
01042 
01051 inline const XalanDOMString
01052 TranscodeFromLocalCodePage(
01053             const char*                 theSourceString,
01054             XalanDOMString::size_type   theSourceStringLength = XalanDOMString::npos)
01055 {
01056     return XalanDOMString(theSourceString, theSourceStringLength);
01057 }
01058 
01059 
01060 
01072 XALAN_DOM_EXPORT_FUNCTION(bool)
01073 TranscodeFromLocalCodePage(
01074             const char*                 theSourceString,
01075             XalanDOMString::size_type   theSourceStringLength,
01076             XalanDOMCharVectorType&     theTargetVector,
01077             bool                        terminate = false);
01078 
01079 
01080 
01091 XALAN_DOM_EXPORT_FUNCTION(bool)
01092 TranscodeFromLocalCodePage(
01093             const char*                 theSourceString,
01094             XalanDOMCharVectorType&     theTargetVector,
01095             bool                        terminate = false);
01096 
01097 
01098 
01106 inline const XalanDOMString
01107 TranscodeFromLocalCodePage(const CharVectorType&    theSourceString)
01108 {
01109     typedef XalanDOMString::size_type       size_type;
01110     typedef XalanDOMString::real_size_type  real_size_type;
01111 
01112     const CharVectorType::size_type     theSize = theSourceString.size();
01113     assert(real_size_type(size_type(theSize)) == theSize);
01114 
01115     if (theSourceString[theSize - 1] == CharVectorType::value_type(0))
01116     {
01117         return TranscodeFromLocalCodePage(&*theSourceString.begin(), size_type(theSize) - 1);
01118     }
01119     else
01120     {
01121         return TranscodeFromLocalCodePage(&*theSourceString.begin(), size_type(theSize));
01122     }
01123 }
01124 
01125 
01126 
01127 #endif  // !defined(XALANDOMSTRING_HEADER_GUARD_1357924680)

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

Xalan-C++ XSL Transformer Version 1.1
Copyright © 2000, 2001 The Apache Software Foundation. All Rights Reserved.