Date: Wednesday, November 29, 2006 @ 12:44:06
  Author: marc
    Path: /cvsroot/carob/carob

Modified: include/SQLDataSerialization.hpp (1.15 -> 1.16)
          src/SQLDataSerialization.cpp (1.35 -> 1.36)
          test/40-Parameter-PreparedStatement/TestIEEE754.cpp (1.14 ->
          1.15)

SQLDataSerialization::floatToU32bits() and sisters are now simple static inline 
C functions, no more visible.
This will prevent nightmarish debates about inline member functions having 
internal vs external linkage.


-----------------------------------------------------+
 include/SQLDataSerialization.hpp                    |   28 ------------
 src/SQLDataSerialization.cpp                        |   39 ++++++++++++------
 test/40-Parameter-PreparedStatement/TestIEEE754.cpp |    5 +-
 3 files changed, 29 insertions(+), 43 deletions(-)


Index: carob/include/SQLDataSerialization.hpp
diff -u carob/include/SQLDataSerialization.hpp:1.15 
carob/include/SQLDataSerialization.hpp:1.16
--- carob/include/SQLDataSerialization.hpp:1.15 Thu Mar 23 17:10:04 2006
+++ carob/include/SQLDataSerialization.hpp      Wed Nov 29 12:44:05 2006
@@ -64,34 +64,6 @@
   static deserializerPtr getDeserializer(TypeTag ttPrm)
       throw (NotImplementedException, UnexpectedException);
 
-  /**
-   * Relatively safe "reinterpret_cast" of an IEEE 754 float to its
-   * uint32_t bit representation. Does NOT swap bytes in any way, so
-   * endianness of the result is arch-specific. Endianness of floats
-   * is typically the same as for integer types, but not granted.
-   * @param f value to convert
-   */
-  static uint32_t
-  floatToU32Bits(float f);
-
-  /** See floatToU32Bits(float f) */
-  static float
-  U32BitsToFloat(uint32_t ui);
-
-  /**
-   * Relatively safe "reinterpret_cast" of an IEEE 754 double to its
-   * uint64_t bit representation. Does NOT swap bytes in any way, so
-   * endianness of the result is arch-specific. Endianness of doubles
-   * is typically the same as for integer types, but not granted.
-   * @param d value to convert
-   */
-  static uint64_t
-  doubleToU64Bits(double d);
-
-  /** See doubleToU64Bits(double d) */
-  static double
-  U64BitsToDouble(uint64_t ui);
-
 };
 
 /** Hold a SQL <code>TIMESTAMP</code> value */
Index: carob/src/SQLDataSerialization.cpp
diff -u carob/src/SQLDataSerialization.cpp:1.35 
carob/src/SQLDataSerialization.cpp:1.36
--- carob/src/SQLDataSerialization.cpp:1.35     Wed Sep 20 17:09:29 2006
+++ carob/src/SQLDataSerialization.cpp  Wed Nov 29 12:44:05 2006
@@ -103,9 +103,15 @@
 }
 
 // Float
-
-inline uint32_t
-SQLDataSerialization::floatToU32Bits(float f)
+  /**
+   * Relatively safe "reinterpret_cast" of an IEEE 754 float to its
+   * uint32_t bit representation. Does NOT swap bytes in any way, so
+   * endianness of the result is arch-specific. Endianness of floats
+   * is typically the same as for integer types, but not granted.
+   * @param f value to convert
+   */
+static inline uint32_t
+floatToU32Bits(float f)
 {
     // "union casting" using { float; uint32_t; } or the simpler:
     //        return * (uint32_t *) &f;
@@ -122,8 +128,8 @@
         | (uint32_t) bytes[0];
 }
 
-inline float
-SQLDataSerialization::U32BitsToFloat(const uint32_t ui)
+static inline float
+U32BitsToFloat(const uint32_t ui)
 {
     float res;
     unsigned char *f_bytes = reinterpret_cast<unsigned char *>(&res);
@@ -156,14 +162,21 @@
       // obviously cannot use ntohl() to swap unconditionnally!
       throw NotImplementedException(L"Inverted endianness Not Implemented 
Yet");
   else
-      res.as_float = SQLDataSerialization::U32BitsToFloat(intRead); // sign 
casting here
+      res.as_float = U32BitsToFloat(intRead); // sign casting here
 
   return res;
 }
 
 // Double
-inline uint64_t
-SQLDataSerialization::doubleToU64Bits(double d)
+  /**
+   * Relatively safe "reinterpret_cast" of an IEEE 754 double to its
+   * uint64_t bit representation. Does NOT swap bytes in any way, so
+   * endianness of the result is arch-specific. Endianness of doubles
+   * is typically the same as for integer types, but not granted.
+   * @param d value to convert
+   */
+static inline uint64_t
+doubleToU64Bits(double d)
 {
     const unsigned char *bytes = reinterpret_cast<const unsigned char *>(&d);
 
@@ -177,8 +190,8 @@
         | (uint64_t) bytes[0];
 }
 
-inline double
-SQLDataSerialization::U64BitsToDouble(const uint64_t ui)
+static inline double
+U64BitsToDouble(const uint64_t ui)
 {
     double res;
     unsigned char *d_bytes = reinterpret_cast<unsigned char *>(&res);
@@ -215,7 +228,7 @@
   if (floats_inverted_endianness)
       throw NotImplementedException(L"Inverted endianness Not Implemented 
Yet");
   else
-      res.as_double = SQLDataSerialization::U64BitsToDouble(intRead); // sign 
casting here
+      res.as_double = U64BitsToDouble(intRead); // sign casting here
 
   return res;
 }
@@ -336,8 +349,8 @@
 namespace {
 
 // shortcuts
-#define F2I(f) SQLDataSerialization::floatToU32Bits(f)
-#define D2I(d) SQLDataSerialization::doubleToU64Bits(d);
+#define F2I(f) floatToU32Bits(f)
+#define D2I(d) doubleToU64Bits(d);
 
 bool
 floats_little_endianness()
Index: carob/test/40-Parameter-PreparedStatement/TestIEEE754.cpp
diff -u carob/test/40-Parameter-PreparedStatement/TestIEEE754.cpp:1.14 
carob/test/40-Parameter-PreparedStatement/TestIEEE754.cpp:1.15
--- carob/test/40-Parameter-PreparedStatement/TestIEEE754.cpp:1.14      Wed Sep 
20 17:09:29 2006
+++ carob/test/40-Parameter-PreparedStatement/TestIEEE754.cpp   Wed Nov 29 
12:44:06 2006
@@ -66,11 +66,12 @@
     std::cout.precision(9);
     std::cout << f << " (=";
     std::cout.width(10);
-    std::cout << SQLDataSerialization::floatToU32Bits(f) << ") | ";
+// export these functions from SQLDataSerialization.[ch]pp for debug
+//    std::cout << floatToU32Bits(f) << ") | ";
     std::cout.precision(17);
     std::cout << d << " (=";
     std::cout.width(18);
-    std::cout << SQLDataSerialization::doubleToU64Bits(d) << ")";
+//    std::cout << doubleToU64Bits(d) << ")";
 }
 
 template <class FP> bool

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

Reply via email to