(file) Return to String.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/String.cpp between version 1.115 and 1.138

version 1.115, 2005/11/27 03:11:36 version 1.138, 2010/07/16 10:15:31
Line 1 
Line 1 
 //%2005////////////////////////////////////////////////////////////////////////  //%LICENSE////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development  // Licensed to The Open Group (TOG) under one or more contributor license
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.  // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;  // this work for additional information regarding copyright ownership.
 // IBM Corp.; EMC Corporation, The Open Group.  // Each contributor licenses this file to you under the OpenPegasus Open
 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;  // Source License; you may not use this file except in compliance with the
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.  // License.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;  
 // EMC Corporation; VERITAS Software Corporation; The Open Group.  
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy  // Permission is hereby granted, free of charge, to any person obtaining a
 // of this software and associated documentation files (the "Software"), to  // copy of this software and associated documentation files (the "Software"),
 // deal in the Software without restriction, including without limitation the  // to deal in the Software without restriction, including without limitation
 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or  // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 // sell copies of the Software, and to permit persons to whom the Software is  // and/or sell copies of the Software, and to permit persons to whom the
 // furnished to do so, subject to the following conditions:  // Software is furnished to do so, subject to the following conditions:
 // //
 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN  // The above copyright notice and this permission notice shall be included
 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED  // in all copies or substantial portions of the Software.
 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT  
 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR  
 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT  
 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN  
 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  
 // //
 //==============================================================================  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 //  // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 // Author: Mike Brasher (mbrasher@austin.rr.com)  // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
   // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 // //
 // Modified By:  //////////////////////////////////////////////////////////////////////////
 //     Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)  
 //     Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) for Bug#3297  
 //     David Dillard, VERITAS Software Corp. (david.dillard@veritas.com)  
 //     Mike Brasher (mike-brasher@austin.rr.com)  
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <Pegasus/Common/PegasusAssert.h> #include <Pegasus/Common/PegasusAssert.h>
 #include <cstring> #include <cstring>
 #include "InternalException.h" #include "InternalException.h"
 #include "CommonUTF.h"  
 #include "MessageLoader.h" #include "MessageLoader.h"
 #include "StringRep.h" #include "StringRep.h"
  
 #ifdef PEGASUS_HAS_ICU #ifdef PEGASUS_HAS_ICU
   # include <unicode/ures.h>
 #include <unicode/ustring.h> #include <unicode/ustring.h>
 #include <unicode/uchar.h> #include <unicode/uchar.h>
 #endif #endif
Line 55 
Line 47 
 // //
 // Compile-time macros (undefined by default). // Compile-time macros (undefined by default).
 // //
 //     PEGASUS_STRING_NO_THROW -- suppresses throwing of exceptions  
 //  
 //     PEGASUS_STRING_NO_UTF8 -- don't generate slower UTF8 code. //     PEGASUS_STRING_NO_UTF8 -- don't generate slower UTF8 code.
 // //
 //============================================================================== //==============================================================================
