Date: Friday, December 16, 2005 @ 18:00:35
  Author: gilles
    Path: /cvsroot/carob/carob

Modified: include/Common.hpp (1.19 -> 1.20) src/Common.cpp (1.13 -> 1.14)
          src/DriverResultSet.cpp (1.25 -> 1.26)

Renamed wstringToA to wstringTo, commented out function and removed base 
parameter


-------------------------+
 include/Common.hpp      |    8 +++++---
 src/Common.cpp          |    8 +++-----
 src/DriverResultSet.cpp |    2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)


Index: carob/include/Common.hpp
diff -u carob/include/Common.hpp:1.19 carob/include/Common.hpp:1.20
--- carob/include/Common.hpp:1.19       Thu Dec 15 17:11:59 2005
+++ carob/include/Common.hpp    Fri Dec 16 18:00:35 2005
@@ -135,12 +135,14 @@
 std::wstring toWString(const int& i);
 
 /**
- * Converts a wstring to any given type in the given base.
+ * Converts the given wstring to any given type.
+ * Uses wistringstream >> operator.
+ * 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
  * @return true if the conversion succeeded, false otherwise
  */
-template <class T> bool wstringToA(T& t, const std::wstring& s, 
-    std::ios_base& (*f)(std::ios_base&));
+template <class T> bool wstringTo(T& t, const std::wstring& s);
 
 /**
  * Defines data type that can be found in ResultSets
Index: carob/src/Common.cpp
diff -u carob/src/Common.cpp:1.13 carob/src/Common.cpp:1.14
--- carob/src/Common.cpp:1.13   Thu Dec 15 12:25:53 2005
+++ carob/src/Common.cpp        Fri Dec 16 18:00:35 2005
@@ -163,13 +163,11 @@
   return buffer.str();        
 }
 
-template <class T> bool CarobNS::wstringToA(T& t, const std::wstring& s, 
-    std::ios_base& (*f)(std::ios_base&))
+template <class T> bool CarobNS::wstringTo(T& t, const std::wstring& s)
 {
   std::wistringstream iss(s);
-  return !(iss >> f >> t).fail();
+  return !(iss >> std::skipws >> t).fail();
 }
 // Explicit instanciation for types actually used
 // More info here: http://www.codeproject.com/cpp/templatesourceorg.asp
-template bool CarobNS::wstringToA<int>(int&, const std::wstring&,
-    std::ios_base& (*f)(std::ios_base&));
+template bool CarobNS::wstringTo<int>(int&, const std::wstring&);
Index: carob/src/DriverResultSet.cpp
diff -u carob/src/DriverResultSet.cpp:1.25 carob/src/DriverResultSet.cpp:1.26
--- carob/src/DriverResultSet.cpp:1.25  Thu Dec 15 15:55:57 2005
+++ carob/src/DriverResultSet.cpp       Fri Dec 16 18:00:35 2005
@@ -313,7 +313,7 @@
     { //these bracket to be able to declare loc var without warns
       wstring valAsString = trim(*(wstring*)(data[currentRow][columnIndex - 
1].as_other));
       //Tries to parse the string as an integer
-      if(!wstringToA<int>(ret, valAsString, std::dec))
+      if(!wstringTo<int>(ret, valAsString))
       {
         //Last chance: is it a boolean ?
         transform(valAsString.begin(),valAsString.end(), valAsString.begin(), 
tolower);

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to