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