Line 162 
Line 152 
 // Rounds x up to the nearest power of two (or just returns 8 if x < 8). // Rounds x up to the nearest power of two (or just returns 8 if x < 8).
 static Uint32 _roundUpToPow2(Uint32 x) static Uint32 _roundUpToPow2(Uint32 x)
 { {
 #ifndef PEGASUS_STRING_NO_THROW      // Check for potential overflow in x
       PEGASUS_CHECK_CAPACITY_OVERFLOW(x);
     if (x > 0x0FFFFFFF)  
         throw PEGASUS_STD(bad_alloc)();  
   
 #endif  
  
     if (x < 8)     if (x < 8)
         return 8;         return 8;
Line 183 
Line 169 
     return x;     return x;
 } }
  
 template<class P, class Q>  
 static void _copy(P* p, const Q* q, size_t n)  
 {  
     // The following employs loop unrolling for efficiency. Please do not  
     // eliminate.  
   
     while (n >= 8)  
     {  
         p[0] = q[0];  
         p[1] = q[1];  
         p[2] = q[2];  
         p[3] = q[3];  
         p[4] = q[4];  
         p[5] = q[5];  
         p[6] = q[6];  
         p[7] = q[7];  
         p += 8;  
         q += 8;  
         n -= 8;  
     }  
   
     while (n >= 4)  
     {  
         p[0] = q[0];  
         p[1] = q[1];  
         p[2] = q[2];  
         p[3] = q[3];  
         p += 4;  
         q += 4;  
         n -= 4;  
     }  
   
     while (n--)  
         *p++ = *q++;  
 }  
   
 static Uint16* _find(const Uint16* s, size_t n, Uint16 c) static Uint16* _find(const Uint16* s, size_t n, Uint16 c)
 { {
     // The following employs loop unrolling for efficiency. Please do not     // The following employs loop unrolling for efficiency. Please do not
Line 280 
Line 230 
     return 0;     return 0;
 } }
  
   #ifdef PEGASUS_STRING_NO_UTF8
 static int _compareNoUTF8(const Uint16* s1, const char* s2) static int _compareNoUTF8(const Uint16* s1, const char* s2)
 { {
     Uint16 c1;     Uint16 c1;
Line 297 
Line 248 
  
     return c1 - c2;     return c1 - c2;
 } }
   #endif
 static int _compare(const Uint16* s1, const Uint16* s2, size_t n)  
 {  
     // This should only be called when s1 and s2 have the same length.  
   
     while (n-- && (*s1++ - *s2++) == 0)  
         ;  
   
     return s1[-1] - s2[-1];  
 }  
  
 static inline void _copy(Uint16* s1, const Uint16* s2, size_t n) static inline void _copy(Uint16* s1, const Uint16* s2, size_t n)
 { {
Line 320 
Line 262 
  
 inline void _checkNullPointer(const void* ptr) inline void _checkNullPointer(const void* ptr)
 { {
 #ifdef PEGASUS_STRING_NO_THROW  
   
     if (!ptr)     if (!ptr)
         throw NullPointer();         throw NullPointer();
   
 #endif  
 } }
  
 static void _StringThrowBadUTF8(Uint32 index)  #define BADUTF8_MAX_CLEAR_CHAR 40
 {  #define BADUTF8_MAX_CHAR_TO_HEX 10
     MessageLoaderParms parms(  
         "Common.String.BAD_UTF8",  
         "The byte sequence starting at index $0 "  
         "is not valid UTF-8 encoding.",  
         index);  
     throw Exception(parms);  
 }  
  
 static size_t _copyFromUTF8(  static void _formatBadUTF8Chars(
     Uint16* dest,      char* buffer,
     const char* src,      Uint32 index,
     size_t n,      const char* q,
     size_t& utf8_error_index)      size_t n )
 { {
     Uint16* p = dest;  
     const Uint8* q = (const Uint8*)src;  
  
     // Process leading 7-bit ASCII characters (to avoid UTF8 overhead later).      char tmp[20];
     // Use loop-unrolling.      const char* start;
  
     while (n >=8 && ((q[0]|q[1]|q[2]|q[3]|q[4]|q[5]|q[6]|q[7]) & 0x80) == 0)      size_t clearChar =
     {          (( index < BADUTF8_MAX_CLEAR_CHAR ) ? index : BADUTF8_MAX_CLEAR_CHAR );
         p[0] = q[0];      size_t charToHex =
         p[1] = q[1];          ((n-index-1) < BADUTF8_MAX_CHAR_TO_HEX ?
         p[2] = q[2];              (n-index-1) : BADUTF8_MAX_CHAR_TO_HEX );
         p[3] = q[3];  
         p[4] = q[4];  
         p[5] = q[5];  
         p[6] = q[6];  
         p[7] = q[7];  
         p += 8;  
         q += 8;  
         n -= 8;  
     }  
   
     while (n >=4 && ((q[0]|q[1]|q[2]|q[3]) & 0x80) == 0)  
     {  
         p[0] = q[0];  
         p[1] = q[1];  
         p[2] = q[2];  
         p[3] = q[3];  
         p += 4;  
         q += 4;  
         n -= 4;  
     }  
  
     switch (n)      if (index < BADUTF8_MAX_CLEAR_CHAR)
     {     {
         case 0:          start = q;
             return p - dest;      } else
         case 1:  
             if (q[0] < 128)  
             {  
                 p[0] = q[0];  
                 return p + 1 - dest;  
             }  
             break;  
         case 2:  
             if (((q[0]|q[1]) & 0x80) == 0)  
             {  
                 p[0] = q[0];  
                 p[1] = q[1];  
                 return p + 2 - dest;  
             }  
             break;  
         case 3:  
             if (((q[0]|q[1]|q[2]) & 0x80) == 0)  
             {             {
                 p[0] = q[0];          start = &(q[ index - BADUTF8_MAX_CLEAR_CHAR]);
                 p[1] = q[1];  
                 p[2] = q[2];  
                 return p + 3 - dest;  
             }  
             break;  
     }     }
  
     // Process remaining characters.      // Intialize the buffer with the first character as '\0' to be able to use
       // strnchat() and strcat()
     while (n)      buffer[0] = 0;
       // Start the buffer with the valid UTF8 chars
       strncat(buffer,start,clearChar);
       for (size_t i = clearChar, j = 0; j <= charToHex; i++,j++ )
     {     {
         // Optimize for 7-bit ASCII case.          tmp[0] = 0;
           sprintf(&(tmp[0])," 0x%02X",(Uint8)start[i]);
           strncat(buffer,&(tmp[0]),5);
       }
  
         if (*q < 128)  
         {  
             *p++ = *q++;  
             n--;  
         }         }
         else  
         {  
             Uint8 c = UTF_8_COUNT_TRAIL_BYTES(*q) + 1;  
  
             if (c > n || !isValid_U8(q, c) ||  static void _StringThrowBadUTF8(Uint32 index, const char* q, size_t n)
                 UTF8toUTF16(&q, q + c, &p, p + n) != 0)  
             {             {
                 utf8_error_index = q - (const Uint8*)src;      char buffer[1024];
                 return size_t(-1);  
             }  
  
             n -= c;      _formatBadUTF8Chars(&(buffer[0]),index,q,n);
         }  
     }      MessageLoaderParms parms(
           "Common.String.BAD_UTF8_LONG",
           "The byte sequence starting at index $0 "
           "is not valid UTF-8 encoding: $1",
           index,buffer);
  
     return p - dest;      throw Exception(parms);
 } }
  
 // Note: dest must be at least three times src (plus an extra byte for // Note: dest must be at least three times src (plus an extra byte for
Line 493 
Line 380 
     return p - (Uint8*)dest;     return p - (Uint8*)dest;
 } }
  
 static inline size_t _convert(  
     Uint16* p, const char* q, size_t n, size_t& utf8_error_index)  
 {  
 #ifdef PEGASUS_STRING_NO_UTF8  
     _copy(p, q, n);  
     return n;  
 #else  
     return _copyFromUTF8(p, q, n, utf8_error_index);  
 #endif  
 }  
   
 //============================================================================== //==============================================================================
 // //
 // class CString // class CString
