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 2007/08/03 17:06:16 UTC

svn commit: r562495 - in /activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang: Byte.cpp Byte.h Double.cpp Double.h Float.cpp Float.h Integer.cpp Integer.h Long.cpp Long.h Short.cpp Short.h

Author: tabish
Date: Fri Aug  3 08:06:15 2007
New Revision: 562495

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

Adding in more Types wrappers

Modified:
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Byte.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Byte.h
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Double.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Double.h
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Float.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Float.h
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Integer.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Integer.h
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Long.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Long.h
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.h

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Byte.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Byte.cpp?view=diff&rev=562495&r1=562494&r2=562495
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Byte.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Byte.cpp Fri Aug  3 08:06:15 2007
@@ -29,7 +29,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Byte::Byte( const std::string& value ) {
+Byte::Byte( const std::string& value ) throw( exceptions::NumberFormatException ) {
     this->value = parseByte( value );
 }
 

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Byte.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Byte.h?view=diff&rev=562495&r1=562494&r2=562495
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Byte.h (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Byte.h Fri Aug  3 08:06:15 2007
@@ -27,9 +27,9 @@
 namespace decaf{
 namespace lang{
 
-    class Byte : public Number,
-                 public Comparable<Byte>,
-                 public Comparable<unsigned char> {
+    class DECAF_API Byte : public Number,
+                           public Comparable<Byte>,
+                           public Comparable<unsigned char> {
     private:
 
         unsigned char value;
@@ -54,8 +54,9 @@
 
         /**
          * @param value - the string to convert to an unsigned char
+         * @throws NumberFormatException
          */
-        Byte( const std::string& value );
+        Byte( const std::string& value ) throw( exceptions::NumberFormatException );
 
         virtual ~Byte() {}
 

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Double.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Double.cpp?view=diff&rev=562495&r1=562494&r2=562495
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Double.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Double.cpp Fri Aug  3 08:06:15 2007
@@ -17,9 +17,38 @@
 
 #include "Double.h"
 
+using namespace std;
 using namespace decaf;
 using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
-Double::Double() {
+const double Double::MAX_VALUE = 1.7976931348623157e+308;
+const double Double::MIN_VALUE = 2.2250738585072014e-308;
+
+////////////////////////////////////////////////////////////////////////////////
+Double::Double( double value ) {
+    this->value = value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Double::Double( const std::string& value ) throw( exceptions::NumberFormatException ) {
+    //TODO this->value = Double::parseFloat( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Double::compareTo( const Double& d ) const {
+    // TODO
+    return this->value < d.value ? -1 : this->value == d.value ? 0 : 1;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Double::compareTo( const double& d ) const {
+    // TODO
+    return this->value < d ? -1 : this->value == d ? 0 : 1;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Double::toString() const {
+    return ""; //TODO Float::toString( this->value, 10 );
 }

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Double.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Double.h?view=diff&rev=562495&r1=562494&r2=562495
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Double.h (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Double.h Fri Aug  3 08:06:15 2007
@@ -21,17 +21,170 @@
 #include <decaf/util/Config.h>
 #include <decaf/lang/Comparable.h>
 #include <decaf/lang/Number.h>
+#include <decaf/lang/exceptions/NumberFormatException.h>
 #include <string>
 
 namespace decaf{
 namespace lang{
 
-    class DECAF_API Double : public Number {
+    class DECAF_API Double : public Number,
+                             public Comparable<Double>,
+                             public Comparable<double> {
+    private:
+
+        double value;
+
+    public:
+
+        /** The size in bits of the primitive int type */
+        static const int SIZE = 64;
+
+        /** The maximum value that the primitive type can hold */
+        static const double MAX_VALUE;
+
+        /** The minimum value that the primitive type can hold */
+        static const double MIN_VALUE;
+
     public:
 
-        Double();
+        /**
+         * @param value - the primitve type to wrap
+         */
+        Double( double value );
+
+        /**
+         * @param value - the string to convert to a primitve type to wrap
+         */
+        Double( const std::string& value ) throw( exceptions::NumberFormatException );
 
         virtual ~Double() {}
+
+        /**
+         * Compares this Double instance with another.
+         * @param d - the Double instance to be compared
+         * @return zero if this object represents the same integer value as the
+         * argument; a positive value if this object represents a value greater
+         * 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;
+
+        /**
+         * @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 {
+            return this->value == d.value;
+        }
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @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 {
+            return this->value == d.value;
+        }
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @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 {
+            return this->value < d.value;
+        }
+
+        /**
+         * Compares this Double instance with another.
+         * @param d - the Double instance to be compared
+         * @return zero if this object represents the same integer value as the
+         * argument; a positive value if this object represents a value greater
+         * 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;
+
+        /**
+         * @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 {
+            return this->value == d;
+        }
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @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 {
+            return this->value == d;
+        }
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @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 {
+            return this->value < d;
+        }
+
+        /**
+         * @returns this Double Object as a String Representation
+         */
+        std::string toString() const;
+
+        /**
+         * Answers the double value which the receiver represents
+         * @return double the value of the receiver.
+         */
+        virtual double doubleValue() const {
+            return (double)this->value;
+        }
+
+        /**
+         * Answers the float value which the receiver represents
+         * @return float the value of the receiver.
+         */
+        virtual float floatValue() const {
+            return this->value;
+        }
+
+        /**
+         * Answers the byte value which the receiver represents
+         * @return byte the value of the receiver.
+         */
+        virtual unsigned char byteValue() const {
+            return (unsigned char)this->value;
+        }
+
+        /**
+         * Answers the short value which the receiver represents
+         * @return short the value of the receiver.
+         */
+        virtual short shortValue() const {
+            return (short)this->value;
+        }
+
+        /**
+         * Answers the int value which the receiver represents
+         * @return int the value of the receiver.
+         */
+        virtual int intValue() const {
+            return (int)this->value;
+        }
+
+        /**
+         * Answers the long value which the receiver represents
+         * @return long the value of the receiver.
+         */
+        virtual long long longValue() const {
+            return (long long)this->value;
+        }
 
     };
 

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Float.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Float.cpp?view=diff&rev=562495&r1=562494&r2=562495
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Float.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Float.cpp Fri Aug  3 08:06:15 2007
@@ -17,9 +17,43 @@
 
 #include "Float.h"
 
+using namespace std;
 using namespace decaf;
 using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
-Float::Float() {
+const float Float::MAX_VALUE = 3.40282347e+38F;
+const float Float::MIN_VALUE = 1.17549435e-38F;
+
+////////////////////////////////////////////////////////////////////////////////
+Float::Float( float value ) {
+    this->value = value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Float::Float( double value ) {
+    this->value = (float)value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+Float::Float( const std::string& value ) throw( exceptions::NumberFormatException ) {
+    //TODO this->value = Float::parseFloat( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Float::compareTo( const Float& f ) const {
+    // TODO
+    return this->value < f.value ? -1 : this->value == f.value ? 0 : 1;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Float::compareTo( const float& f ) const {
+    // TODO
+    return this->value < f ? -1 : this->value == f ? 0 : 1;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string Float::toString() const {
+    return ""; //TODO Float::toString( this->value, 10 );
 }

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Float.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Float.h?view=diff&rev=562495&r1=562494&r2=562495
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Float.h (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Float.h Fri Aug  3 08:06:15 2007
@@ -21,17 +21,175 @@
 #include <decaf/util/Config.h>
 #include <decaf/lang/Number.h>
 #include <decaf/lang/Comparable.h>
+#include <decaf/lang/exceptions/NumberFormatException.h>
 #include <string>
 
 namespace decaf{
 namespace lang{
 
-    class DECAF_API Float : public Number {
+    class DECAF_API Float : public Number,
+                            public Comparable<Float>,
+                            public Comparable<float> {
+    private:
+
+        float value;
+
+    public:
+
+        /** The size in bits of the primitive int type */
+        static const int SIZE = 32;
+
+        /** The maximum value that the primitive type can hold */
+        static const float MAX_VALUE;
+
+        /** The minimum value that the primitive type can hold */
+        static const float MIN_VALUE;
+
     public:
 
-        Float();
+        /**
+         * @param value - the primitve type to wrap
+         */
+        Float( float value );
+
+        /**
+         * @param value - the primitve type to wrap
+         */
+        Float( double value );
+
+        /**
+         * @param value - the string to convert to a primitve type to wrap
+         */
+        Float( const std::string& value ) throw( exceptions::NumberFormatException );
 
         virtual ~Float() {}
+
+        /**
+         * Compares this Float instance with another.
+         * @param f - the Float instance to be compared
+         * @return zero if this object represents the same integer value as the
+         * argument; a positive value if this object represents a value greater
+         * than the passed in value, and -1 if this object repesents a value
+         * less than the passed in value.
+         */
+        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 {
+            return this->value == f.value;
+        }
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @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 {
+            return this->value == f.value;
+        }
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @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 {
+            return this->value < f.value;
+        }
+
+        /**
+         * Compares this Float instance with another.
+         * @param f - the Float instance to be compared
+         * @return zero if this object represents the same integer value as the
+         * argument; a positive value if this object represents a value greater
+         * than the passed in value, and -1 if this object repesents a value
+         * less than the passed in value.
+         */
+        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 {
+            return this->value == f;
+        }
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @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 {
+            return this->value == f;
+        }
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @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 {
+            return this->value < f;
+        }
+
+        /**
+         * @returns this Float Object as a String Representation
+         */
+        std::string toString() const;
+
+        /**
+         * Answers the double value which the receiver represents
+         * @return double the value of the receiver.
+         */
+        virtual double doubleValue() const {
+            return (double)this->value;
+        }
+
+        /**
+         * Answers the float value which the receiver represents
+         * @return float the value of the receiver.
+         */
+        virtual float floatValue() const {
+            return this->value;
+        }
+
+        /**
+         * Answers the byte value which the receiver represents
+         * @return byte the value of the receiver.
+         */
+        virtual unsigned char byteValue() const {
+            return (unsigned char)this->value;
+        }
+
+        /**
+         * Answers the short value which the receiver represents
+         * @return short the value of the receiver.
+         */
+        virtual short shortValue() const {
+            return (short)this->value;
+        }
+
+        /**
+         * Answers the int value which the receiver represents
+         * @return int the value of the receiver.
+         */
+        virtual int intValue() const {
+            return (int)this->value;
+        }
+
+        /**
+         * Answers the long value which the receiver represents
+         * @return long the value of the receiver.
+         */
+        virtual long long longValue() const {
+            return (long long)this->value;
+        }
 
     };
 

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Integer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Integer.cpp?view=diff&rev=562495&r1=562494&r2=562495
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Integer.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Integer.cpp Fri Aug  3 08:06:15 2007
@@ -29,7 +29,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Integer::Integer( const std::string& value ) {
+Integer::Integer( const std::string& value ) throw( exceptions::NumberFormatException ) {
     this->value = parseInt( value );
 }
 

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Integer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Integer.h?view=diff&rev=562495&r1=562494&r2=562495
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Integer.h (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Integer.h Fri Aug  3 08:06:15 2007
@@ -55,8 +55,9 @@
 
         /**
          * @param the base 10 encoded string to decode to sn int and wrap.
+         * @throws NumberFormatException
          */
-        Integer( const std::string& value );
+        Integer( const std::string& value ) throw( exceptions::NumberFormatException );
 
         virtual ~Integer() {}
 

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Long.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Long.cpp?view=diff&rev=562495&r1=562494&r2=562495
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Long.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Long.cpp Fri Aug  3 08:06:15 2007
@@ -28,7 +28,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Long::Long( const std::string& value ) {
+Long::Long( const std::string& value ) throw( exceptions::NumberFormatException ) {
     this->value = parseLong( value );
 }
 

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Long.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Long.h?view=diff&rev=562495&r1=562494&r2=562495
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Long.h (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Long.h Fri Aug  3 08:06:15 2007
@@ -54,8 +54,9 @@
 
         /**
          * @param value - the long long formated string to wrap
+         * @thorw NumberFormatException
          */
-        Long( const std::string& value );
+        Long( const std::string& value ) throw( exceptions::NumberFormatException );
 
         virtual ~Long() {}
 

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.cpp?view=diff&rev=562495&r1=562494&r2=562495
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.cpp Fri Aug  3 08:06:15 2007
@@ -30,7 +30,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Short::Short( const std::string& value ) {
+Short::Short( const std::string& value ) throw( exceptions::NumberFormatException ) {
     this->value = value.size(); //Short::parseShort( value );
 }
 

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.h?view=diff&rev=562495&r1=562494&r2=562495
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.h (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.h Fri Aug  3 08:06:15 2007
@@ -54,8 +54,9 @@
 
         /**
          * @param value - string value to convert to short and wrap
+         * @throws NumberFormatException
          */
-        Short( const std::string& value );
+        Short( const std::string& value ) throw( exceptions::NumberFormatException );
 
         virtual ~Short() {}