Date: Wednesday, January 31, 2007 @ 11:45:10
Author: marc
Path: /cvsroot/carob/carob
Modified: include/Common.hpp (1.57 -> 1.58) src/Common.cpp (1.66 -> 1.67)
Simplified explicit template instantiation of: toWString(),
toUserString() and wstringTo(). Will help CAROB-116
--------------------+
include/Common.hpp | 35 +++++------------------------------
src/Common.cpp | 20 ++++++++++----------
2 files changed, 15 insertions(+), 40 deletions(-)
Index: carob/include/Common.hpp
diff -u carob/include/Common.hpp:1.57 carob/include/Common.hpp:1.58
--- carob/include/Common.hpp:1.57 Fri Jan 19 13:04:31 2007
+++ carob/include/Common.hpp Wed Jan 31 11:45:10 2007
@@ -196,17 +196,13 @@
/**
* Converts any type to wstring using C locale (locale independant). To be used
* for internal conversions
- * Implemented so far:
- * java_byte
- * char
- * wchar_t
- * uint16_t
+ * Explicitly instantiated:
* int16_t
+ * uint16_t
+ * int32_t
* uint32_t
* int64_t
* uint64_t
- * int
- * long
* float
* double
* @return a wstring representation of the given argument
@@ -216,18 +212,7 @@
/**
* Converts any type to wstring using user current locale (ie. std::locale()).
* To be used for user-oriented info (logs, exception)
- * Implemented so far:
- * java_byte
- * char
- * wchar_t
- * int16_t
- * uint16_t
- * int32_t
- * uint32_t
- * int64_t
- * uint64_t
- * float
- * double
+ * Explicitly instantiated: see above
* @see toWString(const T&)
* @return a wstring representation of the given argument
*/
@@ -239,17 +224,7 @@
* Ignores whitespaces and eventual characters following the number.
* eg. 123abc will be transformed to 123
* Function found at http://www.codeguru.com/forum/showthread.php?t=231054
- * Types implemented so far:
- * char
- * wchar_t
- * int16_t
- * uint16_t
- * int32_t
- * uint32_t
- * int64_t
- * uint64_t
- * float
- * double
+ * Explicitly instantiated: see above
* @return true if the conversion succeeded, false otherwise
*/
template <class T> bool wstringTo(T& t, const std::wstring& s);
Index: carob/src/Common.cpp
diff -u carob/src/Common.cpp:1.66 carob/src/Common.cpp:1.67
--- carob/src/Common.cpp:1.66 Fri Jan 19 13:04:31 2007
+++ carob/src/Common.cpp Wed Jan 31 11:45:10 2007
@@ -247,11 +247,11 @@
buffer << t;
return buffer.str();
}
-// Explicit instantiation for types actually used
+// Explicit instantiation to avoid Borland/Cfront/whatever else
+// non-portable solution to the template instantiation problem.
+// Don't instantiate fuzzy types like (unsigned?) "char" or "long"
+// they cause portability headaches (see CAROB-116).
// Don't forget to update javadoc when changing this
-template wstring CarobNS::toWString<CarobNS::java_byte>(const
CarobNS::java_byte&);
-template wstring CarobNS::toWString<char>(const char&);
-template wstring CarobNS::toWString<wchar_t>(const wchar_t&);
template wstring CarobNS::toWString<int16_t>(const int16_t&);
template wstring CarobNS::toWString<uint16_t>(const uint16_t&);
template wstring CarobNS::toWString<int32_t>(const int32_t&);
@@ -271,9 +271,7 @@
return buffer.str();
}
-template wstring CarobNS::toUserString<CarobNS::java_byte>(const
CarobNS::java_byte&);
-template wstring CarobNS::toUserString<char>(const char&);
-template wstring CarobNS::toUserString<wchar_t>(const wchar_t&);
+// Explicit instantiation, see toWString() above
template wstring CarobNS::toUserString<int16_t>(const int16_t&);
template wstring CarobNS::toUserString<uint16_t>(const uint16_t&);
template wstring CarobNS::toUserString<int32_t>(const int32_t&);
@@ -288,9 +286,11 @@
std::wistringstream iss(s);
return !(iss >> std::skipws >> t).fail();
}
-// Explicit instantiation for types actually used
-// Don't forget to update javadoc when changing this
-template bool CarobNS::wstringTo<int>(int&, const std::wstring&);
+// Explicit instantiation, see toWString() above
+template bool CarobNS::wstringTo<int16_t>(int16_t&, const std::wstring&);
+template bool CarobNS::wstringTo<uint16_t>(uint16_t&, const std::wstring&);
+template bool CarobNS::wstringTo<int32_t>(int32_t&, const std::wstring&);
+template bool CarobNS::wstringTo<uint32_t>(uint32_t&, const std::wstring&);
template bool CarobNS::wstringTo<int64_t>(int64_t&, const std::wstring&);
template bool CarobNS::wstringTo<uint64_t>(uint64_t&, const std::wstring&);
template bool CarobNS::wstringTo<float>(float&, const std::wstring&);
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits