Date: Friday, January 27, 2006 @ 19:03:19
  Author: marc
    Path: /cvsroot/carob/carob/src

Modified: ParameterStatement.cpp (1.14 -> 1.15)

Moved setString() code to its template specialization. CAROB-55.


------------------------+
 ParameterStatement.cpp |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)


Index: carob/src/ParameterStatement.cpp
diff -u carob/src/ParameterStatement.cpp:1.14 
carob/src/ParameterStatement.cpp:1.15
--- carob/src/ParameterStatement.cpp:1.14       Fri Jan 27 18:33:58 2006
+++ carob/src/ParameterStatement.cpp    Fri Jan 27 19:03:19 2006
@@ -153,7 +153,7 @@
  * Stream filter: intercept (only) one value, modify it before printing it, 
and returns the
  * filtered stream before disappearing.
  */
-template <class T, class Ch>
+template <class T, class Ch = wchar_t>
 class oneShotFilter
 {
   basic_ostream<Ch>& wrapped_stream;
@@ -301,11 +301,31 @@
 public:
   void doManip(basic_ostream<Ch>& s) const
   {
+    // see: java.lang.Boolean#toBoolean()
     s.imbue(locC);
     s << std::boolalpha;
   };
 };
 
+// template specialization for wstring
+template <>
+class oneShotFilter<wstring>
+{
+  basic_ostream<wchar_t>& wrapped_stream;
+public:
+  oneShotFilter(basic_ostream<wchar_t>& s) : wrapped_stream(s) { } ;
+  basic_ostream<wchar_t>&
+ // this is the actual filtering operator
+  operator<< (wstring value)
+  { 
+    wrapped_stream <<
+      (value == NULL_TAG ? NULL_STRING_TAG : replaceAll(value, TAG_MARKER, 
TAG_MARKER_ESCAPE));
+    // then return the underlying stream (we filter only once!)
+    return wrapped_stream;
+  }
+};
+
+
 
 } // namespace CarobNS
 
@@ -361,6 +381,11 @@
   set<std::wstring>(parameterIndex, NULL_TAG, emptyString);
 }
 
+
+// Don't add any code in here, use template specializations
+// above. CAROB-55: We may deprecate these methods in the future in
+// profit of the underlying templates
+
 void ParameterStatement::setBoolean(const int parameterIndex, const bool x)
     throw (DriverException, UnexpectedException)
 {
@@ -406,12 +431,11 @@
 void ParameterStatement::setBigDecimal(const int parameterIndex, const 
BigDecimal &x)
     throw (DriverException, UnexpectedException)
 {
-  set<wstring>(parameterIndex, BIG_DECIMAL_TAG, x);
+  set<wstring>(parameterIndex, BIG_DECIMAL_TAG, x); // FIXME: should be 
set<BigDecimal>, else explain
 }
 
 void ParameterStatement::setString(const int parameterIndex, const 
std::wstring &x)
     throw (DriverException, UnexpectedException)
 {
-  set<wstring>(parameterIndex, STRING_TAG, 
-    x == NULL_TAG ? NULL_STRING_TAG : replaceAll(x, TAG_MARKER, 
TAG_MARKER_ESCAPE));
+  set<wstring>(parameterIndex, STRING_TAG, x);
 }

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

Reply via email to