- fixed: had problems with integral overloading under 32-bit

Tue, 16 Dec 2014 23:49:11 +0200

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Tue, 16 Dec 2014 23:49:11 +0200
changeset 66
bd28a5730fd0
parent 65
8f47c682e248
child 67
637ed38c3a82

- fixed: had problems with integral overloading under 32-bit

sources/format.h file | annotate | diff | comparison | revisions
sources/mystring.cpp file | annotate | diff | comparison | revisions
sources/mystring.h file | annotate | diff | comparison | revisions
--- 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 "<null pointer>"; }
 FORMAT_OVERLOAD (bool) { return a ? "true" : "false"; }
--- 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);
--- 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;

mercurial