Date: Wednesday, January 17, 2007 @ 17:23:31
  Author: marc
    Path: /cvsroot/carob/carob

Modified: include/Common.hpp (1.54 -> 1.55) include/DriverSocket.hpp (1.18
          -> 1.19) src/Common.cpp (1.60 -> 1.61) src/ControllerInfo.cpp
          (1.12 -> 1.13) src/JavaSocket.cpp (1.72 -> 1.73)

- Exported tryUTF8locale() from Common.hpp to JavaSocket.cpp (where it should 
be moved later)
- JavaSocket now has its private ut8_codec to talk with the controller.
- JavaSocket & DriverSocket ctors now throw CodecException, caught in 
ControllerInfo.cpp
- DriverSocket ctor never throws ConnectionException: removed from signature


--------------------------+
 include/Common.hpp       |    6 ++++++
 include/DriverSocket.hpp |    2 +-
 src/Common.cpp           |   14 +++++++++-----
 src/ControllerInfo.cpp   |   11 ++++++++++-
 src/JavaSocket.cpp       |   11 ++++++++---
 5 files changed, 34 insertions(+), 10 deletions(-)


Index: carob/include/Common.hpp
diff -u carob/include/Common.hpp:1.54 carob/include/Common.hpp:1.55
--- carob/include/Common.hpp:1.54       Thu Jan 11 11:34:42 2007
+++ carob/include/Common.hpp    Wed Jan 17 17:23:31 2007
@@ -57,6 +57,12 @@
 }
 #endif
 
+// should move this to JavaSocket.cpp at some point
+#include <locale>
+namespace CarobNS {
+std::locale tryUTF8locale();
+}
+
 namespace CarobNS {
 
 // This is to check that carob and its client are in sync concerning
Index: carob/include/DriverSocket.hpp
diff -u carob/include/DriverSocket.hpp:1.18 carob/include/DriverSocket.hpp:1.19
--- carob/include/DriverSocket.hpp:1.18 Tue Nov 28 17:07:55 2006
+++ carob/include/DriverSocket.hpp      Wed Jan 17 17:23:31 2007
@@ -42,7 +42,7 @@
    * Empty constructor
    * @throws ConnectionException if the connection fails
    */
-  DriverSocket() throw (ConnectionException, UnexpectedException) : 
JavaSocket() {}
+  DriverSocket() throw (CodecException, UnexpectedException) : JavaSocket() {}
 
   /**
    * Writes a string to the socket according to the controller protocol
Index: carob/src/Common.cpp
diff -u carob/src/Common.cpp:1.60 carob/src/Common.cpp:1.61
--- carob/src/Common.cpp:1.60   Tue Jan 16 19:13:16 2007
+++ carob/src/Common.cpp        Wed Jan 17 17:23:31 2007
@@ -244,9 +244,10 @@
 }
 
 namespace {
-  using namespace CarobNS;
-
   std::locale tryuserlocale();
+}
+
+namespace CarobNS {
 
   std::locale tryUTF8locale()
   {
@@ -339,13 +340,16 @@
     // See CAROB-74
 
   } // tryUTF8locale()
+} // namespace CarobNS
+
+namespace {
 
   std::locale tryuserlocale()
   {
     try {
       return std::locale("");
     } catch (std::runtime_error& ) {
-      logInit(LOG_LEVEL_WARN, __WFILE__ L":tryuserlocale()",
+      logInit(CarobNS::LOG_LEVEL_WARN, __WFILE__ L":tryuserlocale()",
               L"Missing user-preferred locale (check LANG). "
               "Falling back on current global locale.");
       return std::locale();
@@ -380,7 +384,7 @@
 }
 // Explicit instantiation for types actually used
 // Don't forget to update javadoc when changing this
-template wstring CarobNS::toWString<java_byte>(const java_byte&);
+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&);
@@ -402,7 +406,7 @@
   return buffer.str();        
 }
 
-template wstring CarobNS::toUserString<java_byte>(const java_byte&);
+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&);
 template wstring CarobNS::toUserString<int16_t>(const int16_t&);
Index: carob/src/ControllerInfo.cpp
diff -u carob/src/ControllerInfo.cpp:1.12 carob/src/ControllerInfo.cpp:1.13
--- carob/src/ControllerInfo.cpp:1.12   Tue Jan  9 20:28:26 2007
+++ carob/src/ControllerInfo.cpp        Wed Jan 17 17:23:31 2007
@@ -128,7 +128,16 @@
 {
   const wstring fctName(L"ControllerInfo::connect()");
 
-  DriverSocket* socketPtr = new DriverSocket();
+  DriverSocket* socketPtr;
+  try {
+    socketPtr = new DriverSocket();
+  } catch (CodecException ce) {
+    std::wostringstream woss;
+    woss << ce;
+    logError(fctName, woss.str() );
+    throw ConnectionException(ce.description(), ce.getSQLState(), &ce);
+  }
+
   // set the correct protocol family
   int family = PF_INET;
   if (socket_address.getFamily() == AF_INET6)
Index: carob/src/JavaSocket.cpp
diff -u carob/src/JavaSocket.cpp:1.72 carob/src/JavaSocket.cpp:1.73
--- carob/src/JavaSocket.cpp:1.72       Tue Jan 16 10:35:08 2007
+++ carob/src/JavaSocket.cpp    Wed Jan 17 17:23:31 2007
@@ -70,7 +70,12 @@
 }
 
 
-JavaSocket::JavaSocket() :
+JavaSocket::JavaSocket() throw (CodecException) :
+#ifdef CAROB_USE_ICONV
+  utf8_codec("UTF-8"),
+#else
+  utf8_codec(CarobNS::tryUTF8locale()),
+#endif
 socket_fd(-1),
 connected(false),
 canceled(false)
@@ -253,7 +258,7 @@
 
   try
   {
-    utf8str = toUTF8(str);
+    utf8str = utf8_codec.encode(str);
   }
   catch (const CodecException&)
   { // Don't leave connection in such a rotten state, see CAROB-101
@@ -289,7 +294,7 @@
 
   try
   {
-    s = fromUTF8(received);
+    s = utf8_codec.decode(received);
   }
   catch (const CodecException&)
   { 

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

Reply via email to