added method & tests to the class NumberFormatter for bool values

This commit is contained in:
Marian Krivos
2009-03-23 20:10:51 +00:00
parent 764bbf2e1d
commit fd98b17390
3 changed files with 80 additions and 41 deletions

View File

@@ -16,14 +16,14 @@
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
@@ -41,7 +41,7 @@
#if defined(_MSC_VER)
#define I64_FMT "I64"
#elif defined(__APPLE__)
#elif defined(__APPLE__)
#define I64_FMT "q"
#else
#define I64_FMT "ll"
@@ -51,6 +51,27 @@
namespace Poco {
std::string NumberFormatter::format(bool value, BoolFormat format)
{
switch(format)
{
default:
case FMT_TRUE_FALSE:
if (value == true)
return "true";
return "false";
case FMT_YES_NO:
if (value == true)
return "yes";
return "no";
case FMT_ON_OFF:
if (value == true)
return "on";
return "off";
}
}
void NumberFormatter::append(std::string& str, int value)
{
char buffer[64];