Browse Source

Add (u)int64_t formatters to plStringStream

Michael Hansen 10 years ago committed by Darryl Pogue
parent
commit
e3163d2465
  1. 18
      Sources/Plasma/CoreLib/plString.cpp
  2. 6
      Sources/Plasma/CoreLib/plString.h

18
Sources/Plasma/CoreLib/plString.cpp

@ -924,14 +924,28 @@ plStringStream &plStringStream::operator<<(const char *text)
plStringStream &plStringStream::operator<<(int num)
{
char buffer[12];
snprintf(buffer, 12, "%d", num);
snprintf(buffer, arrsize(buffer), "%d", num);
return operator<<(buffer);
}
plStringStream &plStringStream::operator<<(unsigned int num)
{
char buffer[12];
snprintf(buffer, 12, "%u", num);
snprintf(buffer, arrsize(buffer), "%u", num);
return operator<<(buffer);
}
plStringStream &plStringStream::operator<<(int64_t num)
{
char buffer[24];
snprintf(buffer, arrsize(buffer), "%lld", num);
return operator<<(buffer);
}
plStringStream &plStringStream::operator<<(uint64_t num)
{
char buffer[24];
snprintf(buffer, arrsize(buffer), "%llu", num);
return operator<<(buffer);
}

6
Sources/Plasma/CoreLib/plString.h

@ -753,6 +753,12 @@ public:
/** Append a base-10 formatted unsigned integer to the stream. */
plStringStream &operator<<(unsigned int num);
/** Append a base-10 formatted signed 64-bit integer to the stream. */
plStringStream &operator<<(int64_t num);
/** Append a base-10 formatted unsigned 64-bit integer to the stream. */
plStringStream &operator<<(uint64_t num);
/** Append a base-10 formatted float to the stream. */
plStringStream &operator<<(float num) { return operator<<(static_cast<double>(num)); }

Loading…
Cancel
Save