From 63557352f20bef44ee795fb84570dad382669004 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Sat, 17 May 2014 16:57:39 -0700 Subject: [PATCH] Add support for bool formatting --- Sources/Plasma/CoreLib/plFormat.cpp | 5 +++++ Sources/Plasma/CoreLib/plFormat.h | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/Sources/Plasma/CoreLib/plFormat.cpp b/Sources/Plasma/CoreLib/plFormat.cpp index 2f6ddb3e..6e7d7a78 100644 --- a/Sources/Plasma/CoreLib/plFormat.cpp +++ b/Sources/Plasma/CoreLib/plFormat.cpp @@ -485,3 +485,8 @@ PL_FORMAT_IMPL(const std::wstring &) { return _formatString(format, plString::FromWchar(value.c_str(), value.size()).ToUtf8()); } + +PL_FORMAT_IMPL(bool) +{ + return PL_FORMAT_FORWARD(format, value ? "true" : "false"); +} diff --git a/Sources/Plasma/CoreLib/plFormat.h b/Sources/Plasma/CoreLib/plFormat.h index 52116f0e..c6a9be4c 100644 --- a/Sources/Plasma/CoreLib/plFormat.h +++ b/Sources/Plasma/CoreLib/plFormat.h @@ -170,6 +170,10 @@ PL_FORMAT_TYPE(const std::wstring &) // TODO: Implement floating point types (float, double). They're harder // than the others, so I'll get around to them later >.> +// Formats as "true" or "false", following normal string formatting rules. +// To use other formats, don't pass us a bool directly... +PL_FORMAT_TYPE(bool) + // End of the chain -- emits the last piece (if any) and builds the final string namespace plFormat_Private {