Line 551 
Line 427 
  
 inline StringRep* StringRep::alloc(size_t cap) inline StringRep* StringRep::alloc(size_t cap)
 { {
 #ifndef PEGASUS_STRING_NO_THROW      // Check for potential overflow in cap
       PEGASUS_CHECK_CAPACITY_OVERFLOW(cap);
     // Any string bigger than this is seriously suspect.  
     if (cap > 0x0FFFFFFF)  
         throw PEGASUS_STD(bad_alloc)();  
   
 #endif  
  
     StringRep* rep = (StringRep*)::operator new(     StringRep* rep = (StringRep*)::operator new(
         sizeof(StringRep) + cap * sizeof(Uint16));         sizeof(StringRep) + cap * sizeof(Uint16));
Line 607 
Line 478 
     size_t utf8_error_index;     size_t utf8_error_index;
     rep->size = _convert((Uint16*)rep->data, data, size, utf8_error_index);     rep->size = _convert((Uint16*)rep->data, data, size, utf8_error_index);
  
 #ifndef PEGASUS_STRING_NO_THROW  
     if (rep->size == size_t(-1))     if (rep->size == size_t(-1))
     {     {
         StringRep::free(rep);         StringRep::free(rep);
         _StringThrowBadUTF8(utf8_error_index);          _StringThrowBadUTF8((Uint32)utf8_error_index, data,size);
     }     }
 #endif  
  
     rep->data[rep->size] = '\0';     rep->data[rep->size] = '\0';
  
Line 629 
Line 498 
     while (*end++)     while (*end++)
         ;         ;
  
     return end - str - 1;      return (Uint32)(end - str - 1);
 } }
  
 //============================================================================== //==============================================================================
