# HG changeset patch # User Teemu Piippo # Date 1418766551 -7200 # Node ID bd28a5730fd0aec06b80708a37525b3277f1a9a8 # Parent 8f47c682e248ba5dd54e8b870b90987e12eabc59 - fixed: had problems with integral overloading under 32-bit diff -r 8f47c682e248 -r bd28a5730fd0 sources/format.h --- a/sources/format.h Tue Dec 16 04:08:31 2014 +0200 +++ b/sources/format.h Tue Dec 16 23:49:11 2014 +0200 @@ -40,10 +40,13 @@ // FORMAT_OVERLOAD (String) { return a; } FORMAT_OVERLOAD (char) { return String (a); } +FORMAT_OVERLOAD (short int) { return String::from_number (a); } FORMAT_OVERLOAD (int) { return String::from_number (a); } FORMAT_OVERLOAD (long int) { return String::from_number (a); } FORMAT_OVERLOAD (double) { return String::from_number (a); } -FORMAT_OVERLOAD (size_t) { return String::from_number (a); } +FORMAT_OVERLOAD (unsigned short int) { return String::from_number (a); } +FORMAT_OVERLOAD (unsigned int) { return String::from_number (a); } +FORMAT_OVERLOAD (unsigned long int) { return String::from_number (a); } FORMAT_OVERLOAD (const char*) { return a; } FORMAT_OVERLOAD (std::nullptr_t) { (void) a; return ""; } FORMAT_OVERLOAD (bool) { return a ? "true" : "false"; } diff -r 8f47c682e248 -r bd28a5730fd0 sources/mystring.cpp --- a/sources/mystring.cpp Tue Dec 16 04:08:31 2014 +0200 +++ b/sources/mystring.cpp Tue Dec 16 23:49:11 2014 +0200 @@ -442,6 +442,16 @@ // ------------------------------------------------------------------------------------------------- // METHOD +String::from_number (short int a) -> String +{ + char buf[32]; + ::sprintf (buf, "%d", a); + return String (buf); +} + +// ------------------------------------------------------------------------------------------------- +// +METHOD String::from_number (int a) -> String { char buf[32]; @@ -452,7 +462,7 @@ // ------------------------------------------------------------------------------------------------- // METHOD -String::from_number (long a) -> String +String::from_number (long int a) -> String { char buf[32]; ::sprintf (buf, "%ld", a); @@ -462,7 +472,27 @@ // ------------------------------------------------------------------------------------------------- // METHOD -String::from_number (unsigned long a) -> String +String::from_number (unsigned short int a) -> String +{ + char buf[32]; + ::sprintf (buf, "%u", a); + return String (buf); +} + +// ------------------------------------------------------------------------------------------------- +// +METHOD +String::from_number (unsigned int a) -> String +{ + char buf[32]; + ::sprintf (buf, "%u", a); + return String (buf); +} + +// ------------------------------------------------------------------------------------------------- +// +METHOD +String::from_number (unsigned long int a) -> String { char buf[32]; ::sprintf (buf, "%lu", a); diff -r 8f47c682e248 -r bd28a5730fd0 sources/mystring.h --- a/sources/mystring.h Tue Dec 16 04:08:31 2014 +0200 +++ b/sources/mystring.h Tue Dec 16 23:49:11 2014 +0200 @@ -105,9 +105,12 @@ METHOD to_uppercase() const -> String; METHOD word_position (int n) const -> int; + static METHOD from_number (short int a) -> String; static METHOD from_number (int a) -> String; - static METHOD from_number (long a) -> String; - static METHOD from_number (unsigned long a) -> String; + static METHOD from_number (long int a) -> String; + static METHOD from_number (unsigned short int a) -> String; + static METHOD from_number (unsigned int a) -> String; + static METHOD from_number (unsigned long int a) -> String; static METHOD from_number (double a) -> String; METHOD operator+ (const String& data) const -> String;