|
|
@ -341,17 +341,19 @@ plString operator+(const char *left, const plString &right); |
|
|
|
class plStringStream |
|
|
|
class plStringStream |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
public: |
|
|
|
plStringStream() : fBufSize(256), fLength(0) |
|
|
|
plStringStream() : fLength(0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fBuffer = new char[fBufSize]; |
|
|
|
fShort[0] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
~plStringStream() { delete [] fBuffer; } |
|
|
|
~plStringStream() { if (ICanHasHeap()) delete [] fBuffer; } |
|
|
|
|
|
|
|
|
|
|
|
plStringStream &append(const char *data, size_t length); |
|
|
|
plStringStream &append(const char *data, size_t length); |
|
|
|
|
|
|
|
|
|
|
|
plStringStream &operator<<(const char *text); |
|
|
|
plStringStream &operator<<(const char *text); |
|
|
|
plStringStream &operator<<(int num); |
|
|
|
plStringStream &operator<<(int num); |
|
|
|
plStringStream &operator<<(unsigned int num); |
|
|
|
plStringStream &operator<<(unsigned int num); |
|
|
|
|
|
|
|
plStringStream &operator<<(float num) { return operator<<(static_cast<double>(num)); } |
|
|
|
|
|
|
|
plStringStream &operator<<(double num); |
|
|
|
plStringStream &operator<<(char ch) { return append(&ch, 1); } |
|
|
|
plStringStream &operator<<(char ch) { return append(&ch, 1); } |
|
|
|
|
|
|
|
|
|
|
|
plStringStream &operator<<(const plString &text) |
|
|
|
plStringStream &operator<<(const plString &text) |
|
|
@ -359,13 +361,25 @@ public: |
|
|
|
return append(text.c_str(), text.GetSize()); |
|
|
|
return append(text.c_str(), text.GetSize()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char *GetRawBuffer() const // WARNING: Not null-terminated!
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return ICanHasHeap() ? fBuffer : fShort; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
size_t GetLength() const { return fLength; } |
|
|
|
size_t GetLength() const { return fLength; } |
|
|
|
plString GetString() { return plString::FromUtf8(fBuffer, fLength); } |
|
|
|
plString GetString() { return plString::FromUtf8(GetRawBuffer(), fLength); } |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
private: |
|
|
|
char *fBuffer; |
|
|
|
union { |
|
|
|
size_t fBufSize; |
|
|
|
struct { |
|
|
|
|
|
|
|
char *fBuffer; |
|
|
|
|
|
|
|
size_t fBufSize; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
char fShort[256]; |
|
|
|
|
|
|
|
}; |
|
|
|
size_t fLength; |
|
|
|
size_t fLength; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ICanHasHeap() const { return fLength > 256; } |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
size_t ustrlen(const UniChar *ustr, size_t max = plString::kSizeAuto); |
|
|
|
size_t ustrlen(const UniChar *ustr, size_t max = plString::kSizeAuto); |
|
|
|