00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * Copyright (c) 1999-2000 The Apache Software Foundation. All rights 00005 * reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * 1. Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 00014 * 2. Redistributions in binary form must reproduce the above copyright 00015 * notice, this list of conditions and the following disclaimer in 00016 * the documentation and/or other materials provided with the 00017 * distribution. 00018 * 00019 * 3. The end-user documentation included with the redistribution, 00020 * if any, must include the following acknowledgment: 00021 * "This product includes software developed by the 00022 * Apache Software Foundation (http://www.apache.org/)." 00023 * Alternately, this acknowledgment may appear in the software itself, 00024 * if and wherever such third-party acknowledgments normally appear. 00025 * 00026 * 4. The names "Xerces" and "Apache Software Foundation" must 00027 * not be used to endorse or promote products derived from this 00028 * software without prior written permission. For written 00029 * permission, please contact apache\@apache.org. 00030 * 00031 * 5. Products derived from this software may not be called "Apache", 00032 * nor may "Apache" appear in their name, without prior written 00033 * permission of the Apache Software Foundation. 00034 * 00035 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00036 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00037 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00038 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 00039 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00040 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00041 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00042 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00043 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00044 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00045 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00046 * SUCH DAMAGE. 00047 * ==================================================================== 00048 * 00049 * This software consists of voluntary contributions made by many 00050 * individuals on behalf of the Apache Software Foundation, and was 00051 * originally based on software copyright (c) 1999, International 00052 * Business Machines, Inc., http://www.ibm.com . For more information 00053 * on the Apache Software Foundation, please see 00054 * <http://www.apache.org/>. 00055 */ 00056 00057 /* 00058 * $Log: DOMString.hpp,v $ 00059 * Revision 1.1 2002/05/11 19:46:28 bhavani 00060 * CR#CR062582# adding xercesc 1.7 file 00061 * 00062 * Revision 1.2 2002/02/20 18:17:00 tng 00063 * [Bug 5977] Warnings on generating apiDocs. 00064 * 00065 * Revision 1.1.1.1 2002/02/01 22:21:44 peiyongz 00066 * sane_include 00067 * 00068 * Revision 1.12 2000/06/02 00:45:42 andyh 00069 * DOM Fixes: DOMString::rawBuffer() now returns a const XMLCh * pointer. 00070 * Two plain deletes changed to array deletes. 00071 * 00072 * Revision 1.11 2000/03/02 19:53:52 roddey 00073 * This checkin includes many changes done while waiting for the 00074 * 1.1.0 code to be finished. I can't list them all here, but a list is 00075 * available elsewhere. 00076 * 00077 * Revision 1.10 2000/02/24 20:11:27 abagchi 00078 * Swat for removing Log from API docs 00079 * 00080 * Revision 1.9 2000/02/16 22:54:56 abagchi 00081 * Switched the order of CDOM_EXPORT DomString for operators, to make OS/390 happy 00082 * 00083 * Revision 1.8 2000/02/06 07:47:27 rahulj 00084 * Year 2K copyright swat. 00085 * 00086 * Revision 1.7 2000/02/04 05:06:30 andyh 00087 * Change all DOMString offsets and lengths form signed to unsigned 00088 * Other misc. cleanups. 00089 * 00090 * Revision 1.6 2000/02/04 00:52:58 rahulj 00091 * Changed size_t to int. 00092 * 00093 * Revision 1.5 2000/02/03 23:07:27 andyh 00094 * Add several new functions from Robert Weir to DOMString. 00095 * 00096 * Revision 1.4 2000/01/05 22:16:26 robweir 00097 * Move DOMString implementation class declarations into a new 00098 * file: DOMStringImpl.hpp. Include this header in DOMString.hpp 00099 * for XML_DEBUG builds so the underlying character array will be 00100 * visible in the debugger. <robert_weir@lotus.com> 00101 * 00102 * Revision 1.3 1999/12/03 00:11:22 andyh 00103 * Added DOMString.clone() to node parameters in and out of the DOM, 00104 * where they had been missed. 00105 * 00106 * DOMString::rawBuffer, removed incorrect assumptions about it 00107 * being null terminated. 00108 * 00109 * Revision 1.2 1999/11/30 21:16:25 roddey 00110 * Changes to add the transcode() method to DOMString, which returns a transcoded 00111 * version (to local code page) of the DOM string contents. And I changed all of the 00112 * exception 'throw by pointer' to 'throw by value' style. 00113 * 00114 * Revision 1.1.1.1 1999/11/09 01:08:48 twl 00115 * Initial checkin 00116 * 00117 * Revision 1.2 1999/11/08 20:44:12 rahul 00118 * Swat for adding in Product name and CVS comment log variable. 00119 * 00120 */ 00121 00122 #ifndef DOMString_HEADER_GUARD_ 00123 #define DOMString_HEADER_GUARD_ 00124 00125 #include <xercesc/util/XercesDefs.hpp> 00126 00127 #ifdef XML_DEBUG 00128 #include "DOMStringImpl.hpp" 00129 #else 00130 class DOMStringHandle; 00131 #endif 00132 00133 class DOM_NullPtr; 00134 00143 class CDOM_EXPORT DOMString { 00144 public: 00152 DOMString(); 00153 00159 DOMString(const DOMString &other); 00160 00168 DOMString(const XMLCh *other); 00169 00176 DOMString(const XMLCh *other, unsigned int length); 00177 00185 DOMString(const char *other); 00186 00190 DOMString(int nullPointerValue); 00191 00198 DOMString & operator = (const DOMString &other); 00199 00200 00201 00202 DOMString & operator = (DOM_NullPtr *other); 00203 00205 00207 00212 ~DOMString(); 00213 00215 00217 00224 // DOMString operator + (const DOMString &other); 00225 00227 00229 00242 bool operator == (const DOMString &other) const; 00243 00256 bool operator != (const DOMString &other) const; 00257 00266 bool operator == (const DOM_NullPtr *other) const; 00267 00274 bool operator != (const DOM_NullPtr *other) const; 00275 00277 00279 00280 00288 void reserve(unsigned int size); 00289 00290 00296 void appendData(const DOMString &other); 00297 00303 void appendData(XMLCh ch); 00304 00310 void appendData(const XMLCh *other); 00311 00312 00318 DOMString& operator +=(const DOMString &other); 00319 00320 00326 DOMString& operator +=(const XMLCh* other); 00327 00328 00334 DOMString& operator +=(XMLCh ch); 00335 00336 00343 void deleteData(unsigned int offset, unsigned int count); 00344 00353 void insertData(unsigned int offset, const DOMString &data); 00354 00356 00358 00365 XMLCh charAt(unsigned int index) const; 00366 00375 const XMLCh *rawBuffer() const; 00376 00385 char *transcode() const; 00386 00387 00395 static DOMString transcode(const char* str); 00396 00397 00398 00406 DOMString substringData(unsigned int offset, unsigned int count) const; 00407 00413 unsigned int length() const; 00414 00416 00418 00424 DOMString clone() const; 00425 00427 00429 00434 void print() const; 00435 00440 void println() const; 00441 00443 00445 00457 int compareString(const DOMString &other) const; 00458 00466 bool equals(const DOMString &other) const; 00467 00468 00476 bool equals(const XMLCh *other) const; 00477 00478 00480 friend class DOMStringData; 00481 friend class DOMStringHandle; 00482 friend class DomMemDebug; 00483 private: 00484 00485 DOMStringHandle *fHandle; 00486 static int gLiveStringHandleCount; 00487 static int gTotalStringHandleCount; 00488 static int gLiveStringDataCount; 00489 static int gTotalStringDataCount; 00490 }; 00491 00492 00493 /****** Global Helper Functions ******/ 00494 00502 DOMString CDOM_EXPORT operator + (const DOMString &lhs, const DOMString &rhs); 00503 00511 DOMString CDOM_EXPORT operator + (const DOMString &lhs, const XMLCh* rhs); 00512 00513 00521 DOMString CDOM_EXPORT operator + (const XMLCh* lhs, const DOMString &rhs); 00522 00523 00531 DOMString CDOM_EXPORT operator + (const DOMString &lhs, XMLCh rhs); 00532 00533 00541 DOMString CDOM_EXPORT operator + (XMLCh lhs, const DOMString &rhs); 00542 00543 #endif