Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 89564 invoked from network); 27 Jul 2007 14:31:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Jul 2007 14:31:27 -0000 Received: (qmail 20852 invoked by uid 500); 27 Jul 2007 14:31:27 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 20798 invoked by uid 500); 27 Jul 2007 14:31:27 -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 20788 invoked by uid 99); 27 Jul 2007 14:31:27 -0000 Received: from Unknown (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jul 2007 07:31:27 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jul 2007 14:31:26 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id F086A1A981A; Fri, 27 Jul 2007 07:31:05 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r560244 - in /activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang: Short.cpp Short.h Date: Fri, 27 Jul 2007 14:31:05 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070727143105.F086A1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Fri Jul 27 07:31:04 2007 New Revision: 560244 URL: http://svn.apache.org/viewvc?view=rev&rev=560244 Log: http://issues.apache.org/activemq/browse/AMQCPP-103 Implementing the Primitive Wrappers fully Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.cpp activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.h Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.cpp?view=diff&rev=560244&r1=560243&r2=560244 ============================================================================== --- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.cpp (original) +++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.cpp Fri Jul 27 07:31:04 2007 @@ -34,3 +34,56 @@ int Short::compareTo( const Short& b ) const { return value == b.value ? 0 : ( value > b.value ? 1 : -1 ); } + +//////////////////////////////////////////////////////////////////////////////// +short Short::parseShort( const std::string& s, int radix ) + throw ( exceptions::NumberFormatException ) { + + // TODO + return s.size() + radix; +} + +//////////////////////////////////////////////////////////////////////////////// +short Short::parseShort( const std::string& s ) + throw ( exceptions::NumberFormatException ) { + return parseShort( s, 10 ); +} + +//////////////////////////////////////////////////////////////////////////////// +Short Short::decode( const std::string& value ) + throw ( exceptions::NumberFormatException ) { + + // TODO + return Short( value.size() ); +} + +//////////////////////////////////////////////////////////////////////////////// +short Short::reverseBytes( short value ) { + + short temp = value; + + // TODO + //temp += ( value & 0xF0 ) >> 8; + //temp += ( value & 0x0F ) << 8; + + return temp; +} + +//////////////////////////////////////////////////////////////////////////////// +Short Short::valueOf( short value ) { + return Short( value ); +} + +//////////////////////////////////////////////////////////////////////////////// +Short Short::valueOf( const std::string& value ) + throw ( exceptions::NumberFormatException ) { + + return Short( parseShort( value, 10 ) ); +} + +//////////////////////////////////////////////////////////////////////////////// +Short Short::valueOf( const std::string& value, int radix ) + throw ( exceptions::NumberFormatException ) { + + return Short( parseShort( value, radix ) ); +} Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.h?view=diff&rev=560244&r1=560243&r2=560244 ============================================================================== --- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.h (original) +++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.h Fri Jul 27 07:31:04 2007 @@ -20,7 +20,7 @@ #include #include -//#include +#include #include namespace decaf{ @@ -36,6 +36,24 @@ public: /** + * Max Value for this Object's primitive type + */ + static const short MAX_VALUE = ((1 << sizeof(short)) - 1); + + /** + * Max Value for this Object's primitive type + */ + static const short MIN_VALUE = (-(1 << sizeof(short))); + + /** + * Size of this objects primitive type + */ + static const int SIZE = sizeof( short ); + + + public: + + /** * @param value - short to wrap */ Short( short value ); @@ -115,6 +133,30 @@ public: // statics /** + * Decodes a String into a Short. Accepts decimal, hexadecimal, and octal + * numbers given by the following grammar: + * + * The sequence of characters following an (optional) negative sign and/or + * radix specifier ("0x", "0X", "#", or leading zero) is parsed as by the + * Short.parseShort method with the indicated radix (10, 16, or 8). This + * sequence of characters must represent a positive value or a + * NumberFormatException will be thrown. The result is negated if first + * character of the specified String is the minus sign. No whitespace + * characters are permitted in the string. + * @param value - The string to decode + * @returns a Short object containing the decoded value + * @throws NumberFomatException if the string is not formatted correctly. + */ + static Short decode( const std::string& value ) + throw ( exceptions::NumberFormatException ); + + /** + * Returns the value obtained by reversing the order of the bytes in the + * two's complement representation of the specified short value. + */ + static short reverseBytes( short value ); + + /** * Parses the string argument as a signed short in the radix specified by * the second argument. The characters in the string must all be digits, * of the specified radix (as determined by whether @@ -137,8 +179,8 @@ * @return the short represented by the string argument in the specified radix. * @throws NumberFormatException - If String does not contain a parsable short. */ -// static short parseShort( const std::string& s, int radix ) -// throw ( exceptions::NumberFormatException ); + static short parseShort( const std::string& s, int radix ) + throw ( exceptions::NumberFormatException ); /** * Parses the string argument as a signed decimal short. The characters @@ -151,8 +193,43 @@ * @returns the converted short value * @throws NumberFormatException if the string is not a short. */ -// static short parseShort( const std::string& s ) -// throw ( exceptions::NumberFormatException ); + static short parseShort( const std::string& s ) + throw ( exceptions::NumberFormatException ); + + /** + * Returns a Short instance representing the specified short value. + * @param value - the short to wrap + * @return the new Short object wrapping value. + */ + static Short valueOf( short value ); + + /** + * Returns a Short object holding the value given by the specified std::string. + * The argument is interpreted as representing a signed decimal short, + * exactly as if the argument were given to the parseShort( std::string ) + * method. The result is a Short object that represents the short value + * specified by the string. + * @param value - std::string to parse as base 10 + * @return new Short Object wrapping the primitive + * @throws NumberFormatException if the string is not a decimal short. + */ + static Short valueOf( const std::string& value ) + throw ( exceptions::NumberFormatException ); + + /** + * Returns a Short object holding the value extracted from the specified + * std::string when parsed with the radix given by the second argument. + * The first argument is interpreted as representing a signed short in the + * radix specified by the second argument, exactly as if the argument were + * given to the parseShort( std::string, int ) method. The result is a + * Short object that represents the short value specified by the string. + * @param value - std::string to parse as base ( radix ) + * @param radix - base of the string to parse. + * @return new Short Object wrapping the primitive + * @throws NumberFormatException if the string is not a valid short. + */ + static Short valueOf( const std::string& value, int radix ) + throw ( exceptions::NumberFormatException ); };