activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r563239 - in /activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util: NumberConverter.cpp NumberConverter.h
Date Mon, 06 Aug 2007 19:58:01 GMT
Author: tabish
Date: Mon Aug  6 12:58:00 2007
New Revision: 563239

URL: http://svn.apache.org/viewvc?view=rev&rev=563239
Log:
http://issues.apache.org/activemq/browse/AMQCPP-103

Implementing the Primitive Wrappers fully

Modified:
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/NumberConverter.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/NumberConverter.h

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/NumberConverter.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/NumberConverter.cpp?view=diff&rev=563239&r1=563238&r2=563239
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/NumberConverter.cpp
(original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/NumberConverter.cpp
Mon Aug  6 12:58:00 2007
@@ -17,49 +17,44 @@
 
 #include "NumberConverter.h"
 
+#include <decaf/lang/Math.h>
+
 using namespace decaf;
+using namespace decaf::lang;
 using namespace decaf::internal;
 using namespace decaf::internal::util;
 
 ////////////////////////////////////////////////////////////////////////////////
-NumberConverter::NumberConverter() {
-}
+const double NumberConverter::invLogOfTenBaseTwo =
+    Math::log(2.0) / Math::log(10.0);
+NumberConverter::StaticInitializer NumberConverter::init;
 
+////////////////////////////////////////////////////////////////////////////////
+NumberConverter::StaticInitializer::StaticInitializer() {
 
-public final class NumberConverter {
-
-    private int setCount; // number of times u and k have been gotten
-
-    private int getCount; // number of times u and k have been set
+    NumberConverter::TEN_TO_THE.resize(20);
+    NumberConverter::TEN_TO_THE[0] = 1L;
 
-    private int[] uArray = new int[64];
+    for( int i = 1; i < TEN_TO_THE.length; ++i ) {
+        long long previous = TEN_TO_THE[i - 1];
+        TEN_TO_THE[i] = ( previous << 1 ) + ( previous << 3 );
+    }
+}
 
-    private int firstK;
+////////////////////////////////////////////////////////////////////////////////
+NumberConverter::NumberConverter() {
 
-    private final static double invLogOfTenBaseTwo = Math.log(2.0)
-            / Math.log(10.0);
+    this->getCount = 0;
+    this->setCount = 0;
+    this->firstK = 0;
+    this->uArray.resize(64);
+}
 
-    private final static long[] TEN_TO_THE = new long[20];
 
-    static {
-        TEN_TO_THE[0] = 1L;
-        for (int i = 1; i < TEN_TO_THE.length; ++i) {
-            long previous = TEN_TO_THE[i - 1];
-            TEN_TO_THE[i] = (previous << 1) + (previous << 3);
-        }
-    }
+public final class NumberConverter {
 
-    private static NumberConverter getConverter() {
-        return new NumberConverter();
-    }
 
-    public static String convert(double input) {
-        return getConverter().convertD(input);
-    }
 
-    public static String convert(float input) {
-        return getConverter().convertF(input);
-    }
 
     public String convertD(double inputNumber) {
         int p = 1023 + 52; // the power offset (precision)

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/NumberConverter.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/NumberConverter.h?view=diff&rev=563239&r1=563238&r2=563239
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/NumberConverter.h (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/NumberConverter.h Mon
Aug  6 12:58:00 2007
@@ -25,12 +25,65 @@
     class NumberConverter {
     private:
 
+        int setCount;
+        int getCount;
+        int firstK;
+        std::vector<int> uArray;
+
+        static std::vector<long long> TEN_TO_THE;
+        static const double invLogOfTenBaseTwo;
+
+        // Internal class used to init static arrays
+        struct StaticInitializer {
+            StaticInitializer();
+        };
+
+        static StaticInitializer init;
+
     public:
 
         NumberConverter();
         virtual ~NumberConverter() {}
 
+        /**
+         * @param value - the double to convert
+         * @returns the string representation of value
+         */
+        std::string convertD( double value );
+
+        /**
+         * @param value - the float to convert
+         * @returns the string representation of value
+         */
+        std::string convertF( float value );
+
     public:   // Statics
+
+        /**
+         * @param value to convert to a string
+         * @returns the value converted to a string
+         */
+        static std::string convert( double value ) {
+            return NumberConverter().convertD( value );
+        }
+
+        /**
+         * @param value to convert to a string
+         * @returns the value converted to a string
+         */
+        static std::string convert( float value ) {
+            return NumberConverter().convertF( value );
+        }
+
+    private:
+
+        std::string freeFormatExponential();
+        std::string freeFormat();
+
+        void bigIntDigitGeneratorInstImpl(
+            long f, int e, bool isDenormalized, bool mantissaIsZero, int p );
+        void longDigitGenerator(
+            long f, int e, bool isDenormalized, bool mantissaIsZero, int p );
 
     };
 



Mime
View raw message