Date: Wednesday, March 22, 2006 @ 18:54:23
Author: gilles
Path: /cvsroot/carob/carob
Modified: include/Common.hpp (1.40 -> 1.41) src/Common.cpp (1.35 -> 1.36)
Introduced decimal point global variables:
. user decimal point will be the default decimal separator in user's current
locale (if any) at library init time
. controller decimal point is the "standard" decimal separator (ie. '.') that
is used by the controller to parse numbers (eg. floats)
Added toWString implem for chars + fixed javadoc
--------------------+
include/Common.hpp | 19 +++++++++++++++----
src/Common.cpp | 9 +++++++++
2 files changed, 24 insertions(+), 4 deletions(-)
Index: carob/include/Common.hpp
diff -u carob/include/Common.hpp:1.40 carob/include/Common.hpp:1.41
--- carob/include/Common.hpp:1.40 Wed Mar 22 18:26:06 2006
+++ carob/include/Common.hpp Wed Mar 22 18:54:23 2006
@@ -88,6 +88,14 @@
#endif
;
+// Decimal point (decimal separator)
+extern wchar_t userDecimalPoint;
+/**
+ * The controller uses the default decimal point separator for parsing numbers,
+ * so we have to send him the right one, ie. the default C one.
+ */
+extern wchar_t controllerDecimalPoint;
+
/** The current log level (set by setLogLevel) */
extern LogLevel currentLogLevel;
@@ -148,10 +156,12 @@
/**
* Converts any type to wstring
* Implemented so far:
+ * char
* uint16_t
* int16_t
* uint32_t
* int64_t
+ * uint64_t
* int
* long
* float
@@ -167,10 +177,11 @@
* eg. 123abc will be transformed to 123
* Function found at http://www.codeguru.com/forum/showthread.php?t=231054
* Types implemented so far:
- * int
- * int64_t
- * float
- * double
+ * int
+ * int64_t
+ * uint64_t
+ * float
+ * double
*
* @return true if the conversion succeeded, false otherwise
*/
Index: carob/src/Common.cpp
diff -u carob/src/Common.cpp:1.35 carob/src/Common.cpp:1.36
--- carob/src/Common.cpp:1.35 Fri Mar 17 20:46:40 2006
+++ carob/src/Common.cpp Wed Mar 22 18:54:23 2006
@@ -298,6 +298,12 @@
const CarobNS::MBSCodec CarobNS::StaticCodecs::user_codec(tryuserlocale());
const CarobNS::MBSCodec CarobNS::StaticCodecs::utf8_codec(tryUTF8locale());
+// decimal point initialization
+wchar_t CarobNS::userDecimalPoint =
+ std::use_facet<std::numpunct<wchar_t> >(tryuserlocale()).decimal_point();
+wchar_t CarobNS::controllerDecimalPoint =
+ std::use_facet<std::numpunct<wchar_t> >(std::locale("C")).decimal_point();
+
//Can this be factorized with ParameterStatement ?
template <class T> wstring CarobNS::toWString(const T& t)
{
@@ -306,6 +312,8 @@
return buffer.str();
}
// Explicit instantiation for types actually used
+// Don't forget to update javadoc when changing this
+template wstring CarobNS::toWString<char>(const char&);
template wstring CarobNS::toWString<uint16_t>(const uint16_t&);
template wstring CarobNS::toWString<int16_t>(const int16_t&);
template wstring CarobNS::toWString<uint32_t>(const uint32_t&);
@@ -322,6 +330,7 @@
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&);
template bool CarobNS::wstringTo<int64_t>(int64_t&, const std::wstring&);
template bool CarobNS::wstringTo<uint64_t>(uint64_t&, const std::wstring&);
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits