version 1.124, 2007/01/02 19:41:23
|
version 1.125, 2007/01/11 16:21:54
|
|
|
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); |
} | } |
| |
rep->data[rep->size] = '\0'; | rep->data[rep->size] = '\0'; |
|
|
while (*end++) | while (*end++) |
; | ; |
| |
return end - str - 1; |
return (Uint32)(end - str - 1); |
} | } |
| |
//============================================================================== | //============================================================================== |
|
|
{ | { |
StringRep::free(_rep); | StringRep::free(_rep); |
_rep = &StringRep::_emptyRep; | _rep = &StringRep::_emptyRep; |
_StringThrowBadUTF8(utf8_error_index); |
_StringThrowBadUTF8((Uint32)utf8_error_index); |
} | } |
| |
_rep->size = n1 + tmp; | _rep->size = n1 + tmp; |
|
|
{ | { |
StringRep::free(_rep); | StringRep::free(_rep); |
_rep = &StringRep::_emptyRep; | _rep = &StringRep::_emptyRep; |
_StringThrowBadUTF8(utf8_error_index); |
_StringThrowBadUTF8((Uint32)utf8_error_index); |
} | } |
| |
_rep->size = n2 + tmp; | _rep->size = n2 + tmp; |
|
|
{ | { |
StringRep::free(_rep); | StringRep::free(_rep); |
_rep = &StringRep::_emptyRep; | _rep = &StringRep::_emptyRep; |
_StringThrowBadUTF8(utf8_error_index); |
_StringThrowBadUTF8((Uint32)utf8_error_index); |
} | } |
| |
_rep->data[_rep->size] = 0; | _rep->data[_rep->size] = 0; |
|
|
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'; |
|
|
| |
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'; |
|
|
| |
String& String::append(const String& str) | String& String::append(const String& str) |
{ | { |
return append((Char16*)(&(str._rep->data[0])), 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) |
|
|
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); |
|
|
{ | { |
StringRep::free(_rep); | StringRep::free(_rep); |
_rep = &StringRep::_emptyRep; | _rep = &StringRep::_emptyRep; |
_StringThrowBadUTF8(utf8_error_index); |
_StringThrowBadUTF8((Uint32)utf8_error_index); |
} | } |
| |
_rep->size += tmp; | _rep->size += tmp; |
|
|
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); |
| |
|
|
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); |
} | } |