Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 73543 invoked from network); 2 May 2009 02:00:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 May 2009 02:00:16 -0000 Received: (qmail 2422 invoked by uid 500); 2 May 2009 02:00:16 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 2222 invoked by uid 500); 2 May 2009 02:00:15 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 1965 invoked by uid 99); 2 May 2009 02:00:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 May 2009 02:00:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 May 2009 02:00:06 +0000 Received: by eris.apache.org (Postfix, from userid 1221) id C2E252388CF8; Sat, 2 May 2009 01:59:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r770872 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang: Double.cpp Float.cpp Date: Sat, 02 May 2009 01:59:44 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090502015945.C2E252388CF8@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Sat May 2 00:39:33 2009 New Revision: 770872 URL: http://svn.apache.org/viewvc?rev=770872&view=rev Log: A couple of hacks to get the primitive value conversion code working, the code still doesn't parse float and double values to spec. Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Double.cpp activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Float.cpp Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Double.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Double.cpp?rev=770872&r1=770871&r2=770872&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Double.cpp (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Double.cpp Sat May 2 00:39:33 2009 @@ -18,6 +18,7 @@ #include "Double.h" #include #include +#include #include using namespace std; @@ -137,10 +138,22 @@ } //////////////////////////////////////////////////////////////////////////////// -double Double::parseDouble( DECAF_UNUSED const std::string value ) +double Double::parseDouble( const std::string value ) throw ( exceptions::NumberFormatException ) { - return 0; // TODO + // TODO - This is not going to parse the formats we say we do. + float result = 0.0; + istringstream stream( value ); + stream >> result; + + // Not everything got read, meaning there wasn't just a number here. + if( !stream.eof() ) { + throw exceptions::NumberFormatException( + __FILE__, __LINE__, + "Failed to parse a valid float from input string: %s", value.c_str() ); + } + + return result; } //////////////////////////////////////////////////////////////////////////////// @@ -229,8 +242,13 @@ } //////////////////////////////////////////////////////////////////////////////// -std::string Double::toString( DECAF_UNUSED double value ) { - return ""; //TODO +std::string Double::toString( double value ) { + + // TODO - This is not going to output to the format we say we do. + ostringstream stream; + stream << value; + + return stream.str(); } //////////////////////////////////////////////////////////////////////////////// Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Float.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Float.cpp?rev=770872&r1=770871&r2=770872&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Float.cpp (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Float.cpp Sat May 2 00:39:33 2009 @@ -152,6 +152,14 @@ float result = 0.0; istringstream stream( value ); stream >> result; + + // Not everything got read, meaning there wasn't just a number here. + if( !stream.eof() ) { + throw exceptions::NumberFormatException( + __FILE__, __LINE__, + "Failed to parse a valid float from input string: %s", value.c_str() ); + } + return result; }