From e3163d2465d9d5c88fb7fae6584913940f02e91d Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Sat, 3 Jan 2015 17:09:33 -0800 Subject: [PATCH] Add (u)int64_t formatters to plStringStream --- Sources/Plasma/CoreLib/plString.cpp | 18 ++++++++++++++++-- Sources/Plasma/CoreLib/plString.h | 6 ++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Sources/Plasma/CoreLib/plString.cpp b/Sources/Plasma/CoreLib/plString.cpp index 9b179949..08bab171 100644 --- a/Sources/Plasma/CoreLib/plString.cpp +++ b/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); } diff --git a/Sources/Plasma/CoreLib/plString.h b/Sources/Plasma/CoreLib/plString.h index 536031ea..3304ffac 100644 --- a/Sources/Plasma/CoreLib/plString.h +++ b/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(num)); }