|
|
|
@ -644,6 +644,36 @@ plString plString::Substr(int start, size_t size) const
|
|
|
|
|
return str; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
plString plString::ToUpper() const |
|
|
|
|
{ |
|
|
|
|
// TODO: Unicode-aware case conversion
|
|
|
|
|
size_t size = GetSize(); |
|
|
|
|
char *dupe = new char[size + 1]; |
|
|
|
|
const char *self = c_str(); |
|
|
|
|
for (size_t i = 0; i < size; ++i) |
|
|
|
|
dupe[i] = toupper(self[i]); |
|
|
|
|
|
|
|
|
|
// Don't re-check UTF-8 on this
|
|
|
|
|
plString str; |
|
|
|
|
str.fUtf8Buffer = plStringBuffer<char>::Steal(dupe, size); |
|
|
|
|
return str; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
plString plString::ToLower() const |
|
|
|
|
{ |
|
|
|
|
// TODO: Unicode-aware case conversion
|
|
|
|
|
size_t size = GetSize(); |
|
|
|
|
char *dupe = new char[size + 1]; |
|
|
|
|
const char *self = c_str(); |
|
|
|
|
for (size_t i = 0; i < size; ++i) |
|
|
|
|
dupe[i] = tolower(self[i]); |
|
|
|
|
|
|
|
|
|
// Don't re-check UTF-8 on this
|
|
|
|
|
plString str; |
|
|
|
|
str.fUtf8Buffer = plStringBuffer<char>::Steal(dupe, size); |
|
|
|
|
return str; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
plString &plString::operator+=(const plString &str) |
|
|
|
|
{ |
|
|
|
|
size_t catsize = GetSize() + str.GetSize(); |
|
|
|
@ -669,9 +699,8 @@ plString operator+(const plString &left, const plString &right)
|
|
|
|
|
return str; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
plStringStream &plStringStream::operator<<(const char *text) |
|
|
|
|
plStringStream &plStringStream::append(const char *data, size_t length) |
|
|
|
|
{ |
|
|
|
|
size_t length = strlen(text); |
|
|
|
|
if (fLength + length > fBufSize) { |
|
|
|
|
char *bigger = new char[fBufSize * 2]; |
|
|
|
|
memcpy(bigger, fBuffer, fBufSize); |
|
|
|
@ -679,11 +708,17 @@ plStringStream &plStringStream::operator<<(const char *text)
|
|
|
|
|
fBuffer = bigger; |
|
|
|
|
fBufSize *= 2; |
|
|
|
|
} |
|
|
|
|
memcpy(fBuffer + fLength, text, length); |
|
|
|
|
memcpy(fBuffer + fLength, data, length); |
|
|
|
|
fLength += length; |
|
|
|
|
return *this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
plStringStream &plStringStream::operator<<(const char *text) |
|
|
|
|
{ |
|
|
|
|
size_t length = strlen(text); |
|
|
|
|
return append(text, length); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
plStringStream &plStringStream::operator<<(int num) |
|
|
|
|
{ |
|
|
|
|
char buffer[12]; |
|
|
|
@ -697,9 +732,3 @@ plStringStream &plStringStream::operator<<(unsigned int num)
|
|
|
|
|
snprintf(buffer, 12, "%u", num); |
|
|
|
|
return operator<<(buffer); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
plStringStream &plStringStream::operator<<(char ch) |
|
|
|
|
{ |
|
|
|
|
char buffer[2] = { ch, 0 }; |
|
|
|
|
return operator<<(buffer); |
|
|
|
|
} |
|
|
|
|