You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2013/11/25 21:11:18 UTC
[1/2] Updates
Updated Branches:
refs/heads/trunk 792d16f4d -> 76ec5822f
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/Long.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/Long.h b/activemq-cpp/src/main/decaf/lang/Long.h
index 46e7a52..b7bdee5 100644
--- a/activemq-cpp/src/main/decaf/lang/Long.h
+++ b/activemq-cpp/src/main/decaf/lang/Long.h
@@ -19,12 +19,13 @@
#define _DECAF_LANG_LONG_H_
#include <decaf/lang/Number.h>
+#include <decaf/lang/String.h>
#include <decaf/lang/Comparable.h>
#include <decaf/lang/exceptions/NumberFormatException.h>
#include <string>
-namespace decaf{
-namespace lang{
+namespace decaf {
+namespace lang {
class DECAF_API Long : public Number,
public Comparable<Long>,
@@ -62,10 +63,9 @@ namespace lang{
*
* @throws NumberFormatException if the string is not a a valid 64bit long.
*/
- Long(const std::string& value);
+ Long(const String& value);
- virtual ~Long() {
- }
+ virtual ~Long();
/**
* Compares this Long instance with another.
@@ -221,7 +221,7 @@ namespace lang{
* @returns a Long object containing the decoded value
* @throws NumberFomatException if the string is not formatted correctly.
*/
- static Long decode(const std::string& value);
+ static Long decode(const String& value);
/**
* Returns an long long value with at most a single one-bit, in the position
@@ -291,7 +291,7 @@ namespace lang{
* @return long long value
* @throws NumberFormatException on invalid string value
*/
- static long long parseLong(const std::string& value);
+ static long long parseLong(const String& value);
/**
* Returns a Long object holding the value extracted from the specified
@@ -305,7 +305,7 @@ namespace lang{
* @return long long value
* @throws NumberFormatException on invalid string value
*/
- static long long parseLong(const std::string& value, int radix);
+ static long long parseLong(const String& value, int radix);
/**
* Returns the value obtained by reversing the order of the bytes in the
@@ -473,31 +473,38 @@ namespace lang{
* Returns a Long object holding the value given by the specified
* std::string. The argument is interpreted as representing a signed
* decimal long long, exactly as if the argument were given to the
- * parseLong( std::string ) method. The result is a Integer object that
+ * parseLong( String ) method. The result is a Integer object that
* represents the long long value specified by the string.
- * @param value - std::string to parse as base 10
+ *
+ * @param value
+ * String to parse as base 10
+ *
* @return new Long Object wrapping the primitive
* @throws NumberFormatException if the string is not a decimal long long.
*/
- static Long valueOf(const std::string& value);
+ static Long valueOf(const String& value);
/**
* Returns a Long 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 long long in the
* radix specified by the second argument, exactly as if the argument were
- * given to the parseLong( std::string, int ) method. The result is a
+ * given to the parseLong(String, int) method. The result is a
* Long object that represents the long long value specified by the string.
- * @param value - std::string to parse as base ( radix )
- * @param radix - base of the string to parse.
+ *
+ * @param value
+ * String to parse as base ( radix )
+ * @param radix
+ * base of the string to parse.
+ *
* @return new Long Object wrapping the primitive
* @throws NumberFormatException if the string is not a valid long long.
*/
- static Long valueOf(const std::string& value, int radix);
+ static Long valueOf(const String& value, int radix);
private:
- static long long parse(const std::string& value, int offset, int radix, bool negative);
+ static long long parse(const String& value, int offset, int radix, bool negative);
};
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/Number.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/Number.h b/activemq-cpp/src/main/decaf/lang/Number.h
index 6daf0da..6d2f582 100644
--- a/activemq-cpp/src/main/decaf/lang/Number.h
+++ b/activemq-cpp/src/main/decaf/lang/Number.h
@@ -35,7 +35,7 @@ namespace lang{
class DECAF_API Number {
public:
- virtual ~Number() {}
+ virtual ~Number();
/**
* Answers the byte value which the receiver represents
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/Short.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/Short.cpp b/activemq-cpp/src/main/decaf/lang/Short.cpp
index f3669d2..c2a129f 100644
--- a/activemq-cpp/src/main/decaf/lang/Short.cpp
+++ b/activemq-cpp/src/main/decaf/lang/Short.cpp
@@ -30,87 +30,88 @@ const short Short::MAX_VALUE = (short)0x7FFF;
const short Short::MIN_VALUE = (short)0x8000;
////////////////////////////////////////////////////////////////////////////////
-Short::Short( short value ) : value(value) {
+Short::Short(short value) : value(value) {
}
////////////////////////////////////////////////////////////////////////////////
-Short::Short( const std::string& value ) : value(0) {
- Short::parseShort( value );
+Short::Short(const String& value) : value(0) {
+ Short::parseShort(value);
}
////////////////////////////////////////////////////////////////////////////////
-int Short::compareTo( const Short& s ) const {
- return value == s.value ? 0 : ( value > s.value ? 1 : -1 );
+Short::~Short() {
}
////////////////////////////////////////////////////////////////////////////////
-int Short::compareTo( const short& s ) const {
- return value == s ? 0 : ( value > s ? 1 : -1 );
+int Short::compareTo(const Short& s) const {
+ return value == s.value ? 0 : (value > s.value ? 1 : -1);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Short::compareTo(const short& s) const {
+ return value == s ? 0 : (value > s ? 1 : -1);
}
////////////////////////////////////////////////////////////////////////////////
std::string Short::toString() const {
- return Integer::toString( this->value );
+ return Integer::toString(this->value);
}
////////////////////////////////////////////////////////////////////////////////
-std::string Short::toString( short value ) {
- return Integer::toString( value );
+std::string Short::toString(short value) {
+ return Integer::toString(value);
}
////////////////////////////////////////////////////////////////////////////////
-short Short::parseShort( const std::string& s, int radix ) {
+short Short::parseShort(const String& s, int radix) {
- int intValue = Integer::parseInt( s, radix );
- short result = (short)intValue;
- if( result != intValue ) {
+ int intValue = Integer::parseInt(s, radix);
+ short result = (short) intValue;
+ if (result != intValue) {
throw NumberFormatException(
- __FILE__, __LINE__,
- "Short::parseShort - Not a valid short encoded string.");
+ __FILE__, __LINE__, "Short::parseShort - Not a valid short encoded string.");
}
return result;
}
////////////////////////////////////////////////////////////////////////////////
-short Short::parseShort( const std::string& s ) {
- return parseShort( s, 10 );
+short Short::parseShort(const String& s) {
+ return parseShort(s, 10);
}
////////////////////////////////////////////////////////////////////////////////
-Short Short::decode( const std::string& value ) {
+Short Short::decode(const String& value) {
- int intValue = Integer::decode( value ).intValue();
- short result = (short)intValue;
- if( result != intValue ) {
+ int intValue = Integer::decode(value).intValue();
+ short result = (short) intValue;
+ if (result != intValue) {
throw NumberFormatException(
__FILE__, __LINE__,
"Short::decode - Not a valid short encoded string.");
}
- return Short( result );
+ return Short(result);
}
////////////////////////////////////////////////////////////////////////////////
-short Short::reverseBytes( short value ) {
+short Short::reverseBytes(short value) {
unsigned short temp = value;
- temp = (unsigned short)( ( ( temp & 0xFF00 ) >> 8 ) | ( ( temp & 0x00FF ) << 8 ) );
+ temp = (unsigned short) (((temp & 0xFF00) >> 8) | ((temp & 0x00FF) << 8));
return temp;
}
////////////////////////////////////////////////////////////////////////////////
-Short Short::valueOf( short value ) {
- return Short( value );
+Short Short::valueOf(short value) {
+ return Short(value);
}
////////////////////////////////////////////////////////////////////////////////
-Short Short::valueOf( const std::string& value ) {
-
- return Short( parseShort( value, 10 ) );
+Short Short::valueOf(const String& value) {
+ return Short(parseShort(value, 10));
}
////////////////////////////////////////////////////////////////////////////////
-Short Short::valueOf( const std::string& value, int radix ) {
-
- return Short( parseShort( value, radix ) );
+Short Short::valueOf(const String& value, int radix) {
+ return Short(parseShort(value, radix));
}
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/Short.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/Short.h b/activemq-cpp/src/main/decaf/lang/Short.h
index 9cec026..d1d050b 100644
--- a/activemq-cpp/src/main/decaf/lang/Short.h
+++ b/activemq-cpp/src/main/decaf/lang/Short.h
@@ -19,13 +19,14 @@
#define _DECAF_LANG_SHORT_H_
#include <decaf/util/Config.h>
+#include <decaf/lang/String.h>
#include <decaf/lang/Number.h>
#include <decaf/lang/Comparable.h>
#include <decaf/lang/exceptions/NumberFormatException.h>
#include <string>
-namespace decaf{
-namespace lang{
+namespace decaf {
+namespace lang {
class DECAF_API Short : public Number,
public Comparable<Short>,
@@ -51,7 +52,7 @@ namespace lang{
/**
* @param value - short to wrap
*/
- Short( short value );
+ Short(short value);
/**
* @param value
@@ -59,9 +60,9 @@ namespace lang{
*
* @throws NumberFormatException if the string is not well formed number value.
*/
- Short( const std::string& value );
+ Short(const String& value);
- virtual ~Short() {}
+ virtual ~Short();
/**
* Compares this Short instance with another.
@@ -71,12 +72,12 @@ namespace lang{
* than the passed in value, and -1 if this object represents a value
* less than the passed in value.
*/
- virtual int compareTo( const Short& s ) const;
+ virtual int compareTo(const Short& s) const;
/**
* @returns true if the two Short Objects have the same value.
*/
- bool equals( const Short& s ) const {
+ bool equals(const Short& s) const {
return this->value == s.value;
}
@@ -85,7 +86,7 @@ namespace lang{
* @param s - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator==( const Short& s ) const {
+ virtual bool operator==(const Short& s) const {
return this->value == s.value;
}
@@ -95,7 +96,7 @@ namespace lang{
* @param s - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator<( const Short& s ) const {
+ virtual bool operator<(const Short& s) const {
return this->value < s.value;
}
@@ -107,12 +108,12 @@ namespace lang{
* than the passed in value, and -1 if this object represents a value
* less than the passed in value.
*/
- virtual int compareTo( const short& s ) const;
+ virtual int compareTo(const short& s) const;
/**
* @returns true if the two Short Objects have the same value.
*/
- bool equals( const short& s ) const {
+ bool equals(const short& s) const {
return this->value == s;
}
@@ -121,7 +122,7 @@ namespace lang{
* @param s - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator==( const short& s ) const {
+ virtual bool operator==(const short& s) const {
return this->value == s;
}
@@ -131,7 +132,7 @@ namespace lang{
* @param s - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator<( const short& s ) const {
+ virtual bool operator<(const short& s) const {
return this->value < s;
}
@@ -145,7 +146,7 @@ namespace lang{
* @return double the value of the receiver.
*/
virtual double doubleValue() const {
- return (double)this->value;
+ return (double) this->value;
}
/**
@@ -153,7 +154,7 @@ namespace lang{
* @return float the value of the receiver.
*/
virtual float floatValue() const {
- return (float)this->value;
+ return (float) this->value;
}
/**
@@ -161,7 +162,7 @@ namespace lang{
* @return int the value of the receiver.
*/
virtual unsigned char byteValue() const {
- return (unsigned char)this->value;
+ return (unsigned char) this->value;
}
/**
@@ -177,7 +178,7 @@ namespace lang{
* @return int the value of the receiver.
*/
virtual int intValue() const {
- return (int)this->value;
+ return (int) this->value;
}
/**
@@ -185,15 +186,15 @@ namespace lang{
* @return long the value of the receiver.
*/
virtual long long longValue() const {
- return (long long)this->value;
+ return (long long) this->value;
}
- public: // statics
+ public:
/**
* @returns a string representing the primitive value as Base 10
*/
- static std::string toString( short value );
+ static std::string toString(short value);
/**
* Decodes a String into a Short. Accepts decimal, hexadecimal, and octal
@@ -210,7 +211,7 @@ namespace lang{
* @returns a Short object containing the decoded value
* @throws NumberFomatException if the string is not formatted correctly.
*/
- static Short decode( const std::string& value );
+ static Short decode(const String& value);
/**
* Returns the value obtained by reversing the order of the bytes in the
@@ -218,7 +219,7 @@ namespace lang{
* @param value - the short whose bytes we are to reverse
* @return the reversed short.
*/
- static short reverseBytes( short value );
+ static short reverseBytes(short value);
/**
* Parses the string argument as a signed short in the radix specified by
@@ -238,12 +239,16 @@ namespace lang{
* provided that the string is longer than length 1.
* * The value represented by the string is not a value of type short.
*
- * @param s - the String containing the short representation to be parsed
- * @param radix - the radix to be used while parsing s
+ * @param s
+ * The String containing the short representation to be parsed
+ * @param radix
+ * The radix to be used while parsing the string.
+ *
* @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 );
+ static short parseShort(const String& s, int radix);
/**
* Parses the string argument as a signed decimal short. The characters
@@ -253,18 +258,21 @@ namespace lang{
* radix 10 were given as arguments to the parseShort( const std::string, int )
* method.
*
- * @param s - String to convert to a short
+ * @param s
+ * String to convert to a short
+ *
* @returns the converted short value
+ *
* @throws NumberFormatException if the string is not a short.
*/
- static short parseShort( const std::string& s );
+ static short parseShort(const String& s);
/**
* 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 );
+ static Short valueOf(short value);
/**
* Returns a Short object holding the value given by the specified std::string.
@@ -272,11 +280,15 @@ namespace lang{
* 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
+ *
+ * @param value
+ * 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 );
+ static Short valueOf(const String& value);
/**
* Returns a Short object holding the value extracted from the specified
@@ -285,12 +297,17 @@ namespace lang{
* 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.
+ *
+ * @param value
+ * 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 );
+ static Short valueOf(const String& value, int radix);
};
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/StringBuffer.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/StringBuffer.h b/activemq-cpp/src/main/decaf/lang/StringBuffer.h
index 30789b3..639c484 100644
--- a/activemq-cpp/src/main/decaf/lang/StringBuffer.h
+++ b/activemq-cpp/src/main/decaf/lang/StringBuffer.h
@@ -54,7 +54,8 @@ namespace lang {
*
* @since 1.0
*/
- class DECAF_API StringBuffer : public AbstractStringBuilder {
+ class DECAF_API StringBuffer : public AbstractStringBuilder,
+ public Appendable {
public:
/**
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/StringBuilder.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/StringBuilder.cpp b/activemq-cpp/src/main/decaf/lang/StringBuilder.cpp
index 49e6451..9ca6fdc 100644
--- a/activemq-cpp/src/main/decaf/lang/StringBuilder.cpp
+++ b/activemq-cpp/src/main/decaf/lang/StringBuilder.cpp
@@ -235,6 +235,11 @@ StringBuilder& StringBuilder::insert(int index, const CharSequence* value, int o
}
////////////////////////////////////////////////////////////////////////////////
+int StringBuilder::length() const {
+ return AbstractStringBuilder::length();
+}
+
+////////////////////////////////////////////////////////////////////////////////
StringBuilder& StringBuilder::replace(int start, int end, const String& value) {
doReplace(start, end, value);
return *this;
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/StringBuilder.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/StringBuilder.h b/activemq-cpp/src/main/decaf/lang/StringBuilder.h
index d98b026..d5d9089 100644
--- a/activemq-cpp/src/main/decaf/lang/StringBuilder.h
+++ b/activemq-cpp/src/main/decaf/lang/StringBuilder.h
@@ -48,7 +48,8 @@ namespace lang {
*
* @since 1.0
*/
- class DECAF_API StringBuilder : public AbstractStringBuilder {
+ class DECAF_API StringBuilder : public AbstractStringBuilder,
+ public Appendable {
public:
/**
@@ -92,6 +93,8 @@ namespace lang {
public:
+ virtual int length() const;
+
/**
* Appends the string representation of the given object pointer. If the pointer
* is NULL then the value "null" is appended to this StringBuilder.
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/util/Arrays.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/util/Arrays.h b/activemq-cpp/src/main/decaf/util/Arrays.h
index 2be2b7e..5a7a941 100644
--- a/activemq-cpp/src/main/decaf/util/Arrays.h
+++ b/activemq-cpp/src/main/decaf/util/Arrays.h
@@ -53,20 +53,20 @@ namespace util {
* @throws IllegalArgumentException if the size parameter is negative, or the start
* index is greater than the end index.
*/
- template< typename E>
- static void fill( E* array, int size, const E& value ) {
+ template<typename E>
+ static void fill(E* array, int size, const E& value) {
- if( array == NULL ) {
+ if (array == NULL) {
throw decaf::lang::exceptions::NullPointerException(
- __FILE__, __LINE__, "Array pointer given was NULL." );
+ __FILE__, __LINE__, "Array pointer given was NULL.");
}
- if( size < 0 ) {
+ if (size < 0) {
throw decaf::lang::exceptions::IllegalArgumentException(
- __FILE__, __LINE__, "Array size value given was negative." );
+ __FILE__, __LINE__, "Array size value given was negative.");
}
- for( int i = 0; i < size; ++i ) {
+ for (int i = 0; i < size; ++i) {
array[i] = value;
}
}
@@ -92,29 +92,29 @@ namespace util {
* is greater than the size parameter.
*/
template< typename E>
- static void fill( E* array, int size, int start, int end, const E& value ) {
+ static void fill(E* array, int size, int start, int end, const E& value) {
- if( array == NULL ) {
+ if (array == NULL) {
throw decaf::lang::exceptions::NullPointerException(
__FILE__, __LINE__, "Array pointer given was NULL." );
}
- if( size < 0 ) {
+ if (size < 0) {
throw decaf::lang::exceptions::IllegalArgumentException(
__FILE__, __LINE__, "Array size value given was negative." );
}
- if( start > end ) {
+ if (start > end) {
throw decaf::lang::exceptions::IllegalArgumentException(
__FILE__, __LINE__, "The start index was greater than the end index." );
}
- if( start < 0 || end > size ) {
+ if (start < 0 || end > size) {
throw decaf::lang::exceptions::IndexOutOfBoundsException(
__FILE__, __LINE__, "The start index {%d} end index {%d} range is invalid.", start, end );
}
- for( int i = start; i < end; ++i ) {
+ for (int i = start; i < end; ++i) {
array[i] = value;
}
}
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/test/testRegistry.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/test/testRegistry.cpp b/activemq-cpp/src/test/testRegistry.cpp
index e786fe0..312dad8 100644
--- a/activemq-cpp/src/test/testRegistry.cpp
+++ b/activemq-cpp/src/test/testRegistry.cpp
@@ -234,37 +234,37 @@
//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::OutputStreamWriterTest );
//#include <decaf/io/InputStreamReaderTest.h>
//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::InputStreamReaderTest );
-//
-//#include <decaf/lang/MathTest.h>
-//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::MathTest );
-//#include <decaf/lang/ByteTest.h>
-//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::ByteTest );
-//#include <decaf/lang/CharacterTest.h>
-//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::CharacterTest );
-//#include <decaf/lang/BooleanTest.h>
-//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::BooleanTest );
-//#include <decaf/lang/ShortTest.h>
-//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::ShortTest );
-//#include <decaf/lang/IntegerTest.h>
-//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::IntegerTest );
-//#include <decaf/lang/LongTest.h>
-//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::LongTest );
-//#include <decaf/lang/FloatTest.h>
-//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::FloatTest );
-//#include <decaf/lang/DoubleTest.h>
-//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::DoubleTest );
-//#include <decaf/lang/ExceptionTest.h>
-//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::ExceptionTest );
+
+#include <decaf/lang/MathTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::MathTest );
+#include <decaf/lang/ByteTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::ByteTest );
+#include <decaf/lang/CharacterTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::CharacterTest );
+#include <decaf/lang/BooleanTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::BooleanTest );
+#include <decaf/lang/ShortTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::ShortTest );
+#include <decaf/lang/IntegerTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::IntegerTest );
+#include <decaf/lang/LongTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::LongTest );
+#include <decaf/lang/FloatTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::FloatTest );
+#include <decaf/lang/DoubleTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::DoubleTest );
+#include <decaf/lang/ExceptionTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::ExceptionTest );
//#include <decaf/lang/ThreadTest.h>
//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::ThreadTest );
//#include <decaf/lang/ThreadLocalTest.h>
//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::ThreadLocalTest );
-//#include <decaf/lang/SystemTest.h>
-//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::SystemTest );
-//#include <decaf/lang/PointerTest.h>
-//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::PointerTest );
-//#include <decaf/lang/ArrayPointerTest.h>
-//CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::ArrayPointerTest );
+#include <decaf/lang/SystemTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::SystemTest );
+#include <decaf/lang/PointerTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::PointerTest );
+#include <decaf/lang/ArrayPointerTest.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::ArrayPointerTest );
#include <decaf/lang/StringTest.h>
CPPUNIT_TEST_SUITE_REGISTRATION( decaf::lang::StringTest );
#include <decaf/lang/StringBuilderTest.h>
[2/2] git commit: Updates
Posted by ta...@apache.org.
Updates
Project: http://git-wip-us.apache.org/repos/asf/activemq-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-cpp/commit/76ec5822
Tree: http://git-wip-us.apache.org/repos/asf/activemq-cpp/tree/76ec5822
Diff: http://git-wip-us.apache.org/repos/asf/activemq-cpp/diff/76ec5822
Branch: refs/heads/trunk
Commit: 76ec5822fdf4c4ce991e0c0468a0d19258021840
Parents: 792d16f
Author: Timothy Bish <ta...@gmai.com>
Authored: Mon Nov 25 15:11:08 2013 -0500
Committer: Timothy Bish <ta...@gmai.com>
Committed: Mon Nov 25 15:11:08 2013 -0500
----------------------------------------------------------------------
activemq-cpp/src/main/Makefile.am | 1 +
activemq-cpp/src/main/decaf/lang/Appendable.h | 11 +-
activemq-cpp/src/main/decaf/lang/Boolean.cpp | 6 +-
activemq-cpp/src/main/decaf/lang/Boolean.h | 8 +-
activemq-cpp/src/main/decaf/lang/Byte.cpp | 45 ++--
activemq-cpp/src/main/decaf/lang/Byte.h | 58 +++--
activemq-cpp/src/main/decaf/lang/Double.cpp | 143 +++++------
activemq-cpp/src/main/decaf/lang/Double.h | 87 ++++---
activemq-cpp/src/main/decaf/lang/Float.cpp | 153 ++++++------
activemq-cpp/src/main/decaf/lang/Float.h | 87 ++++---
activemq-cpp/src/main/decaf/lang/Integer.cpp | 242 +++++++++----------
activemq-cpp/src/main/decaf/lang/Integer.h | 26 +-
activemq-cpp/src/main/decaf/lang/Long.cpp | 41 ++--
activemq-cpp/src/main/decaf/lang/Long.h | 39 +--
activemq-cpp/src/main/decaf/lang/Number.h | 2 +-
activemq-cpp/src/main/decaf/lang/Short.cpp | 67 ++---
activemq-cpp/src/main/decaf/lang/Short.h | 83 ++++---
activemq-cpp/src/main/decaf/lang/StringBuffer.h | 3 +-
.../src/main/decaf/lang/StringBuilder.cpp | 5 +
.../src/main/decaf/lang/StringBuilder.h | 5 +-
activemq-cpp/src/main/decaf/util/Arrays.h | 26 +-
activemq-cpp/src/test/testRegistry.cpp | 54 ++---
22 files changed, 644 insertions(+), 548 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/Makefile.am
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/Makefile.am b/activemq-cpp/src/main/Makefile.am
index 5939df9..98ec152 100644
--- a/activemq-cpp/src/main/Makefile.am
+++ b/activemq-cpp/src/main/Makefile.am
@@ -458,6 +458,7 @@ cc_sources = \
decaf/lang/Iterable.cpp \
decaf/lang/Long.cpp \
decaf/lang/Math.cpp \
+ decaf/lang/Number.cpp \
decaf/lang/Readable.cpp \
decaf/lang/Runnable.cpp \
decaf/lang/Runtime.cpp \
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/Appendable.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/Appendable.h b/activemq-cpp/src/main/decaf/lang/Appendable.h
index 57b9579..6109b50 100644
--- a/activemq-cpp/src/main/decaf/lang/Appendable.h
+++ b/activemq-cpp/src/main/decaf/lang/Appendable.h
@@ -31,11 +31,6 @@ namespace lang {
* must be implemented by any class whose instances are intended to receive formatted
* output from a Formatter.
*
- * TODO
- * The characters to be appended should be valid Unicode characters as described in Unicode
- * Character Representation. Note that supplementary characters may be composed of multiple
- * 16-bit char values.
- *
* Appendables are not necessarily safe for multithreaded access. Thread safety is the
* responsibility of classes that extend and implement this interface.
*
@@ -59,7 +54,7 @@ namespace lang {
*
* @throws Exception if an error occurs.
*/
- virtual Appendable& append( char value ) = 0;
+ virtual Appendable& append(char value) = 0;
/**
* Appends the specified character sequence to this Appendable.
@@ -73,7 +68,7 @@ namespace lang {
*
* @throws Exception if an error occurs.
*/
- virtual Appendable& append( const CharSequence* csq ) = 0;
+ virtual Appendable& append(const CharSequence* csq) = 0;
/**
* Appends a subsequence of the specified character sequence to this Appendable.
@@ -92,7 +87,7 @@ namespace lang {
* @throws IndexOutOfBoundsException start is greater than end, or end is
* greater than csq.length()
*/
- virtual Appendable& append( const CharSequence* csq, int start, int end ) = 0;
+ virtual Appendable& append(const CharSequence* csq, int start, int end) = 0;
};
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/Boolean.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/Boolean.cpp b/activemq-cpp/src/main/decaf/lang/Boolean.cpp
index 8bd3ba9..53a21a8 100644
--- a/activemq-cpp/src/main/decaf/lang/Boolean.cpp
+++ b/activemq-cpp/src/main/decaf/lang/Boolean.cpp
@@ -34,7 +34,7 @@ Boolean::Boolean(bool value) : value(value) {
}
////////////////////////////////////////////////////////////////////////////////
-Boolean::Boolean(const std::string& value) : value(false) {
+Boolean::Boolean(const String& value) : value(false) {
this->value = parseBoolean(value);
}
@@ -86,7 +86,7 @@ std::string Boolean::toString() const {
}
////////////////////////////////////////////////////////////////////////////////
-Boolean Boolean::valueOf(const std::string& value) {
+Boolean Boolean::valueOf(const String& value) {
return Boolean(value);
}
@@ -96,7 +96,7 @@ Boolean Boolean::valueOf(bool value) {
}
////////////////////////////////////////////////////////////////////////////////
-bool Boolean::parseBoolean(const std::string& value) {
+bool Boolean::parseBoolean(const String& value) {
return StringUtils::compareIgnoreCase(value.c_str(), "true") == 0;
}
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/Boolean.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/Boolean.h b/activemq-cpp/src/main/decaf/lang/Boolean.h
index 7f5d8e2..ec37b61 100644
--- a/activemq-cpp/src/main/decaf/lang/Boolean.h
+++ b/activemq-cpp/src/main/decaf/lang/Boolean.h
@@ -19,6 +19,7 @@
#define _DECAF_LANG_BOOLEAN_H_
#include <string>
+#include <decaf/lang/String.h>
#include <decaf/lang/Comparable.h>
#include <decaf/util/Config.h>
@@ -54,7 +55,7 @@ namespace lang{
/**
* @param value - String value to convert to a boolean.
*/
- Boolean(const std::string& value);
+ Boolean(const String& value);
virtual ~Boolean() {}
@@ -135,7 +136,6 @@ namespace lang{
}
public:
- // Statics
/**
* @param value
@@ -151,7 +151,7 @@ namespace lang{
*
* @returns a Boolean instance of the string value
*/
- static Boolean valueOf(const std::string& value);
+ static Boolean valueOf(const String& value);
/**
* Parses the String passed and extracts an bool.
@@ -160,7 +160,7 @@ namespace lang{
* The std::string value to parse
* @return bool value
*/
- static bool parseBoolean(const std::string& value);
+ static bool parseBoolean(const String& value);
/**
* Converts the bool to a String representation.
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/Byte.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/Byte.cpp b/activemq-cpp/src/main/decaf/lang/Byte.cpp
index 34af228..843b602 100644
--- a/activemq-cpp/src/main/decaf/lang/Byte.cpp
+++ b/activemq-cpp/src/main/decaf/lang/Byte.cpp
@@ -29,63 +29,62 @@ const unsigned char Byte::MAX_VALUE = 0x80;
const int Byte::SIZE = 8;
////////////////////////////////////////////////////////////////////////////////
-Byte::Byte( unsigned char value ) : value(value) {
+Byte::Byte(unsigned char value) : value(value) {
}
////////////////////////////////////////////////////////////////////////////////
-Byte::Byte( const std::string& value ) : value(0) {
- this->value = parseByte( value );
+Byte::Byte(const String& value) : value(0) {
+ this->value = parseByte(value);
}
////////////////////////////////////////////////////////////////////////////////
std::string Byte::toString() const {
- return Integer::toString( value );
+ return Integer::toString(value);
}
////////////////////////////////////////////////////////////////////////////////
-std::string Byte::toString( unsigned char value ) {
- return Integer::toString( value );
+std::string Byte::toString(unsigned char value) {
+ return Integer::toString(value);
}
////////////////////////////////////////////////////////////////////////////////
-unsigned char Byte::parseByte( const std::string& s, int radix ) {
+unsigned char Byte::parseByte(const String& s, int radix) {
- int intValue = Integer::parseInt( s, radix );
- unsigned char result = (unsigned char)intValue;
- if( result != intValue ) {
+ int intValue = Integer::parseInt(s, radix);
+ unsigned char result = (unsigned char) intValue;
+ if (result != intValue) {
throw NumberFormatException(
- __FILE__, __LINE__,
- "Byte::parseByte - Not a valid unsigned char encoded string.");
+ __FILE__, __LINE__, "Byte::parseByte - Not a valid unsigned char encoded string.");
}
return result;
}
////////////////////////////////////////////////////////////////////////////////
-unsigned char Byte::parseByte( const std::string& s ) {
- return parseByte( s, 10 );
+unsigned char Byte::parseByte(const String& s) {
+ return parseByte(s, 10);
}
////////////////////////////////////////////////////////////////////////////////
-Byte Byte::decode( const std::string& value ) {
+Byte Byte::decode(const String& value) {
- int intValue = Integer::decode( value ).intValue();
- unsigned char result = (unsigned char)intValue;
- if( result != intValue ) {
+ int intValue = Integer::decode(value).intValue();
+ unsigned char result = (unsigned char) intValue;
+ if (result != intValue) {
throw NumberFormatException(
__FILE__, __LINE__,
"Byte::decode - Not a valid unsigned char encoded string.");
}
- return Byte( result );
+ return Byte(result);
}
////////////////////////////////////////////////////////////////////////////////
-Byte Byte::valueOf( const std::string& value ) {
- return Byte( parseByte( value, 10 ) );
+Byte Byte::valueOf(const String& value) {
+ return Byte(parseByte(value, 10));
}
////////////////////////////////////////////////////////////////////////////////
-Byte Byte::valueOf( const std::string& value, int radix ) {
- return Byte( parseByte( value, radix ) );
+Byte Byte::valueOf(const String& value, int radix) {
+ return Byte(parseByte(value, radix));
}
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/Byte.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/Byte.h b/activemq-cpp/src/main/decaf/lang/Byte.h
index 52bb809..6ae606b 100644
--- a/activemq-cpp/src/main/decaf/lang/Byte.h
+++ b/activemq-cpp/src/main/decaf/lang/Byte.h
@@ -20,12 +20,13 @@
#include <decaf/util/Config.h>
#include <decaf/lang/Number.h>
+#include <decaf/lang/String.h>
#include <decaf/lang/Comparable.h>
#include <decaf/lang/exceptions/NumberFormatException.h>
#include <string>
-namespace decaf{
-namespace lang{
+namespace decaf {
+namespace lang {
class DECAF_API Byte : public Number,
public Comparable<Byte>,
@@ -60,7 +61,7 @@ namespace lang{
*
* @throws NumberFormatException if the string is not a valid byte.
*/
- Byte(const std::string& value);
+ Byte(const String& value);
virtual ~Byte() {}
@@ -193,7 +194,7 @@ namespace lang{
return (long long) this->value;
}
- public: // statics
+ public:
/**
* @returns a string representing the primitive value as Base 10
@@ -211,11 +212,15 @@ namespace lang{
* 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
+ *
+ * @param value
+ * The string to decode
+ *
* @returns a Byte object containing the decoded value
+ *
* @throws NumberFomatException if the string is not formatted correctly.
*/
- static Byte decode(const std::string& value);
+ static Byte decode(const String& value);
/**
* Parses the string argument as a signed unsigned char in the radix specified by
@@ -235,14 +240,17 @@ namespace lang{
* that the string is longer than length 1.
* * The value represented by the string is not a value of type unsigned char.
*
- * @param s - the String containing the unsigned char to be parsed
- * @param radix - the radix to be used while parsing s
+ * @param s
+ * The String containing the unsigned char to be parsed
+ * @param radix
+ * The radix to be used while parsing s
+ *
* @return the unsigned char represented by the string argument in the
* specified radix.
* @throws NumberFormatException - If String does not contain a parsable
* unsigned char.
*/
- static unsigned char parseByte(const std::string& s, int radix);
+ static unsigned char parseByte(const String& s, int radix);
/**
* Parses the string argument as a signed decimal unsigned char. The
@@ -250,16 +258,23 @@ namespace lang{
* first character may be an ASCII minus sign '-' to indicate a
* negative value. The resulting unsigned char value is returned, exactly as
* if the argument and the radix 10 were given as arguments to the
- * parseByte( const std::string, int ) method.
- * @param s - String to convert to a unsigned char
+ * parseByte(const String, int) method.
+ *
+ * @param s
+ * String to convert to a unsigned char
+ *
* @returns the converted unsigned char value
+ *
* @throws NumberFormatException if the string is not a unsigned char.
*/
- static unsigned char parseByte(const std::string& s);
+ static unsigned char parseByte(const String& s);
/**
* Returns a Character instance representing the specified char value.
- * @param value - the primitive char to wrap.
+ *
+ * @param value
+ * The primitive char to wrap.
+ *
* @returns a new Character instance that wraps this value.
*/
static Byte valueOf(unsigned char value) {
@@ -272,11 +287,14 @@ namespace lang{
* exactly as if the argument were given to the parseByte( std::string )
* method. The result is a Byte object that represents the unsigned char value
* specified by the string.
- * @param value - std::string to parse as base 10
+ *
+ * @param value
+ * String to parse as base 10
+ *
* @return new Byte Object wrapping the primitive
* @throws NumberFormatException if the string is not a decimal unsigned char.
*/
- static Byte valueOf(const std::string& value);
+ static Byte valueOf(const String& value);
/**
* Returns a Byte object holding the value extracted from the specified
@@ -286,12 +304,16 @@ namespace lang{
* were given to the parseByte( std::string, int ) method. The result is a
* Byte object that represents the unsigned char value specified by the
* string.
- * @param value - std::string to parse as base ( radix )
- * @param radix - base of the string to parse.
+ * @param value
+ * String to parse as base ( radix )
+ * @param radix
+ * Base of the string to parse.
+ *
* @return new Byte Object wrapping the primitive
+ *
* @throws NumberFormatException if the string is not a valid unsigned char.
*/
- static Byte valueOf(const std::string& value, int radix);
+ static Byte valueOf(const String& value, int radix);
};
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/Double.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/Double.cpp b/activemq-cpp/src/main/decaf/lang/Double.cpp
index 186a276..7b923e9 100644
--- a/activemq-cpp/src/main/decaf/lang/Double.cpp
+++ b/activemq-cpp/src/main/decaf/lang/Double.cpp
@@ -17,6 +17,7 @@
#include "Double.h"
#include <decaf/lang/Long.h>
+#include <decaf/lang/ArrayPointer.h>
#include <limits>
#include <sstream>
#include <string.h>
@@ -34,59 +35,64 @@ const double Double::NaN = std::numeric_limits<double>::quiet_NaN();
const double Double::POSITIVE_INFINITY = std::numeric_limits<double>::infinity();
const double Double::NEGATIVE_INFINITY = -std::numeric_limits<double>::infinity();
+const long long Double::DOUBLE_SIGN_MASK = 0x8000000000000000LL;
+const long long Double::DOUBLE_EXPONENT_MASK = 0x7FF0000000000000LL;
+const long long Double::DOUBLE_MANTISSA_MASK = 0x000FFFFFFFFFFFFFLL;
+const long long Double::DOUBLE_NAN_BITS = DOUBLE_EXPONENT_MASK | 0x0008000000000000LL;
+
////////////////////////////////////////////////////////////////////////////////
-Double::Double( double value ) :value(value) {
+Double::Double(double value) : value(value) {
}
////////////////////////////////////////////////////////////////////////////////
-Double::Double( const std::string& value ) : value(0) {
- this->value = Double::parseDouble( value );
+Double::Double(const String& value) : value(0) {
+ this->value = Double::parseDouble(value);
}
////////////////////////////////////////////////////////////////////////////////
-int Double::compareTo( const Double& d ) const {
- return Double::compare( this->value, d.value );
+int Double::compareTo(const Double& d) const {
+ return Double::compare(this->value, d.value);
}
////////////////////////////////////////////////////////////////////////////////
-int Double::compareTo( const double& d ) const {
- return Double::compare( this->value, d );
+int Double::compareTo(const double& d) const {
+ return Double::compare(this->value, d);
}
////////////////////////////////////////////////////////////////////////////////
std::string Double::toString() const {
- return Double::toString( this->value );
+ return Double::toString(this->value);
}
////////////////////////////////////////////////////////////////////////////////
bool Double::isInfinite() const {
- return Double::isInfinite( this->value );
+ return Double::isInfinite(this->value);
}
////////////////////////////////////////////////////////////////////////////////
bool Double::isNaN() const {
- return Double::isNaN( this->value );
+ return Double::isNaN(this->value);
}
////////////////////////////////////////////////////////////////////////////////
-int Double::compare( double d1, double d2 ) {
+int Double::compare(double d1, double d2) {
long long l1, l2 = 0;
- long long NaNbits = Double::doubleToLongBits( Double::NaN );
+ long long NaNbits = Double::doubleToLongBits(Double::NaN);
- if( ( l1 = Double::doubleToLongBits( d1 ) ) == NaNbits ) {
- if( Double::doubleToLongBits( d2 ) == NaNbits ) {
+ if ((l1 = Double::doubleToLongBits(d1)) == NaNbits) {
+ if (Double::doubleToLongBits(d2) == NaNbits) {
return 0;
}
return 1;
}
- if( ( l2 = Double::doubleToLongBits( d2 ) ) == NaNbits ) {
+ if ((l2 = Double::doubleToLongBits(d2)) == NaNbits) {
return -1;
}
- if( d1 == d2 ) {
- if( l1 == l2 ) {
+ if (d1 == d2) {
+ if (l1 == l2) {
return 0;
}
@@ -98,13 +104,13 @@ int Double::compare( double d1, double d2 ) {
}
////////////////////////////////////////////////////////////////////////////////
-long long Double::doubleToLongBits( double value ) {
+long long Double::doubleToLongBits(double value) {
long long longValue = 0;
- memcpy( &longValue, &value, sizeof( double ) );
+ memcpy(&longValue, &value, sizeof(double));
- if( ( longValue & DOUBLE_EXPONENT_MASK ) == DOUBLE_EXPONENT_MASK ) {
- if( longValue & DOUBLE_MANTISSA_MASK ) {
+ if ((longValue & DOUBLE_EXPONENT_MASK) == DOUBLE_EXPONENT_MASK) {
+ if (longValue & DOUBLE_MANTISSA_MASK) {
return DOUBLE_NAN_BITS;
}
}
@@ -113,135 +119,137 @@ long long Double::doubleToLongBits( double value ) {
}
////////////////////////////////////////////////////////////////////////////////
-long long Double::doubleToRawLongBits( double value ) {
+long long Double::doubleToRawLongBits(double value) {
long long longValue = 0;
- memcpy( &longValue, &value, sizeof( double ) );
+ memcpy(&longValue, &value, sizeof(double));
return longValue;
}
////////////////////////////////////////////////////////////////////////////////
-bool Double::isInfinite( double value ) {
- return ( value == POSITIVE_INFINITY ) || ( value == NEGATIVE_INFINITY );
+bool Double::isInfinite(double value) {
+ return (value == POSITIVE_INFINITY) || (value == NEGATIVE_INFINITY);
}
////////////////////////////////////////////////////////////////////////////////
-bool Double::isNaN( double value ) {
+bool Double::isNaN(double value) {
return value != value;
}
////////////////////////////////////////////////////////////////////////////////
-double Double::longBitsToDouble( long long bits ) {
+double Double::longBitsToDouble(long long bits) {
double result = 0;
- memcpy( &result, &bits, sizeof( long long ) );
+ memcpy(&result, &bits, sizeof(long long));
return result;
}
////////////////////////////////////////////////////////////////////////////////
-double Double::parseDouble( const std::string value ) {
+double Double::parseDouble(const String& value) {
// TODO - This is not going to parse the formats we say we do.
float result = 0.0;
- istringstream stream( value );
+ ArrayPointer<char> buffer(value.length() + 1);
+ value.getChars(0, value.length(), buffer.get(), value.length() + 1, 0);
+
+ istringstream stream(buffer.get());
stream >> result;
// Not everything got read, meaning there wasn't just a number here.
- if( !stream.eof() ) {
+ if (!stream.eof()) {
throw exceptions::NumberFormatException(
- __FILE__, __LINE__,
- "Failed to parse a valid float from input string: %s", value.c_str() );
+ __FILE__, __LINE__, "Failed to parse a valid float from input string: %s", value.c_str());
}
return result;
}
////////////////////////////////////////////////////////////////////////////////
-std::string Double::toHexString( double value ) {
+std::string Double::toHexString(double value) {
/*
* Reference: http://en.wikipedia.org/wiki/IEEE_754
*/
- if( value != value ) {
+ if (value != value) {
return "NaN";
}
- if( value == POSITIVE_INFINITY ) {
+ if (value == POSITIVE_INFINITY) {
return "Infinity";
}
- if( value == NEGATIVE_INFINITY ) {
+ if (value == NEGATIVE_INFINITY) {
return "-Infinity";
}
- unsigned long long bitValue = Double::doubleToLongBits( value );
+ unsigned long long bitValue = Double::doubleToLongBits(value);
- bool negative = ( bitValue & 0x8000000000000000LL ) != 0;
+ bool negative = (bitValue & 0x8000000000000000LL) != 0;
// mask exponent bits and shift down
- unsigned long long exponent = ( bitValue & 0x7FF0000000000000LL ) >> 52;
+ unsigned long long exponent = (bitValue & 0x7FF0000000000000LL) >> 52;
// mask significand bits and shift up
unsigned long long significand = bitValue & 0x000FFFFFFFFFFFFFLL;
- if( exponent == 0 && significand == 0 ) {
- return ( negative ? "-0x0.0p0" : "0x0.0p0" );
+ if (exponent == 0 && significand == 0) {
+ return (negative ? "-0x0.0p0" : "0x0.0p0");
}
// Start with sign and hex indicator
- std::string hexString( negative ? "-0x" : "0x" );
+ std::string hexString(negative ? "-0x" : "0x");
- if( exponent == 0 ) {
+ if (exponent == 0) {
// denormal (subnormal) value
hexString.append("0.");
// significand is 52-bits, so there can be 13 hex digits
unsigned int fractionDigits = 13;
// remove trailing hex zeros, so Integer.toHexString() won't print
// them
- while( ( significand != 0 ) && ( ( significand & 0xF ) == 0 ) ) {
+ while ((significand != 0) && ((significand & 0xF) == 0)) {
significand >>= 4;
fractionDigits--;
}
// this assumes Integer.toHexString() returns lowercase characters
- std::string hexSignificand = Long::toHexString( significand );
+ std::string hexSignificand = Long::toHexString(significand);
// if there are digits left, then insert some '0' chars first
- if( significand != 0 && fractionDigits > hexSignificand.length() ) {
- int digitDiff = fractionDigits - (int)hexSignificand.length();
- while( digitDiff-- != 0 ) {
- hexString.append( "0" );
+ if (significand != 0 && fractionDigits > hexSignificand.length()) {
+ int digitDiff = fractionDigits - (int) hexSignificand.length();
+ while (digitDiff-- != 0) {
+ hexString.append("0");
}
}
- hexString.append( hexSignificand );
- hexString.append( "p-1022" );
+ hexString.append(hexSignificand);
+ hexString.append("p-1022");
} else {
// normal value
- hexString.append( "1." );
+ hexString.append("1.");
// significand is 52-bits, so there can be 13 hex digits
unsigned int fractionDigits = 13;
// remove trailing hex zeros, so Integer.toHexString() won't print
// them
- while( (significand != 0 ) && ( ( significand & 0xF ) == 0 ) ) {
+ while ((significand != 0) && ((significand & 0xF) == 0)) {
significand >>= 4;
fractionDigits--;
}
// this assumes Integer.toHexString() returns lowercase characters
- std::string hexSignificand = Long::toHexString( significand );
+ std::string hexSignificand = Long::toHexString(significand);
// if there are digits left, then insert some '0' chars first
- if( significand != 0 && fractionDigits > hexSignificand.length() ) {
- int digitDiff = fractionDigits - (int)hexSignificand.length();
- while( digitDiff-- != 0 ) {
- hexString.append( "0" );
+ if (significand != 0 && fractionDigits > hexSignificand.length()) {
+ int digitDiff = fractionDigits - (int) hexSignificand.length();
+ while (digitDiff-- != 0) {
+ hexString.append("0");
}
}
- hexString.append( hexSignificand );
- hexString.append( "p" );
+ hexString.append(hexSignificand);
+ hexString.append("p");
// remove exponent's 'bias' and convert to a string
- hexString.append( Long::toString( exponent - 1023 ) );
+ hexString.append(Long::toString(exponent - 1023));
}
return hexString;
}
////////////////////////////////////////////////////////////////////////////////
-std::string Double::toString( double value ) {
+std::string Double::toString(double value) {
// TODO - This is not going to output to the format we say we do.
ostringstream stream;
@@ -251,12 +259,11 @@ std::string Double::toString( double value ) {
}
////////////////////////////////////////////////////////////////////////////////
-Double Double::valueOf( double value ) {
- return Double( value );
+Double Double::valueOf(double value) {
+ return Double(value);
}
////////////////////////////////////////////////////////////////////////////////
-Double Double::valueOf( const std::string& value ) {
-
- return valueOf( parseDouble( value ) );
+Double Double::valueOf(const String& value) {
+ return valueOf(parseDouble(value));
}
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/Double.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/Double.h b/activemq-cpp/src/main/decaf/lang/Double.h
index e3f9a9c..a296561 100644
--- a/activemq-cpp/src/main/decaf/lang/Double.h
+++ b/activemq-cpp/src/main/decaf/lang/Double.h
@@ -21,11 +21,12 @@
#include <decaf/util/Config.h>
#include <decaf/lang/Comparable.h>
#include <decaf/lang/Number.h>
+#include <decaf/lang/String.h>
#include <decaf/lang/exceptions/NumberFormatException.h>
#include <string>
-namespace decaf{
-namespace lang{
+namespace decaf {
+namespace lang {
class DECAF_API Double : public Number,
public Comparable<Double>,
@@ -62,7 +63,7 @@ namespace lang{
* @param value
* The primitive type to wrap.
*/
- Double( double value );
+ Double(double value);
/**
* Constructs a new Double and attempts to convert the given string to a double
@@ -74,7 +75,7 @@ namespace lang{
*
* @throws NumberFormatException if the string is not a a valid double.
*/
- Double( const std::string& value );
+ Double(const String& value);
virtual ~Double() {}
@@ -86,13 +87,13 @@ namespace lang{
* than the passed in value, and -1 if this object repesents a value
* less than the passed in value.
*/
- virtual int compareTo( const Double& d ) const;
+ virtual int compareTo(const Double& d) const;
/**
* @param d - the Double object to compare against.
* @returns true if the two Double Objects have the same value.
*/
- bool equals( const Double& d ) const {
+ bool equals(const Double& d) const {
return this->value == d.value;
}
@@ -101,7 +102,7 @@ namespace lang{
* @param d - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator==( const Double& d ) const {
+ virtual bool operator==(const Double& d) const {
return this->value == d.value;
}
@@ -111,7 +112,7 @@ namespace lang{
* @param d - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator<( const Double& d ) const {
+ virtual bool operator<(const Double& d) const {
return this->value < d.value;
}
@@ -123,13 +124,13 @@ namespace lang{
* than the passed in value, and -1 if this object represents a value
* less than the passed in value.
*/
- virtual int compareTo( const double& d ) const;
+ virtual int compareTo(const double& d) const;
/**
* @param d - the Double object to compare against.
* @returns true if the two Double Objects have the same value.
*/
- bool equals( const double& d ) const {
+ bool equals(const double& d) const {
return this->value == d;
}
@@ -138,7 +139,7 @@ namespace lang{
* @param d - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator==( const double& d ) const {
+ virtual bool operator==(const double& d) const {
return this->value == d;
}
@@ -148,7 +149,7 @@ namespace lang{
* @param d - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator<( const double& d ) const {
+ virtual bool operator<(const double& d) const {
return this->value < d;
}
@@ -170,7 +171,7 @@ namespace lang{
* @return float the value of the receiver.
*/
virtual float floatValue() const {
- return (float)this->value;
+ return (float) this->value;
}
/**
@@ -178,7 +179,7 @@ namespace lang{
* @return byte the value of the receiver.
*/
virtual unsigned char byteValue() const {
- return (unsigned char)this->value;
+ return (unsigned char) this->value;
}
/**
@@ -186,7 +187,7 @@ namespace lang{
* @return short the value of the receiver.
*/
virtual short shortValue() const {
- return (short)this->value;
+ return (short) this->value;
}
/**
@@ -194,7 +195,7 @@ namespace lang{
* @return int the value of the receiver.
*/
virtual int intValue() const {
- return (int)this->value;
+ return (int) this->value;
}
/**
@@ -202,7 +203,7 @@ namespace lang{
* @return long the value of the receiver.
*/
virtual long long longValue() const {
- return (long long)this->value;
+ return (long long) this->value;
}
/**
@@ -215,7 +216,7 @@ namespace lang{
*/
bool isNaN() const;
- public: // Statics
+ public:
/**
* Compares the two specified double values. The sign of the integer value
@@ -228,7 +229,7 @@ namespace lang{
* 0 if d1 is numerically less than d2; and a value greater than 0 if d1 is
* numerically greater than d2.
*/
- static int compare( double d1, double d2 );
+ static int compare(double d1, double d2);
/**
* Returns a representation of the specified floating-point value according
@@ -252,7 +253,7 @@ namespace lang{
* @param value - double to be converted
* @returns the long long bits that make up the double
*/
- static long long doubleToLongBits( double value );
+ static long long doubleToLongBits(double value);
/**
* Returns a representation of the specified floating-point value according
@@ -279,19 +280,19 @@ namespace lang{
* @param value - double to be converted
* @returns the long long bits that make up the double
*/
- static long long doubleToRawLongBits( double value );
+ static long long doubleToRawLongBits(double value);
/**
* @param value - The double to check.
* @returns true if the double is equal to infinity.
*/
- static bool isInfinite( double value );
+ static bool isInfinite(double value);
/**
* @param value - The double to check.
* @returns true if the double is equal to NaN.
*/
- static bool isNaN( double value );
+ static bool isNaN(double value);
/**
* Returns the double value corresponding to a given bit representation.
@@ -309,16 +310,20 @@ namespace lang{
* @param bits - the long long bits to convert to double
* @return the double converted from the bits
*/
- static double longBitsToDouble( long long bits );
+ static double longBitsToDouble(long long bits);
/**
* Returns a new double initialized to the value represented by the
* specified string, as performed by the valueOf method of class Double.
- * @param value - The string to parse to an double
+ *
+ * @param value
+ * The string to parse to an double.
+ *
* @returns a double parsed from the passed string
+ *
* @throws NumberFormatException
*/
- static double parseDouble( const std::string value );
+ static double parseDouble(const String& value);
/**
* Returns a hexadecimal string representation of the double argument. All
@@ -354,7 +359,7 @@ namespace lang{
* @param value - The double to convert to a string
* @returns the Hex formatted double string.
*/
- static std::string toHexString( double value );
+ static std::string toHexString(double value);
/**
* Returns a string representation of the double argument. All characters
@@ -387,31 +392,37 @@ namespace lang{
* @param value - The double to convert to a string
* @returns the formatted double string.
*/
- static std::string toString( double value );
+ static std::string toString(double value);
/**
* Returns a Double instance representing the specified double value.
- * @param value - double to wrap
+ *
+ * @param value
+ * The double to wrap.
+ *
* @returns new Double instance wrapping the primitive value
*/
- static Double valueOf( double value );
+ static Double valueOf(double value);
/**
- * Returns a Double instance that wraps a primtive double which is parsed
+ * Returns a Double instance that wraps a primitive double which is parsed
* from the string value passed.
- * @param value - the string to parse
+ *
+ * @param value
+ * The string to parse
+ *
* @returns a new Double instance wrapping the double parsed from value
+ *
* @throws NumberFormatException on error.
*/
- static Double valueOf( const std::string& value );
+ static Double valueOf(const String& value);
private:
- static const long long DOUBLE_SIGN_MASK = 0x8000000000000000LL;
- static const long long DOUBLE_EXPONENT_MASK = 0x7FF0000000000000LL;
- static const long long DOUBLE_MANTISSA_MASK = 0x000FFFFFFFFFFFFFLL;
- static const long long DOUBLE_NAN_BITS =
- DOUBLE_EXPONENT_MASK | 0x0008000000000000LL;
+ static const long long DOUBLE_SIGN_MASK;
+ static const long long DOUBLE_EXPONENT_MASK;
+ static const long long DOUBLE_MANTISSA_MASK;
+ static const long long DOUBLE_NAN_BITS;
};
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/Float.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/Float.cpp b/activemq-cpp/src/main/decaf/lang/Float.cpp
index 2dc8c8b..6e77be6 100644
--- a/activemq-cpp/src/main/decaf/lang/Float.cpp
+++ b/activemq-cpp/src/main/decaf/lang/Float.cpp
@@ -17,6 +17,7 @@
#include "Float.h"
#include <decaf/lang/Integer.h>
+#include <decaf/lang/ArrayPointer.h>
#include <limits>
#include <string.h>
@@ -33,63 +34,67 @@ const float Float::NaN = std::numeric_limits<float>::quiet_NaN();
const float Float::POSITIVE_INFINITY = std::numeric_limits<float>::infinity();
const float Float::NEGATIVE_INFINITY = -std::numeric_limits<float>::infinity();
+const unsigned int Float::SINGLE_EXPONENT_MASK = 0x7F800000;
+const unsigned int Float::SINGLE_MANTISSA_MASK = 0x007FFFFF;
+const unsigned int Float::SINGLE_NAN_BITS = (SINGLE_EXPONENT_MASK | 0x00400000);
+
////////////////////////////////////////////////////////////////////////////////
-Float::Float( float value ) : value(value) {
+Float::Float(float value) : value(value) {
}
////////////////////////////////////////////////////////////////////////////////
-Float::Float( double value ) : value((float)value) {
+Float::Float(double value) : value((float) value) {
}
////////////////////////////////////////////////////////////////////////////////
-Float::Float( const std::string& value ) : value(0) {
- this->value = Float::parseFloat( value );
+Float::Float(const String& value) : value(0) {
+ this->value = Float::parseFloat(value);
}
////////////////////////////////////////////////////////////////////////////////
-int Float::compareTo( const Float& f ) const {
- return Float::compare( this->value, f.value );
+int Float::compareTo(const Float& f) const {
+ return Float::compare(this->value, f.value);
}
////////////////////////////////////////////////////////////////////////////////
-int Float::compareTo( const float& f ) const {
- return Float::compare( this->value, f );
+int Float::compareTo(const float& f) const {
+ return Float::compare(this->value, f);
}
////////////////////////////////////////////////////////////////////////////////
std::string Float::toString() const {
- return Float::toString( this->value );
+ return Float::toString(this->value);
}
////////////////////////////////////////////////////////////////////////////////
bool Float::isInfinite() const {
- return Float::isInfinite( this->value );
+ return Float::isInfinite(this->value);
}
////////////////////////////////////////////////////////////////////////////////
bool Float::isNaN() const {
- return Float::isNaN( this->value );
+ return Float::isNaN(this->value);
}
////////////////////////////////////////////////////////////////////////////////
-int Float::compare( float f1, float f2 ) {
+int Float::compare(float f1, float f2) {
int i1, i2 = 0;
- long NaNbits = Float::floatToIntBits( Float::NaN );
+ long NaNbits = Float::floatToIntBits(Float::NaN);
- if( ( i1 = Float::floatToIntBits( f1 ) ) == NaNbits ) {
- if( Float::floatToIntBits( f2 ) == NaNbits ) {
+ if ((i1 = Float::floatToIntBits(f1)) == NaNbits) {
+ if (Float::floatToIntBits(f2) == NaNbits) {
return 0;
}
return 1;
}
- if( ( i2 = Float::floatToIntBits( f2 ) ) == NaNbits ) {
+ if ((i2 = Float::floatToIntBits(f2)) == NaNbits) {
return -1;
}
- if( f1 == f2 ) {
- if( i1 == i2 ) {
+ if (f1 == f2) {
+ if (i1 == i2) {
return 0;
}
@@ -101,15 +106,13 @@ int Float::compare( float f1, float f2 ) {
}
////////////////////////////////////////////////////////////////////////////////
-int Float::floatToIntBits( float value ) {
+int Float::floatToIntBits(float value) {
int intValue = 0;
- memcpy( &intValue, &value, sizeof( float ) );
+ memcpy(&intValue, &value, sizeof(float));
- if( ( intValue & SINGLE_EXPONENT_MASK ) == SINGLE_EXPONENT_MASK )
- {
- if( intValue & SINGLE_MANTISSA_MASK )
- {
+ if ((intValue & SINGLE_EXPONENT_MASK) == SINGLE_EXPONENT_MASK) {
+ if (intValue & SINGLE_MANTISSA_MASK) {
return SINGLE_NAN_BITS;
}
}
@@ -118,136 +121,137 @@ int Float::floatToIntBits( float value ) {
}
////////////////////////////////////////////////////////////////////////////////
-int Float::floatToRawIntBits( float value ) {
-
+int Float::floatToRawIntBits(float value) {
int intValue = 0;
- memcpy( &intValue, &value, sizeof( float ) );
+ memcpy(&intValue, &value, sizeof(float));
return intValue;
}
////////////////////////////////////////////////////////////////////////////////
-float Float::intBitsToFloat( int bits ) {
-
+float Float::intBitsToFloat(int bits) {
float floatValue = 0;
- memcpy( &floatValue, &bits, sizeof( int ) );
+ memcpy(&floatValue, &bits, sizeof(int));
return floatValue;
}
////////////////////////////////////////////////////////////////////////////////
-bool Float::isInfinite( float value ) {
- return ( value == POSITIVE_INFINITY ) || ( value == NEGATIVE_INFINITY );
+bool Float::isInfinite(float value) {
+ return (value == POSITIVE_INFINITY) || (value == NEGATIVE_INFINITY);
}
////////////////////////////////////////////////////////////////////////////////
-bool Float::isNaN( float value ) {
+bool Float::isNaN(float value) {
return value != value;
}
////////////////////////////////////////////////////////////////////////////////
-float Float::parseFloat( const std::string& value ) {
+float Float::parseFloat(const String& value) {
// TODO - This is not going to parse the formats we say we do.
float result = 0.0;
- istringstream stream( value );
+
+ ArrayPointer<char> buffer(value.length() + 1);
+ value.getChars(0, value.length(), buffer.get(), value.length() + 1, 0);
+
+ istringstream stream(buffer.get());
stream >> result;
// Not everything got read, meaning there wasn't just a number here.
- if( !stream.eof() ) {
+ if (!stream.eof()) {
throw exceptions::NumberFormatException(
__FILE__, __LINE__,
- "Failed to parse a valid float from input string: %s", value.c_str() );
+ "Failed to parse a valid float from input string: %s", value.c_str());
}
return result;
}
////////////////////////////////////////////////////////////////////////////////
-std::string Float::toHexString( float value ) {
+std::string Float::toHexString(float value) {
/*
* Reference: http://en.wikipedia.org/wiki/IEEE_754
*/
- if( value != value ) {
+ if (value != value) {
return "NaN";
}
- if( value == POSITIVE_INFINITY ) {
+ if (value == POSITIVE_INFINITY) {
return "Infinity";
}
- if( value == NEGATIVE_INFINITY ) {
+ if (value == NEGATIVE_INFINITY) {
return "-Infinity";
}
- unsigned int bitValue = Float::floatToIntBits( value );
+ unsigned int bitValue = Float::floatToIntBits(value);
- bool negative = ( bitValue & 0x80000000 ) != 0;
+ bool negative = (bitValue & 0x80000000) != 0;
// mask exponent bits and shift down
- unsigned int exponent = ( bitValue & 0x7f800000 ) >> 23;
+ unsigned int exponent = (bitValue & 0x7f800000) >> 23;
// mask significand bits and shift up
// significand is 23-bits, so we shift to treat it like 24-bits
- unsigned int significand = ( bitValue & 0x007FFFFF ) << 1;
+ unsigned int significand = (bitValue & 0x007FFFFF) << 1;
- if( exponent == 0 && significand == 0 ) {
- return ( negative ? "-0x0.0p0" : "0x0.0p0" );
+ if (exponent == 0 && significand == 0) {
+ return (negative ? "-0x0.0p0" : "0x0.0p0");
}
// Start with the correct sign and Hex indicator
- std::string hexString( negative ? "-0x" : "0x" );
+ std::string hexString(negative ? "-0x" : "0x");
- if( exponent == 0 ) {
+ if (exponent == 0) {
// denormal (subnormal) value
- hexString.append( "0." );
+ hexString.append("0.");
// significand is 23-bits, so there can be 6 hex digits
unsigned int fractionDigits = 6;
// remove trailing hex zeros, so Integer.toHexString() won't print
// them
- while( ( significand != 0 ) && ( ( significand & 0xF ) == 0 ) ) {
+ while ((significand != 0) && ((significand & 0xF) == 0)) {
significand >>= 4;
fractionDigits--;
}
// this assumes Integer.toHexString() returns lowercase characters
- std::string hexSignificand = Integer::toHexString( significand );
+ std::string hexSignificand = Integer::toHexString(significand);
// if there are digits left, then insert some '0' chars first
- if( significand != 0 && fractionDigits > hexSignificand.length() ) {
- unsigned int digitDiff = fractionDigits - (int)hexSignificand.length();
- while( digitDiff-- != 0 ) {
- hexString.append( "0" );
+ if (significand != 0 && fractionDigits > hexSignificand.length()) {
+ unsigned int digitDiff = fractionDigits - (int) hexSignificand.length();
+ while (digitDiff-- != 0) {
+ hexString.append("0");
}
}
- hexString.append( hexSignificand );
- hexString.append( "p-126" );
+ hexString.append(hexSignificand);
+ hexString.append("p-126");
} else {
// normal value
- hexString.append( "1." );
+ hexString.append("1.");
// significand is 23-bits, so there can be 6 hex digits
unsigned int fractionDigits = 6;
// remove trailing hex zeros, so Integer.toHexString() won't print
// them
- while( (significand != 0) && ((significand & 0xF ) == 0 ) ) {
+ while ((significand != 0) && ((significand & 0xF) == 0)) {
significand >>= 4;
fractionDigits--;
}
// this assumes Integer.toHexString() returns lowercase characters
- std::string hexSignificand = Integer::toHexString( significand );
+ std::string hexSignificand = Integer::toHexString(significand);
// if there are digits left, then insert some '0' chars first
- if( significand != 0 && fractionDigits > hexSignificand.length() ) {
- unsigned int digitDiff = fractionDigits - (int)hexSignificand.length();
- while( digitDiff-- != 0 ) {
- hexString.append( "0" );
+ if (significand != 0 && fractionDigits > hexSignificand.length()) {
+ unsigned int digitDiff = fractionDigits - (int) hexSignificand.length();
+ while (digitDiff-- != 0) {
+ hexString.append("0");
}
}
- hexString.append( hexSignificand );
- hexString.append( "p" );
+ hexString.append(hexSignificand);
+ hexString.append("p");
// remove exponent's 'bias' and convert to a string
- hexString.append( Integer::toString( exponent - 127 ) );
+ hexString.append(Integer::toString(exponent - 127));
}
return hexString;
}
////////////////////////////////////////////////////////////////////////////////
-std::string Float::toString( float value ) {
-
+std::string Float::toString(float value) {
// TODO - This is not going to support the formats we say we do.
ostringstream stream;
stream << value;
@@ -255,12 +259,11 @@ std::string Float::toString( float value ) {
}
////////////////////////////////////////////////////////////////////////////////
-Float Float::valueOf( float value ) {
- return Float( value );
+Float Float::valueOf(float value) {
+ return Float(value);
}
////////////////////////////////////////////////////////////////////////////////
-Float Float::valueOf( const std::string& value ) {
-
- return valueOf( parseFloat( value ) );
+Float Float::valueOf(const String& value) {
+ return valueOf(parseFloat(value));
}
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/Float.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/Float.h b/activemq-cpp/src/main/decaf/lang/Float.h
index 6894391..ca57222 100644
--- a/activemq-cpp/src/main/decaf/lang/Float.h
+++ b/activemq-cpp/src/main/decaf/lang/Float.h
@@ -20,12 +20,13 @@
#include <decaf/util/Config.h>
#include <decaf/lang/Number.h>
+#include <decaf/lang/String.h>
#include <decaf/lang/Comparable.h>
#include <decaf/lang/exceptions/NumberFormatException.h>
#include <string>
-namespace decaf{
-namespace lang{
+namespace decaf {
+namespace lang {
class DECAF_API Float : public Number,
public Comparable<Float>,
@@ -59,17 +60,17 @@ namespace lang{
/**
* @param value - the primitive type to wrap
*/
- Float( float value );
+ Float(float value);
/**
* @param value - the primitive type to wrap
*/
- Float( double value );
+ Float(double value);
/**
* @param value - the string to convert to a primitive type to wrap
*/
- Float( const std::string& value );
+ Float(const String& value);
virtual ~Float() {}
@@ -81,13 +82,13 @@ namespace lang{
* than the passed in value, and -1 if this object represents a value
* less than the passed in value.
*/
- virtual int compareTo( const Float& f ) const;
+ virtual int compareTo(const Float& f) const;
/**
* @param f - the Float object to compare against.
* @returns true if the two Float Objects have the same value.
*/
- bool equals( const Float& f ) const {
+ bool equals(const Float& f) const {
return this->value == f.value;
}
@@ -96,7 +97,7 @@ namespace lang{
* @param f - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator==( const Float& f ) const {
+ virtual bool operator==(const Float& f) const {
return this->value == f.value;
}
@@ -106,7 +107,7 @@ namespace lang{
* @param f - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator<( const Float& f ) const {
+ virtual bool operator<(const Float& f) const {
return this->value < f.value;
}
@@ -118,13 +119,13 @@ namespace lang{
* than the passed in value, and -1 if this object represents a value
* less than the passed in value.
*/
- virtual int compareTo( const float& f ) const;
+ virtual int compareTo(const float& f) const;
/**
* @param f - the Float object to compare against.
* @returns true if the two Float Objects have the same value.
*/
- bool equals( const float& f ) const {
+ bool equals(const float& f) const {
return this->value == f;
}
@@ -133,7 +134,7 @@ namespace lang{
* @param f - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator==( const float& f ) const {
+ virtual bool operator==(const float& f) const {
return this->value == f;
}
@@ -143,7 +144,7 @@ namespace lang{
* @param f - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator<( const float& f ) const {
+ virtual bool operator<(const float& f) const {
return this->value < f;
}
@@ -157,7 +158,7 @@ namespace lang{
* @return double the value of the receiver.
*/
virtual double doubleValue() const {
- return (double)this->value;
+ return (double) this->value;
}
/**
@@ -173,7 +174,7 @@ namespace lang{
* @return byte the value of the receiver.
*/
virtual unsigned char byteValue() const {
- return (unsigned char)this->value;
+ return (unsigned char) this->value;
}
/**
@@ -181,7 +182,7 @@ namespace lang{
* @return short the value of the receiver.
*/
virtual short shortValue() const {
- return (short)this->value;
+ return (short) this->value;
}
/**
@@ -189,7 +190,7 @@ namespace lang{
* @return int the value of the receiver.
*/
virtual int intValue() const {
- return (int)this->value;
+ return (int) this->value;
}
/**
@@ -197,7 +198,7 @@ namespace lang{
* @return long the value of the receiver.
*/
virtual long long longValue() const {
- return (long long)this->value;
+ return (long long) this->value;
}
/**
@@ -210,7 +211,8 @@ namespace lang{
*/
bool isNaN() const;
- public: // Statics
+ public:
+ // Statics
/**
* Compares the two specified double values. The sign of the integer value
@@ -222,7 +224,7 @@ namespace lang{
* 0 if f1 is numerically less than f2; and a value greater than 0 if f1 is
* numerically greater than f2.
*/
- static int compare( float f1, float f2 );
+ static int compare(float f1, float f2);
/**
* Returns a representation of the specified floating-point value according
@@ -245,7 +247,7 @@ namespace lang{
* @param value - the float to convert to int bits
* @returns the int that holds the float's value
*/
- static int floatToIntBits( float value );
+ static int floatToIntBits(float value);
/**
* Returns a representation of the specified floating-point value according
@@ -272,7 +274,7 @@ namespace lang{
* The float to convert to a raw int.
* @returns the raw int value of the float
*/
- static int floatToRawIntBits( float value );
+ static int floatToRawIntBits(float value);
/**
* Returns the float value corresponding to a given bit representation. The
@@ -291,28 +293,36 @@ namespace lang{
* @param bits - the bits of the float encoded as a float
* @return a new float created from the int bits.
*/
- static float intBitsToFloat( int bits );
+ static float intBitsToFloat(int bits);
/**
* @param value - The float to check.
* @returns true if the float is equal to infinity.
*/
- static bool isInfinite( float value );
+ static bool isInfinite(float value);
/**
- * @param value - The float to check.
+ * Checks and returns whether the given float is equal to NaN.
+ *
+ * @param value
+ * The float to check.
+ *
* @returns true if the float is equal to NaN.
*/
- static bool isNaN( float value );
+ static bool isNaN(float value);
/**
* Returns a new float initialized to the value represented by the
* specified string, as performed by the valueOf method of class Float.
- * @param value - the string to parse
+ *
+ * @param value
+ * The string to parse.
+ *
* @returns a float parsed from the string
- * @throw NumberFormatException
+ *
+ * @throw NumberFormatException if an error occurs parsing the String.
*/
- static float parseFloat( const std::string& value );
+ static float parseFloat(const String& value);
/**
* Returns a hexadecimal string representation of the float argument. All
@@ -348,7 +358,7 @@ namespace lang{
* @param value - The float to convert to a string
* @returns the Hex formatted float string.
*/
- static std::string toHexString( float value );
+ static std::string toHexString(float value);
/**
* Returns a string representation of the float argument. All characters
@@ -378,17 +388,20 @@ namespace lang{
* representing the fractional part of a, followed by the letter 'E',
* followed by a representation of n as a decimal integer, as produced
* by the method Integer.toString(int).
- * @param value - The float to convert to a string
+ *
+ * @param value
+ * The float to convert to a string
+ *
* @returns the formatted float string.
*/
- static std::string toString( float value );
+ static std::string toString(float value);
/**
* Returns a Float instance representing the specified float value.
* @param value - float to wrap
* @returns new Float instance wrapping the primitive value
*/
- static Float valueOf( float value );
+ static Float valueOf(float value);
/**
* Returns a Float instance that wraps a primitive float which is parsed
@@ -398,13 +411,13 @@ namespace lang{
* @returns a new Float instance wrapping the float parsed from value
* @throws NumberFormatException on error.
*/
- static Float valueOf( const std::string& value );
+ static Float valueOf(const String& value);
private:
- static const unsigned int SINGLE_EXPONENT_MASK = 0x7F800000;
- static const unsigned int SINGLE_MANTISSA_MASK = 0x007FFFFF;
- static const unsigned int SINGLE_NAN_BITS = (SINGLE_EXPONENT_MASK | 0x00400000);
+ static const unsigned int SINGLE_EXPONENT_MASK;
+ static const unsigned int SINGLE_MANTISSA_MASK;
+ static const unsigned int SINGLE_NAN_BITS;
};
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/Integer.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/Integer.cpp b/activemq-cpp/src/main/decaf/lang/Integer.cpp
index 4d3a11f..04d011d 100644
--- a/activemq-cpp/src/main/decaf/lang/Integer.cpp
+++ b/activemq-cpp/src/main/decaf/lang/Integer.cpp
@@ -33,32 +33,36 @@ const int Integer::MAX_VALUE = (int)0x7FFFFFFF;
const int Integer::MIN_VALUE = (int)0x80000000;
////////////////////////////////////////////////////////////////////////////////
-Integer::Integer( int value ) :value(value) {
+Integer::Integer(int value) : value(value) {
}
////////////////////////////////////////////////////////////////////////////////
-Integer::Integer( const std::string& value ) : value() {
- this->value = parseInt( value );
+Integer::Integer(const std::string& value) : value() {
+ this->value = parseInt(value);
}
////////////////////////////////////////////////////////////////////////////////
-int Integer::compareTo( const Integer& i ) const {
+int Integer::compareTo(const Integer& i) const {
return this->value < i.value ? -1 : this->value == i.value ? 0 : 1;
}
////////////////////////////////////////////////////////////////////////////////
-int Integer::compareTo( const int& i ) const {
+int Integer::compareTo(const int& i) const {
return this->value < i ? -1 : this->value == i ? 0 : 1;
}
////////////////////////////////////////////////////////////////////////////////
-int Integer::bitCount( int value ) {
+Integer::~Integer() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Integer::bitCount(int value) {
- if( value == 0 ) {
+ if (value == 0) {
return 0;
}
- unsigned int uvalue = (unsigned int)value;
+ unsigned int uvalue = (unsigned int) value;
// 32-bit recursive reduction using SWAR...
// but first step is mapping 2-bit values
@@ -68,17 +72,17 @@ int Integer::bitCount( int value ) {
uvalue = (((uvalue >> 4) + uvalue) & 0x0F0F0F0F);
uvalue += (uvalue >> 8);
uvalue += (uvalue >> 16);
- return(uvalue & 0x0000003F);
+ return (uvalue & 0x0000003F);
}
////////////////////////////////////////////////////////////////////////////////
-int Integer::reverseBytes( int value ) {
+int Integer::reverseBytes(int value) {
- if( value == 0 ) {
+ if (value == 0) {
return 0;
}
- unsigned int uvalue = (unsigned int)value;
+ unsigned int uvalue = (unsigned int) value;
unsigned int b3 = uvalue >> 24;
unsigned int b2 = (uvalue >> 8) & 0xFF00;
@@ -88,13 +92,13 @@ int Integer::reverseBytes( int value ) {
}
////////////////////////////////////////////////////////////////////////////////
-int Integer::reverse( int value ) {
+int Integer::reverse(int value) {
- if( value == 0 ) {
+ if (value == 0) {
return 0;
}
- unsigned int uvalue = (unsigned int)value;
+ unsigned int uvalue = (unsigned int) value;
uvalue = (((uvalue & 0xAAAAAAAA) >> 1) | ((uvalue & 0x55555555) << 1));
uvalue = (((uvalue & 0xCCCCCCCC) >> 2) | ((uvalue & 0x33333333) << 2));
@@ -105,33 +109,33 @@ int Integer::reverse( int value ) {
////////////////////////////////////////////////////////////////////////////////
std::string Integer::toString() const {
- return Integer::toString( this->value, 10 );
+ return Integer::toString(this->value, 10);
}
////////////////////////////////////////////////////////////////////////////////
-std::string Integer::toString( int value ) {
- return Integer::toString( value, 10 );
+std::string Integer::toString(int value) {
+ return Integer::toString(value, 10);
}
////////////////////////////////////////////////////////////////////////////////
-std::string Integer::toString( int value, int radix ) {
+std::string Integer::toString(int value, int radix) {
- if( radix < Character::MIN_RADIX || radix > Character::MAX_RADIX ) {
+ if (radix < Character::MIN_RADIX || radix > Character::MAX_RADIX) {
radix = 10;
}
- if( value == 0 ) {
+ if (value == 0) {
return "0";
}
int count = 2, j = value;
bool negative = value < 0;
- if( !negative ) {
+ if (!negative) {
count = 1;
j = -value;
}
- while( (value /= radix) != 0 ) {
+ while ((value /= radix) != 0) {
count++;
}
@@ -141,37 +145,37 @@ std::string Integer::toString( int value, int radix ) {
char* buffer = new char[length + 1];
do {
- int ch = 0 - ( j % radix );
- if( ch > 9 ) {
+ int ch = 0 - (j % radix);
+ if (ch > 9) {
ch = ch - 10 + 'a';
} else {
ch += '0';
}
- buffer[--count] = (char)ch;
- } while( (j /= radix) != 0 );
+ buffer[--count] = (char) ch;
+ } while ((j /= radix) != 0);
- if( negative ) {
+ if (negative) {
buffer[0] = '-';
}
// Ensure there's a null
buffer[length] = 0;
- std::string result( &buffer[0] );
- delete [] buffer;
+ std::string result(&buffer[0]);
+ delete[] buffer;
return result;
}
////////////////////////////////////////////////////////////////////////////////
-std::string Integer::toBinaryString( int value ) {
+std::string Integer::toBinaryString(int value) {
int count = 1;
int j = value;
- if( value < 0 ) {
+ if (value < 0) {
count = 32;
} else {
- while ( (j >>= 1) != 0) {
+ while ((j >>= 1) != 0) {
count++;
}
}
@@ -182,28 +186,28 @@ std::string Integer::toBinaryString( int value ) {
char* buffer = new char[length + 1];
do {
- buffer[--count] = (char)( (value & 1) + '0' );
+ buffer[--count] = (char) ((value & 1) + '0');
value >>= 1;
- } while( count > 0 );
+ } while (count > 0);
// Ensure there's a null
buffer[length] = 0;
- std::string result( &buffer[0] );
- delete [] buffer;
+ std::string result(&buffer[0]);
+ delete[] buffer;
return result;
}
////////////////////////////////////////////////////////////////////////////////
-std::string Integer::toOctalString( int value ) {
+std::string Integer::toOctalString(int value) {
int count = 1, j = value;
unsigned int uvalue = (unsigned int) value;
- if( value < 0 ) {
+ if (value < 0) {
count = 11; // (8 * sizeof(value) + 2) / 3;
} else {
- while ( (j >>= 3) != 0 ) {
+ while ((j >>= 3) != 0) {
count++;
}
}
@@ -214,28 +218,28 @@ std::string Integer::toOctalString( int value ) {
char* buffer = new char[length + 1];
do {
- buffer[--count] = (char)( (uvalue & 7) + '0' );
+ buffer[--count] = (char) ((uvalue & 7) + '0');
uvalue >>= 3;
- } while( count > 0 );
+ } while (count > 0);
// Ensure there's a null
buffer[length] = 0;
- std::string result( &buffer[0] );
- delete [] buffer;
+ std::string result(&buffer[0]);
+ delete[] buffer;
return result;
}
////////////////////////////////////////////////////////////////////////////////
-std::string Integer::toHexString( int value ) {
+std::string Integer::toHexString(int value) {
int count = 1;
int j = value;
- if( value < 0 ) {
+ if (value < 0) {
count = 8;
} else {
- while( (j >>= 4) != 0 ) {
+ while ((j >>= 4) != 0) {
count++;
}
}
@@ -247,32 +251,32 @@ std::string Integer::toHexString( int value ) {
do {
int t = value & 15;
- if( t > 9 ) {
+ if (t > 9) {
t = t - 10 + 'a';
} else {
t += '0';
}
- buffer[--count] = (char)t;
+ buffer[--count] = (char) t;
value >>= 4;
- } while( count > 0 );
+ } while (count > 0);
// Ensure there's a null
buffer[length] = 0;
- std::string result( &buffer[0] );
- delete [] buffer;
+ std::string result(&buffer[0]);
+ delete[] buffer;
return result;
}
////////////////////////////////////////////////////////////////////////////////
-int Integer::parseInt( const std::string& value ) {
- return Integer::parseInt( value, 10 );
+int Integer::parseInt(const String& value) {
+ return Integer::parseInt(value, 10);
}
////////////////////////////////////////////////////////////////////////////////
-int Integer::parseInt( const std::string& value, int radix ) {
+int Integer::parseInt(const String& value, int radix) {
- if( radix < Character::MIN_RADIX ||
+ if (radix < Character::MIN_RADIX ||
radix > Character::MAX_RADIX ) {
throw NumberFormatException(
__FILE__, __LINE__,
@@ -280,63 +284,61 @@ int Integer::parseInt( const std::string& value, int radix ) {
}
int length = (int)value.length(), i = 0;
- if( length == 0 ) {
+ if (length == 0) {
throw NumberFormatException(
__FILE__, __LINE__,
"Integer:decode - Invalid: zero length string");
}
- bool negative = value[i] == '-';
- if( negative && ++i == length ) {
+ bool negative = value.charAt(i) == '-';
+ if (negative && ++i == length) {
throw NumberFormatException(
__FILE__, __LINE__,
"Integer:decode - Invalid only a minus sign given");
}
- return Integer::parse( value, i, radix, negative );
+ return Integer::parse(value, i, radix, negative);
}
////////////////////////////////////////////////////////////////////////////////
-Integer Integer::valueOf( const std::string& value ) {
-
- return Integer( Integer::parseInt( value ) );
+Integer Integer::valueOf(const String& value) {
+ return Integer(Integer::parseInt(value));
}
////////////////////////////////////////////////////////////////////////////////
-Integer Integer::valueOf( const std::string& value, int radix ) {
-
- return Integer( Integer::parseInt( value, radix ) );
+Integer Integer::valueOf(const String& value, int radix) {
+ return Integer(Integer::parseInt(value, radix));
}
////////////////////////////////////////////////////////////////////////////////
-Integer Integer::decode( const std::string& value ) {
+Integer Integer::decode(const String& value) {
- int length = (int)value.length(), i = 0;
- if( length == 0 ) {
+ int length = (int) value.length(), i = 0;
+ if (length == 0) {
throw NumberFormatException(
__FILE__, __LINE__,
"Integer:decode - Invalid zero size string");
}
- char firstDigit = value[i];
+ char firstDigit = value.charAt(i);
bool negative = firstDigit == '-';
- if( negative ) {
- if( length == 1 ) {
+ if (negative) {
+ if (length == 1) {
throw NumberFormatException(
__FILE__, __LINE__,
"Integer:decode - Invalid zero string, minus only");
}
- firstDigit = value[++i];
+ firstDigit = value.charAt(++i);
}
int base = 10;
- if( firstDigit == '0' ) {
- if( ++i == length ) {
- return valueOf( 0 );
+ if (firstDigit == '0') {
+ if (++i == length) {
+ return valueOf(0);
}
- if( ( firstDigit = value[i] ) == 'x' || firstDigit == 'X' ) {
+ if ((firstDigit = value.charAt(i)) == 'x' || firstDigit == 'X') {
if( i == length ) {
throw NumberFormatException(
__FILE__, __LINE__,
@@ -347,8 +349,8 @@ Integer Integer::decode( const std::string& value ) {
} else {
base = 8;
}
- } else if( firstDigit == '#' ) {
- if( i == length ) {
+ } else if (firstDigit == '#') {
+ if (i == length) {
throw NumberFormatException(
__FILE__, __LINE__,
"Integer:decode - Invalid zero string, minus only");
@@ -357,120 +359,116 @@ Integer Integer::decode( const std::string& value ) {
base = 16;
}
- int result = parse( value, i, base, negative );
- return valueOf( result );
+ int result = parse(value, i, base, negative);
+ return valueOf(result);
}
////////////////////////////////////////////////////////////////////////////////
-int Integer::parse( const std::string& value, int offset, int radix, bool negative ) {
+int Integer::parse(const String& value, int offset, int radix, bool negative) {
int max = Integer::MIN_VALUE / radix;
- int result = 0, length = (int)value.size();
+ int result = 0, length = (int) value.length();
- while( offset < length ) {
- int digit = Character::digit( value[offset++], radix );
- if( digit == -1 ) {
+ while (offset < length) {
+ int digit = Character::digit(value.charAt(offset++), radix);
+ if (digit == -1) {
throw NumberFormatException(
__FILE__, __LINE__,
- "Integer::parse - number string is invalid: ",
- value.c_str() );
+ "Integer::parse - number string is invalid: ", value.c_str());
}
- if( max > result ) {
+ if (max > result) {
throw NumberFormatException(
__FILE__, __LINE__,
- "Integer::parse - number string is invalid: ",
- value.c_str() );
+ "Integer::parse - number string is invalid: ", value.c_str());
}
int next = result * radix - digit;
- if( next > result ) {
+ if (next > result) {
throw NumberFormatException(
__FILE__, __LINE__,
- "Integer::parse - number string is invalid: ",
- value.c_str() );
+ "Integer::parse - number string is invalid: ", value.c_str());
}
result = next;
}
- if( !negative ) {
+ if (!negative) {
result = -result;
- if( result < 0 ) {
+ if (result < 0) {
throw NumberFormatException(
__FILE__, __LINE__,
- "Integer::parse - number string is invalid: ",
- value.c_str() );
+ "Integer::parse - number string is invalid: ", value.c_str());
}
}
return result;
}
////////////////////////////////////////////////////////////////////////////////
-int Integer::highestOneBit( int value ) {
+int Integer::highestOneBit(int value) {
- if( value == 0 ) {
+ if (value == 0) {
return 0;
}
- unsigned int uvalue = (unsigned int)value;
+ unsigned int uvalue = (unsigned int) value;
uvalue |= (uvalue >> 1);
uvalue |= (uvalue >> 2);
uvalue |= (uvalue >> 4);
uvalue |= (uvalue >> 8);
uvalue |= (uvalue >> 16);
- return ( uvalue & ~(uvalue >> 1));
+ return (uvalue & ~(uvalue >> 1));
}
////////////////////////////////////////////////////////////////////////////////
-int Integer::lowestOneBit( int value ) {
- if( value == 0 ) {
+int Integer::lowestOneBit(int value) {
+ if (value == 0) {
return 0;
}
- unsigned int uvalue = (unsigned int)value;
- return ( uvalue & (-uvalue) );
+ unsigned int uvalue = (unsigned int) value;
+ return (uvalue & (-uvalue));
}
////////////////////////////////////////////////////////////////////////////////
-int Integer::numberOfLeadingZeros( int value ) {
+int Integer::numberOfLeadingZeros(int value) {
- if( value == 0 ) {
+ if (value == 0) {
return 0;
}
- unsigned int uvalue = (unsigned int)value;
+ unsigned int uvalue = (unsigned int) value;
value |= value >> 1;
value |= value >> 2;
value |= value >> 4;
value |= value >> 8;
value |= value >> 16;
- return Integer::bitCount( ~uvalue );
+ return Integer::bitCount(~uvalue);
}
////////////////////////////////////////////////////////////////////////////////
-int Integer::numberOfTrailingZeros( int value ) {
- if( value == 0 ) {
+int Integer::numberOfTrailingZeros(int value) {
+ if (value == 0) {
return 0;
}
- unsigned int uvalue = (unsigned int)value;
- return bitCount( (uvalue & -uvalue) - 1 );
+ unsigned int uvalue = (unsigned int) value;
+ return bitCount((uvalue & -uvalue) - 1);
}
////////////////////////////////////////////////////////////////////////////////
-int Integer::rotateLeft( int value, int distance ) {
- unsigned int i = (unsigned int)value;
+int Integer::rotateLeft(int value, int distance) {
+ unsigned int i = (unsigned int) value;
int j = distance & 0x1F;
- return ( i << j ) | ( i >> (-j & 0x1F ) );
+ return (i << j) | (i >> (-j & 0x1F));
}
////////////////////////////////////////////////////////////////////////////////
-int Integer::rotateRight( int value, int distance ) {
- unsigned int i = (unsigned int)value;
+int Integer::rotateRight(int value, int distance) {
+ unsigned int i = (unsigned int) value;
int j = distance & 0x1F;
- return ( i >> j ) | ( i << (-j & 0x1F ) );
+ return (i >> j) | (i << (-j & 0x1F));
}
////////////////////////////////////////////////////////////////////////////////
-int Integer::signum( int value ) {
- return ( value == 0 ? 0 : ( value < 0 ? -1 : 1 ) );
+int Integer::signum(int value) {
+ return (value == 0 ? 0 : (value < 0 ? -1 : 1));
}
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/Integer.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/Integer.h b/activemq-cpp/src/main/decaf/lang/Integer.h
index a2a2147..d74c613 100644
--- a/activemq-cpp/src/main/decaf/lang/Integer.h
+++ b/activemq-cpp/src/main/decaf/lang/Integer.h
@@ -20,6 +20,7 @@
#include <decaf/util/Config.h>
#include <decaf/lang/Number.h>
+#include <decaf/lang/String.h>
#include <decaf/lang/Comparable.h>
#include <string>
#include <decaf/lang/exceptions/NumberFormatException.h>
@@ -66,8 +67,7 @@ namespace lang{
*/
Integer(const std::string& value);
- virtual ~Integer() {
- }
+ virtual ~Integer();
/**
* Compares this Integer instance with another.
@@ -214,7 +214,7 @@ namespace lang{
* @returns a Integer object containing the decoded value
* @throws NumberFomatException if the string is not formatted correctly.
*/
- static Integer decode(const std::string& value);
+ static Integer decode(const String& value);
/**
* Returns the value obtained by reversing the order of the bytes in the
@@ -255,7 +255,7 @@ namespace lang{
* @return the int represented by the string argument in the specified radix.
* @throws NumberFormatException - If String does not contain a parsable int.
*/
- static int parseInt(const std::string& s, int radix);
+ static int parseInt(const String& s, int radix);
/**
* Parses the string argument as a signed decimal int. The characters
@@ -264,15 +264,21 @@ namespace lang{
* negative value. The resulting int value is returned, exactly as if
* the argument and the radix 10 were given as arguments to the
* parseInteger( const std::string, int ) method.
- * @param s - String to convert to a int
+ *
+ * @param s
+ * String to convert to a int
+ *
* @returns the converted int value
* @throws NumberFormatException if the string is not a int.
*/
- static int parseInt(const std::string& s);
+ static int parseInt(const String& s);
/**
* Returns a Integer instance representing the specified int value.
- * @param value - the int to wrap
+ *
+ * @param value
+ * The int to wrap in an Integer object.
+ *
* @return the new Integer object wrapping value.
*/
static Integer valueOf(int value) {
@@ -289,7 +295,7 @@ namespace lang{
* @return new Integer Object wrapping the primitive
* @throws NumberFormatException if the string is not a decimal int.
*/
- static Integer valueOf(const std::string& value);
+ static Integer valueOf(const String& value);
/**
* Returns a Integer object holding the value extracted from the specified
@@ -303,7 +309,7 @@ namespace lang{
* @return new Integer Object wrapping the primitive
* @throws NumberFormatException if the string is not a valid int.
*/
- static Integer valueOf(const std::string& value, int radix);
+ static Integer valueOf(const String& value, int radix);
/**
* Returns the number of one-bits in the two's complement binary
@@ -512,7 +518,7 @@ namespace lang{
private:
- static int parse(const std::string& value, int offset, int radix, bool negative);
+ static int parse(const String& value, int offset, int radix, bool negative);
};
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/76ec5822/activemq-cpp/src/main/decaf/lang/Long.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/lang/Long.cpp b/activemq-cpp/src/main/decaf/lang/Long.cpp
index dba47ca..ba6383c 100644
--- a/activemq-cpp/src/main/decaf/lang/Long.cpp
+++ b/activemq-cpp/src/main/decaf/lang/Long.cpp
@@ -32,11 +32,15 @@ Long::Long(long long value) : value(value) {
}
////////////////////////////////////////////////////////////////////////////////
-Long::Long(const std::string& value) : value(0) {
+Long::Long(const String& value) : value(0) {
this->value = parseLong(value);
}
////////////////////////////////////////////////////////////////////////////////
+Long::~Long() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
int Long::compareTo(const Long& l) const {
return this->value < l.value ? -1 : this->value == l.value ? 0 : 1;
}
@@ -66,20 +70,20 @@ int Long::bitCount(long long value) {
}
////////////////////////////////////////////////////////////////////////////////
-Long Long::decode(const std::string& value) {
+Long Long::decode(const String& value) {
int length = (int) value.length(), i = 0;
if (length == 0) {
throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::decode - Zero length string given.");
}
- char firstDigit = value[i];
+ char firstDigit = value.charAt(i);
bool negative = firstDigit == '-';
if (negative) {
if (length == 1) {
throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::decode - Invalid length string given.", value.c_str());
}
- firstDigit = value[++i];
+ firstDigit = value.charAt(++i);
}
int base = 10;
@@ -87,7 +91,7 @@ Long Long::decode(const std::string& value) {
if (++i == length) {
return valueOf(0LL);
}
- if ((firstDigit = value[i]) == 'x' || firstDigit == 'X') {
+ if ((firstDigit = value.charAt(i)) == 'x' || firstDigit == 'X') {
if (i == length) {
throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::decode - Invalid length string given.", value.c_str());
}
@@ -165,13 +169,12 @@ int Long::numberOfTrailingZeros(long long value) {
}
////////////////////////////////////////////////////////////////////////////////
-long long Long::parseLong(const std::string& value) {
-
+long long Long::parseLong(const String& value) {
return Long::parseLong(value, 10);
}
////////////////////////////////////////////////////////////////////////////////
-long long Long::parseLong(const std::string& value, int radix) {
+long long Long::parseLong(const String& value, int radix) {
if (radix < Character::MIN_RADIX || radix > Character::MAX_RADIX) {
throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::parseLong - Given Radix is out of range.");
@@ -184,7 +187,7 @@ long long Long::parseLong(const std::string& value, int radix) {
throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::parseLong - Zero length string is illegal.");
}
- bool negative = value[i] == '-';
+ bool negative = value.charAt(i) == '-';
if (negative && ++i == length) {
throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::parseLong - Only a minus given, string is invalid.");
}
@@ -193,27 +196,30 @@ long long Long::parseLong(const std::string& value, int radix) {
}
////////////////////////////////////////////////////////////////////////////////
-long long Long::parse(const std::string& value, int offset, int radix, bool negative) {
+long long Long::parse(const String& value, int offset, int radix, bool negative) {
long long max = Long::MIN_VALUE / radix;
long long result = 0;
long long length = value.length();
while (offset < length) {
- int digit = Character::digit(value[offset++], radix);
+ int digit = Character::digit(value.charAt(offset++), radix);
if (digit == -1) {
- throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::parseLong - String contains no digit characters.");
+ throw exceptions::NumberFormatException(__FILE__, __LINE__,
+ "Long::parseLong - String contains no digit characters.");
}
if (max > result) {
- throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::parseLong - Parsed value greater than max for radix.");
+ throw exceptions::NumberFormatException(__FILE__, __LINE__,
+ "Long::parseLong - Parsed value greater than max for radix.");
}
long long next = result * radix - digit;
if (next > result) {
- throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::parseLong - Only a minus given, string is invalid.");
+ throw exceptions::NumberFormatException(__FILE__, __LINE__,
+ "Long::parseLong - Only a minus given, string is invalid.");
}
result = next;
@@ -222,7 +228,8 @@ long long Long::parse(const std::string& value, int offset, int radix, bool nega
if (!negative) {
result = -result;
if (result < 0) {
- throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::parseLong - Value less than zero, but no minus sign.");
+ throw exceptions::NumberFormatException(__FILE__, __LINE__,
+ "Long::parseLong - Value less than zero, but no minus sign.");
}
}
@@ -450,11 +457,11 @@ std::string Long::toHexString(long long value) {
}
////////////////////////////////////////////////////////////////////////////////
-Long Long::valueOf(const std::string& value) {
+Long Long::valueOf(const String& value) {
return Long(Long::parseLong(value));
}
////////////////////////////////////////////////////////////////////////////////
-Long Long::valueOf(const std::string& value, int radix) {
+Long Long::valueOf(const String& value, int radix) {
return Long(Long::parseLong(value, radix));
}