Line 698 
Line 567 
     size_t utf8_error_index;     size_t utf8_error_index;
     size_t tmp = _convert((Uint16*)_rep->data + n1, s2, n2, utf8_error_index);     size_t tmp = _convert((Uint16*)_rep->data + n1, s2, n2, utf8_error_index);
  
 #ifndef PEGASUS_STRING_NO_THROW  
     if (tmp == size_t(-1))     if (tmp == size_t(-1))
     {     {
         StringRep::free(_rep);         StringRep::free(_rep);
         _rep = &StringRep::_emptyRep;         _rep = &StringRep::_emptyRep;
         _StringThrowBadUTF8(utf8_error_index);          _StringThrowBadUTF8((Uint32)utf8_error_index,s2,n2);
     }     }
 #endif  
  
     _rep->size = n1 + tmp;     _rep->size = n1 + tmp;
     _rep->data[_rep->size] = '\0';     _rep->data[_rep->size] = '\0';
Line 720 
Line 587 
     size_t utf8_error_index;     size_t utf8_error_index;
     size_t tmp = _convert((Uint16*)_rep->data, s1, n1, utf8_error_index);     size_t tmp = _convert((Uint16*)_rep->data, s1, n1, utf8_error_index);
  
 #ifndef PEGASUS_STRING_NO_THROW  
     if (tmp ==  size_t(-1))     if (tmp ==  size_t(-1))
     {     {
         StringRep::free(_rep);         StringRep::free(_rep);
         _rep = &StringRep::_emptyRep;         _rep = &StringRep::_emptyRep;
         _StringThrowBadUTF8(utf8_error_index);          _StringThrowBadUTF8((Uint32)utf8_error_index,s1,n1);
     }     }
 #endif  
  
     _rep->size = n2 + tmp;     _rep->size = n2 + tmp;
     _copy(_rep->data + n1, s2._rep->data, n2);     _copy(_rep->data + n1, s2._rep->data, n2);
Line 775 
Line 640 
     size_t utf8_error_index;     size_t utf8_error_index;
     _rep->size = _convert(_rep->data, str, n, utf8_error_index);     _rep->size = _convert(_rep->data, str, n, utf8_error_index);
  
 #ifndef PEGASUS_STRING_NO_THROW  
     if (_rep->size ==  size_t(-1))     if (_rep->size ==  size_t(-1))
     {     {
         StringRep::free(_rep);         StringRep::free(_rep);
         _rep = &StringRep::_emptyRep;         _rep = &StringRep::_emptyRep;
         _StringThrowBadUTF8(utf8_error_index);          _StringThrowBadUTF8((Uint32)utf8_error_index,str,n);
     }     }
 #endif  
  
     _rep->data[_rep->size] = 0;     _rep->data[_rep->size] = 0;
  
Line 827 
Line 690 
     str[_rep->size] = '\0';     str[_rep->size] = '\0';
     return CString(str);     return CString(str);
 #else #else
     Uint32 n = 3 * _rep->size;      Uint32 n = (Uint32)(3 * _rep->size);
     char* str = (char*)operator new(n + 1);     char* str = (char*)operator new(n + 1);
     size_t size = _copyToUTF8(str, _rep->data, _rep->size);     size_t size = _copyToUTF8(str, _rep->data, _rep->size);
     str[size] = '\0';     str[size] = '\0';
Line 841 
Line 704 
  
     size_t oldSize = _rep->size;     size_t oldSize = _rep->size;
     size_t newSize = oldSize + n;     size_t newSize = oldSize + n;
     _reserve(_rep, newSize);      _reserve(_rep, (Uint32)newSize);
     _copy(_rep->data + oldSize, (Uint16*)str, n);     _copy(_rep->data + oldSize, (Uint16*)str, n);
     _rep->size = newSize;     _rep->size = newSize;
     _rep->data[newSize] = '\0';     _rep->data[newSize] = '\0';
Line 851 
Line 714 
  
 String& String::append(const String& str) String& String::append(const String& str)
 { {
     return append((Char16*)str._rep->data, str._rep->size);      return append((Char16*)(&(str._rep->data[0])), (Uint32)str._rep->size);
 } }
  
 String& String::append(const char* str, Uint32 size) String& String::append(const char* str, Uint32 size)
