activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r564238 - in /activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util: FloatingPointParser.cpp HexStringParser.cpp HexStringParser.h
Date Thu, 09 Aug 2007 15:23:53 GMT
Author: tabish
Date: Thu Aug  9 08:23:52 2007
New Revision: 564238

URL: http://svn.apache.org/viewvc?view=rev&rev=564238
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/FloatingPointParser.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/HexStringParser.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/HexStringParser.h

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/FloatingPointParser.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/FloatingPointParser.cpp?view=diff&rev=564238&r1=564237&r2=564238
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/FloatingPointParser.cpp
(original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/FloatingPointParser.cpp
Thu Aug  9 08:23:52 2007
@@ -25,6 +25,7 @@
 #include <decaf/internal/util/HexStringParser.h>
 #include <decaf/internal/util/BigInt.h>
 #include <decaf/internal/util/BitOps.h>
+#include <decaf/lang/exceptions/NumberFormatException.h>
 #include <apr_lib.h>
 
 using namespace std;
@@ -141,6 +142,17 @@
 ////////////////////////////////////////////////////////////////////////////////
 float FloatingPointParser::parseFltImpl( const std::string& value, int exp )
     throw ( exceptions::NumberFormatException ) {
+
+    float flt = (float)exp; // TODO - FloatOps::createFloat( str, exp );
+
+    if( Float::floatToIntBits( flt ) >= 0 ) {
+        return flt;
+    } else if( Float::floatToIntBits( flt ) == -1 ) {
+      throw exceptions::NumberFormatException(
+          __FILE__, __LINE__,
+          "FloatingPointParser::parseFltImpl - Not a valid float string",
+          value.c_str() );
+    }
 
     return 0.0f;
 }

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/HexStringParser.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/HexStringParser.cpp?view=diff&rev=564238&r1=564237&r2=564238
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/HexStringParser.cpp
(original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/HexStringParser.cpp
Thu Aug  9 08:23:52 2007
@@ -22,9 +22,11 @@
 #include <decaf/lang/Long.h>
 #include <decaf/lang/Double.h>
 #include <decaf/lang/Float.h>
+#include <decaf/util/StringTokenizer.h>
 #include <decaf/lang/exceptions/NumberFormatException.h>
 
 using namespace decaf;
+using namespace decaf::util;
 using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 using namespace decaf::internal;
@@ -130,10 +132,13 @@
 ////////////////////////////////////////////////////////////////////////////////
 void HexStringParser::parseMantissa(const std::string& significantStr) {
 
-    //TODO
-    std::string* strings = significantStr.split("\\.");
+    StringTokenizer tokenizer( significantStr, "\\." );
+    std::vector<std::string> strings;
+
+    tokenizer.toArray( strings );
+
     std::string strIntegerPart = strings[0];
-    std::string strDecimalPart = strings.length > 1 ? strings[1] : "";
+    std::string strDecimalPart = strings.size() > 1 ? strings[1] : "";
 
     std::string significand =
         getNormalizedSignificand( strIntegerPart, strDecimalPart) ;
@@ -222,13 +227,11 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-/*
- * The value is rounded up or down to the nearest infinitely precise result.
- * If the value is exactly halfway between two infinitely precise results,
- * then it should be rounded up to the nearest infinitely precise even.
- */
 void HexStringParser::round() {
-    std::string result = abandonedNumber.replaceAll( "0+", "" );
+
+    std::string result = abandonedNumber;
+    replaceAll( result, "0+", "" );
+
     bool moreThanZero = ( result.length() > 0 ? true : false );
 
     int lastDiscardedBit = (int)( mantissa & 1L );
@@ -257,7 +260,7 @@
     replaceFirst( significand, "^0x", "" );
 
     if( significand.length() == 0 ) {
-        significand = "0"; //$NON-NLS-1$
+        significand = "0";
     }
     return significand;
 }

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/HexStringParser.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/HexStringParser.h?view=diff&rev=564238&r1=564237&r2=564238
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/HexStringParser.h (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/internal/util/HexStringParser.h Thu
Aug  9 08:23:52 2007
@@ -187,6 +187,19 @@
                 return target.replace( pos, find.length(), replace );
             }
         }
+
+        // TODO
+        std::string& replaceAll( std::string& target,
+                                 const std::string& find,
+                                 const std::string& replace ) {
+
+            std::string::size_type pos = std::string::npos;
+
+            if( ( pos = target.find_first_of( find, 0 ) ) != std::string::npos ) {
+                return target.replace( pos, find.length(), replace );
+            }
+        }
+
     };
 
 }}}



Mime
View raw message