Date: Wednesday, January 25, 2006 @ 23:05:25
  Author: marc
    Path: /cvsroot/carob/carob

Modified: include/BigDecimal.hpp (1.11 -> 1.12) src/BigDecimal.cpp (1.14
          -> 1.15) src/SQLDataSerialization.cpp (1.16 -> 1.17)

changed static BigDecimal::deserializer into a constructor(stream)


------------------------------+
 include/BigDecimal.hpp       |    5 ++---
 src/BigDecimal.cpp           |   33 +++++++++++++--------------------
 src/SQLDataSerialization.cpp |   12 ++++++++++--
 3 files changed, 25 insertions(+), 25 deletions(-)


Index: carob/include/BigDecimal.hpp
diff -u carob/include/BigDecimal.hpp:1.11 carob/include/BigDecimal.hpp:1.12
--- carob/include/BigDecimal.hpp:1.11   Tue Jan 24 17:51:49 2006
+++ carob/include/BigDecimal.hpp        Wed Jan 25 23:05:25 2006
@@ -57,12 +57,11 @@
   virtual ~BigDecimal();
   
   /**
-   * Static function to deserialize a BigDecimal from a stream.
+   * Constructor to deserialize a BigDecimal from a stream.
    * @param input socket from which to deserializer Big Decimal
-   * @return pointer to BigDecimal as a void*
    * @throws SocketIOException if an error occurs on the stream
    */
-  static ResultSetDataType deserializer(const DriverSocket& input)
+  BigDecimal::BigDecimal(const DriverSocket& input)
       throw (SocketIOException, UnexpectedException);
   /**
    * Convertion to string. Handy for displaying the number
Index: carob/src/BigDecimal.cpp
diff -u carob/src/BigDecimal.cpp:1.14 carob/src/BigDecimal.cpp:1.15
--- carob/src/BigDecimal.cpp:1.14       Tue Jan 24 17:51:49 2006
+++ carob/src/BigDecimal.cpp    Wed Jan 25 23:05:25 2006
@@ -43,20 +43,17 @@
   }
 }
 
-// TODO: why not a constructor here?
-ResultSetDataType BigDecimal::deserializer(const DriverSocket& input)
+BigDecimal::BigDecimal(const DriverSocket& input)
     throw (SocketIOException, UnexpectedException)
 {
-  BigDecimal* retVal = new BigDecimal();
-  ResultSetDataType res;
   //1. Read intVal:
   //1.1 Read intValLength
   int32_t lengthRead;
   input>>lengthRead;
   //We receive the length as an int32 but internally, we have an array of 
bytes,
   //which length actually is of size_t type
-  retVal->byteArrayLength = (size_t)lengthRead;
-  if (retVal->byteArrayLength == 0)
+  this->byteArrayLength = (size_t)lengthRead;
+  if (this->byteArrayLength == 0)
   {
     //This is a zero, no byte array
     // FIXME: for safety, create an empty byte array instead
@@ -64,11 +61,11 @@
   }
   else
   {
-    retVal->byteArray = new java_byte[retVal->byteArrayLength];
+    this->byteArray = new java_byte[this->byteArrayLength];
     //1.2 Compute padding
     unsigned int idx = 0;
     int32_t wordRead = 0;
-    unsigned int padding = retVal->byteArrayLength%4;
+    unsigned int padding = this->byteArrayLength%4;
     //If there is a padding, we must read the first 'padding' bytes
     //so we are aligned for the rest of the bytes
     if (padding > 0)
@@ -76,31 +73,27 @@
       input>>wordRead;
       for (idx=0; idx<padding; idx++)
       {
-        retVal->byteArray[idx] = 
(java_byte)((wordRead>>(8*(padding-idx-1)))&0xFF);
+        this->byteArray[idx] = 
(java_byte)((wordRead>>(8*(padding-idx-1)))&0xFF);
       }
     }
     //1.3 Read the byte array from integers
     //we start from the first aligned byte
-    for (; idx<retVal->byteArrayLength; idx+=4)
+    for (; idx<this->byteArrayLength; idx+=4)
     {
       input>>wordRead;
-      retVal->byteArray[idx]   = (java_byte)((wordRead>>24)&0xFF);
-      retVal->byteArray[idx+1] = (java_byte)((wordRead>>16)&0xFF);
-      retVal->byteArray[idx+2] = (java_byte)((wordRead>> 8)&0xFF);
-      retVal->byteArray[idx+3] = (java_byte) (wordRead     &0xFF);
+      this->byteArray[idx]   = (java_byte)((wordRead>>24)&0xFF);
+      this->byteArray[idx+1] = (java_byte)((wordRead>>16)&0xFF);
+      this->byteArray[idx+2] = (java_byte)((wordRead>> 8)&0xFF);
+      this->byteArray[idx+3] = (java_byte) (wordRead     &0xFF);
     }
   }
   
   // UNTESTED
   // 1.4 read sign
-  input>>retVal->signum;
+  input>>this->signum;
   
   //2. Read scale
-  input>>retVal->scale;
-
-  
-  res.as_other = static_cast<void*>(retVal);
-  return res;
+  input>>this->scale;
 }
 
 int* BigDecimal::toIntArray(int& intArrayLength) const
Index: carob/src/SQLDataSerialization.cpp
diff -u carob/src/SQLDataSerialization.cpp:1.16 
carob/src/SQLDataSerialization.cpp:1.17
--- carob/src/SQLDataSerialization.cpp:1.16     Tue Jan 24 18:54:51 2006
+++ carob/src/SQLDataSerialization.cpp  Wed Jan 25 23:05:25 2006
@@ -55,7 +55,15 @@
   res.as_other = static_cast<void*>(strRead);
   return res;
 }
-// Big Decimal => see BigDecimal class
+
+// BigDecimal
+ResultSetDataType bigDecimalDeserializer(const DriverSocket& input)
+    throw (SocketIOException, UnexpectedException)
+{
+  ResultSetDataType res;
+  res.as_other = new BigDecimal::BigDecimal(input);
+  return res;
+}
 
 // Int
 ResultSetDataType integerDeserializer(const DriverSocket& input)
@@ -230,7 +238,7 @@
     case TT_BIGDECIMAL:
       // comment out the throw() line below to test the new bigdecimal 
serialization
       throw NotImplementedException(L"BigDecimal serialization not enabled 
yet: waiting for sequoia commit");
-      return BigDecimal::deserializer;
+      return bigDecimalDeserializer;
     break;
     case TT_BOOLEAN:
       return booleanDeserializer;

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

Reply via email to