Line 861 
Line 724 
     size_t oldSize = _rep->size;     size_t oldSize = _rep->size;
     size_t cap = oldSize + size;     size_t cap = oldSize + size;
  
     _reserve(_rep, cap);      _reserve(_rep, (Uint32)cap);
     size_t utf8_error_index;     size_t utf8_error_index;
     size_t tmp = _convert(     size_t tmp = _convert(
         (Uint16*)_rep->data + oldSize, str, size, utf8_error_index);         (Uint16*)_rep->data + oldSize, str, size, utf8_error_index);
  
 #ifndef PEGASUS_STRING_NO_THROW  
     if (tmp ==  size_t(-1))     if (tmp ==  size_t(-1))
     {     {
         StringRep::free(_rep);         StringRep::free(_rep);
         _rep = &StringRep::_emptyRep;         _rep = &StringRep::_emptyRep;
         _StringThrowBadUTF8(utf8_error_index);          _StringThrowBadUTF8((Uint32)utf8_error_index,str,size);
     }     }
 #endif  
  
     _rep->size += tmp;     _rep->size += tmp;
     _rep->data[_rep->size] = '\0';     _rep->data[_rep->size] = '\0';
Line 884 
Line 745 
 void String::remove(Uint32 index, Uint32 n) void String::remove(Uint32 index, Uint32 n)
 { {
     if (n == PEG_NOT_FOUND)     if (n == PEG_NOT_FOUND)
         n = _rep->size - index;          n = (Uint32)(_rep->size - index);
  
     _checkBounds(index + n, _rep->size);     _checkBounds(index + n, _rep->size);
  
Line 911 
Line 772 
     if (index < _rep->size)     if (index < _rep->size)
     {     {
         if (n == PEG_NOT_FOUND || n > _rep->size - index)         if (n == PEG_NOT_FOUND || n > _rep->size - index)
             n = _rep->size - index;              n = (Uint32)(_rep->size - index);
  
         return String((Char16*)_rep->data + index, n);          return String((Char16*)(_rep->data + index), n);
     }     }
  
     return String();     return String();
Line 924 
Line 785 
     Uint16* p = (Uint16*)_find(_rep->data, _rep->size, c);     Uint16* p = (Uint16*)_find(_rep->data, _rep->size, c);
  
     if (p)     if (p)
         return p - _rep->data;          return static_cast<Uint32>(p - _rep->data);
  
     return PEG_NOT_FOUND;     return PEG_NOT_FOUND;
 } }
Line 939 
Line 800 
     Uint16* p = (Uint16*)_find(_rep->data + index, _rep->size - index, c);     Uint16* p = (Uint16*)_find(_rep->data + index, _rep->size - index, c);
  
     if (p)     if (p)
         return p - _rep->data;          return static_cast<Uint32>(p - _rep->data);
  
     return PEG_NOT_FOUND;     return PEG_NOT_FOUND;
 } }
Line 960 
Line 821 
             break;             break;
  
         if (memcmp(p, s, n * sizeof(Uint16)) == 0)         if (memcmp(p, s, n * sizeof(Uint16)) == 0)
             return p - _rep->data;              return static_cast<Uint32>(p - _rep->data);
  
         p++;         p++;
         rem -= p - data;         rem -= p - data;
Line 988 
Line 849 
     while (q != p)     while (q != p)
     {     {
         if (*--q == x)         if (*--q == x)
             return q - p;              return static_cast<Uint32>(q - p);
     }     }
  
     return PEG_NOT_FOUND;     return PEG_NOT_FOUND;
Line 1102 
Line 963 
  
 int String::compare(const String& s1, const String& s2, Uint32 n) int String::compare(const String& s1, const String& s2, Uint32 n)
 { {
     PEGASUS_ASSERT(n <= s1._rep->size);      const Uint16* p1 = s1._rep->data;
     PEGASUS_ASSERT(n <= s2._rep->size);      const Uint16* p2 = s2._rep->data;
  
     // Ignoring error in which n is greater than s1.size() or s2.size()      while (n--)
     return _compare(s1._rep->data, s2._rep->data, n);      {
           int r = *p1++ - *p2++;
           if (r)
           {
               return r;
           }
           else if (!p1[-1])
           {
               // We must have encountered a null terminator in both s1 and s2
               return 0;
           }
       }
       return 0;
 } }
  
 int String::compare(const String& s1, const String& s2) int String::compare(const String& s1, const String& s2)
Line 1133 
Line 1006 
     if (InitializeICU::initICUSuccessful())     if (InitializeICU::initICUSuccessful())
     {     {
         return  u_strcasecmp(         return  u_strcasecmp(
             str1._rep->data, str2._rep->data, U_FOLD_CASE_DEFAULT);              (const UChar*)str1._rep->data,
               (const UChar*)str2._rep->data,
               U_FOLD_CASE_DEFAULT
               );
     }     }
  
 #endif /* PEGASUS_HAS_ICU */ #endif /* PEGASUS_HAS_ICU */
Line 1258 
Line 1134 
  
 Boolean String::equal(const String& s1, const String& s2) Boolean String::equal(const String& s1, const String& s2)
 { {
     return s1._rep->size == s2._rep->size && memcmp(s1._rep->data,      return (s1._rep == s2._rep) ||
         s2._rep->data, s1._rep->size * sizeof(Uint16)) == 0;          ((s1._rep->size == s2._rep->size) &&
            memcmp(s1._rep->data,
                   s2._rep->data,
                   s1._rep->size * sizeof(Uint16)) == 0);
 } }
  
 Boolean String::equal(const String& s1, const char* s2) Boolean String::equal(const String& s1, const char* s2)
Line 1288 
Line 1167 
  
 PEGASUS_STD(ostream)& operator<<(PEGASUS_STD(ostream)& os, const String& str) PEGASUS_STD(ostream)& operator<<(PEGASUS_STD(ostream)& os, const String& str)
 { {
 #if defined(PEGASUS_OS_OS400)  
   
     CString cstr = str.getCString();  
     const char* utf8str = cstr;  
     os << utf8str;  
     return os;  
 #else  
   
 #if defined(PEGASUS_HAS_ICU) #if defined(PEGASUS_HAS_ICU)
  
     if (InitializeICU::initICUSuccessful())     if (InitializeICU::initICUSuccessful())
Line 1331 
Line 1202 
     }     }
  
     return os;     return os;
 #endif // PEGASUS_OS_OS400  
 } }
  
 void StringAppendCharAux(StringRep*& _rep) void StringAppendCharAux(StringRep*& _rep)
Line 1354 
Line 1224 
     _rep = tmp;     _rep = tmp;
 } }
  
   void AssignASCII(String& s, const char* str, Uint32 n)
   {
       class StringLayout
       {
       public:
           StringRep* rep;
       };
   
       StringLayout* that = reinterpret_cast<StringLayout*>(&s);
   
       _checkNullPointer(str);
   
       if (n > that->rep->cap || that->rep->refs.get() != 1)
       {
           StringRep::unref(that->rep);
           that->rep = StringRep::alloc(n);
       }
   
       _copy(that->rep->data, str, n);
       that->rep->size = n;
       that->rep->data[that->rep->size] = 0;
   }
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END
  
 /* /*
Line 1482 
Line 1375 
         This avoids slower UTF8 processing when not needed.         This avoids slower UTF8 processing when not needed.
  
 ================================================================================ ================================================================================
   
 TO-DO:  
   
     (+) [DONE] Use PEGASUS_USE_EXPERIMENTAL_INTERFACES  
   
     (+) [DONE] Submit BUG-2754 (Windows buffer limit).  
   
     (+) [DONE] Eliminate char versions of find() and append().  
   
     (+) [DONE] Remove PEGASUS_MAX_PRINTABLE_CHARACTER from Config.h  
   
     (+) [DONE] Change _next_pow_2() to _roundUpToPow2().  
   
     (+) [DONE] Change '99' to '2' in StringRep constructor (comment as well).  
   
     (+) [DONE] Comment StringRep allocation layout.  
   
     (+) [DONE] Conceal private inline functions.  
   
     (+) [DONE] Shorten inclusion of StringInline.h in String.h.  
   
     (+) [DONE] Change USE_INTERNAL_INLINE TO DISABLE_INTERNAL_INLINE or get  
         rid of altogether.  
   
     (+) [DONE] useCamelNotationOnAllFunctionNames.  
   
     (+) [DONE] Check for overlow condition in StringRep::alloc().  
   
     (+) [DONE] Remove tabs (used vim ":set expandtab" and ":retab").  
   
     (+) [DONE] Fix throw-related memory leak.  
   
     (+) [DONE] Look at PEP223 for coding security guidelines.  
   
     (+) [DONE] Use old AtomicInt for now (new AtomicInt part of bug #4250).  
   
     (+) [DONE] Removed appendASCII() and the ASCII form of the constructor.  
   
     (+) DOC++ String.h - will open new bug?  
   
     (+) Added PEGASUS_DISABLE_INTERNAL_INLINES macro (to permit suppression  
         on certain platforms).  
   
 ================================================================================  
 */ */


Legend:
Removed from v.1.115  
changed lines
  Added in v.1.138

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2