activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r562183 - in /activemq/activemq-cpp/trunk/src/decaf/src/main/decaf: lang/Boolean.cpp lang/Boolean.h lang/Character.cpp lang/Character.h lang/Comparable.h lang/Integer.cpp lang/Integer.h lang/Short.cpp lang/Short.h util/UUID.cpp util/UUID.h
Date Thu, 02 Aug 2007 17:09:00 GMT
Author: tabish
Date: Thu Aug  2 10:08:58 2007
New Revision: 562183

URL: http://svn.apache.org/viewvc?view=rev&rev=562183
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/Boolean.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Boolean.h
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Character.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Character.h
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Comparable.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/Short.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Short.h
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.h

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Boolean.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Boolean.cpp?view=diff&rev=562183&r1=562182&r2=562183
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Boolean.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Boolean.cpp Thu Aug  2 10:08:58
2007
@@ -47,6 +47,37 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+bool Boolean::operator==( const Boolean& b ) const {
+    return this->value == b.value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Boolean::operator<( const Boolean& b ) const {
+    return this->value < b.value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int Boolean::compareTo( const bool& b ) const {
+    if( this->value == b ) {
+        return 0;
+    } else if( this->value && !b ) {
+        return 1;
+    } else {
+        return -1;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Boolean::operator==( const bool& b ) const {
+    return this->value == b;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool Boolean::operator<( const bool& b ) const {
+    return this->value < b;
+}
+
+////////////////////////////////////////////////////////////////////////////////
 std::string Boolean::toString() const {
     return this->value ? "true" : "false";
 }

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Boolean.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Boolean.h?view=diff&rev=562183&r1=562182&r2=562183
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Boolean.h (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Boolean.h Thu Aug  2 10:08:58
2007
@@ -25,7 +25,8 @@
 namespace decaf{
 namespace lang{
 
-    class DECAF_API Boolean : public Comparable<Boolean> {
+    class DECAF_API Boolean : public Comparable<Boolean>,
+                              public Comparable<bool> {
     private:
 
         // This objects boolean value
@@ -80,10 +81,57 @@
         virtual int compareTo( const Boolean& b ) const;
 
         /**
+         * Compares equality between this object and the one passed.
+         * @param value - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const Boolean& value ) const;
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param value - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const Boolean& value ) const;
+
+        /**
          * @returns true if the two Boolean Objects have the same value.
          */
         bool equals( const Boolean& b ) const {
             return this->value == b.value;
+        }
+
+        /**
+         * Compares this Boolean instance with another.
+         * @param b - the Boolean instance to be compared
+         * @return zero if this object represents the same boolean value as the
+         * argument; a positive value if this object represents true and the
+         * argument represents false; and a negative value if this object
+         * represents false and the argument represents true
+         */
+        virtual int compareTo( const bool& b ) const;
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @param value - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const bool& value ) const;
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param value - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const bool& value ) const;
+
+        /**
+         * @returns true if the two Boolean Objects have the same value.
+         */
+        bool equals( const bool& b ) const {
+            return this->value == b;
         }
 
     public:  // Statics

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Character.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Character.cpp?view=diff&rev=562183&r1=562182&r2=562183
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Character.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Character.cpp Thu Aug  2 10:08:58
2007
@@ -27,11 +27,6 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int Character::compareTo( const Character& c ) const {
-    return value < c.value ? -1 : (value > c.value) ? -1 : 0;
-}
-
-////////////////////////////////////////////////////////////////////////////////
 std::string Character::toString() const {
     return string( 1, this->value );
 }

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Character.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Character.h?view=diff&rev=562183&r1=562182&r2=562183
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Character.h (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Character.h Thu Aug  2 10:08:58
2007
@@ -27,7 +27,8 @@
 namespace lang{
 
     class DECAF_API Character : public Number,
-                                public Comparable<Character> {
+                                public Comparable<Character>,
+                                public Comparable<char> {
     private:
 
         // The primitive Char value
@@ -65,13 +66,72 @@
          * than the passed in value, and -1 if this object repesents a value
          * less than the passed in value.
          */
-        virtual int compareTo( const Character& c ) const;
+        virtual int compareTo( const Character& c ) const {
+            return this->value < c.value ? -1 : (this->value > c.value) ? -1
: 0;
+        }
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @param c - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const Character& c ) const {
+            return this->value == c.value;
+        }
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param c - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const Character& c ) const {
+            return this->value < c.value;
+        }
+
+        /**
+         * Compares this Character instance with a char type.
+         * @param c - the char instance to be compared
+         * @return zero if this object represents the same char 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 char& c ) const {
+            return this->value < c ? -1 : (this->value > c) ? -1 : 0;
+        }
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @param c - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const char& c ) const {
+            return this->value == c;
+        }
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param c - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const char& c ) const {
+            return this->value < c;
+        }
 
         /**
          * @returns true if the two Character Objects have the same value.
          */
         bool equals( const Character& c ) const {
             return this->value == c.value;
+        }
+
+        /**
+         * @returns true if the two Characters have the same value.
+         */
+        bool equals( const char& c ) const {
+            return this->value == c;
         }
 
         /**

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Comparable.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Comparable.h?view=diff&rev=562183&r1=562182&r2=562183
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Comparable.h (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Comparable.h Thu Aug  2 10:08:58
2007
@@ -46,6 +46,26 @@
          */
         virtual int compareTo( const T& value ) const = 0;
 
+        /**
+         * @return true if this value is considered equal to the passed value.
+         */
+        virtual bool equals( const T& value ) const = 0;
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @param value - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const T& value ) const = 0;
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param value - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const T& value ) const = 0;
+
     };
 
 }}

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=562183&r1=562182&r2=562183
==============================================================================
--- 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 Thu Aug  2 10:08:58
2007
@@ -34,8 +34,13 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int Integer::compareTo( const Integer& n ) const {
-    return this->value < n.value ? -1 : this->value == n.value ? 0 : 1;
+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 {
+    return this->value < i ? -1 : this->value == i ? 0 : 1;
 }
 
 ////////////////////////////////////////////////////////////////////////////////

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=562183&r1=562182&r2=562183
==============================================================================
--- 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 Thu Aug  2 10:08:58
2007
@@ -28,7 +28,8 @@
 namespace lang{
 
     class DECAF_API Integer : public Number,
-                              public Comparable<Integer> {
+                              public Comparable<Integer>,
+                              public Comparable<int> {
     private:
 
         // The primitve Integer value.
@@ -61,20 +62,76 @@
 
         /**
          * Compares this Integer instance with another.
-         * @param b - the Integer instance to be compared
+         * @param i - the Integer 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 Integer& n ) const;
+        virtual int compareTo( const Integer& i ) const;
 
         /**
-         * @param the Integer object to compare against.
+         * @param i - the Integer object to compare against.
          * @returns true if the two Integer Objects have the same value.
          */
-        bool equals( const Integer& n ) const {
-            return this->value == n.value;
+        bool equals( const Integer& i ) const {
+            return this->value == i.value;
+        }
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @param i - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const Integer& i ) const {
+            return this->value == i.value;
+        }
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param i - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const Integer& i ) const {
+            return this->value < i.value;
+        }
+
+        /**
+         * Compares this Integer instance with another.
+         * @param i - the Integer 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 int& i ) const;
+
+        /**
+         * @param i - the Integer object to compare against.
+         * @returns true if the two Integer Objects have the same value.
+         */
+        bool equals( const int& i ) const {
+            return this->value == i;
+        }
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @param i - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const int& i ) const {
+            return this->value == i;
+        }
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param i - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const int& i ) const {
+            return this->value < i;
         }
 
         /**

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=562183&r1=562182&r2=562183
==============================================================================
--- 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 Thu Aug  2 10:08:58
2007
@@ -16,11 +16,13 @@
  */
 
 #include "Short.h"
+#include "Integer.h"
 
 #include <sstream>
 
 using namespace decaf;
 using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
 Short::Short( short value ) {
@@ -33,8 +35,13 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int Short::compareTo( const Short& b ) const {
-    return value == b.value ? 0 : ( value > b.value ? 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 );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -53,8 +60,15 @@
 short Short::parseShort( const std::string& s, int radix )
     throw ( exceptions::NumberFormatException ) {
 
-    // TODO
-    return s.size() + radix;
+    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.");
+    }
+
+    return result;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -67,14 +81,21 @@
 Short Short::decode( const std::string& value )
     throw ( exceptions::NumberFormatException ) {
 
-    // TODO
-    return Short( value.size() );
+    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 );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 short Short::reverseBytes( short value ) {
-    short temp = value;
-    temp = ( ( value & 0xFF00 ) >> 8 ) | ( ( value & 0x00FF ) << 8 );
+    unsigned short temp = value;
+    temp = ( ( temp & 0xFF00 ) >> 8 ) | ( ( temp & 0x00FF ) << 8 );
     return temp;
 }
 

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=562183&r1=562182&r2=562183
==============================================================================
--- 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 Thu Aug  2 10:08:58
2007
@@ -27,7 +27,8 @@
 namespace lang{
 
     class Short : public Number,
-                  public Comparable<Short> {
+                  public Comparable<Short>,
+                  public Comparable<short> {
     private:
 
         // The short value
@@ -60,19 +61,74 @@
 
         /**
          * Compares this Short instance with another.
-         * @param b - the Short instance to be compared
+         * @param s - the Short instance to be compared
          * @return zero if this object represents the same short 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 Short& b ) 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 {
             return this->value == s.value;
+        }
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @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 {
+            return this->value == s.value;
+        }
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @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 {
+            return this->value < s.value;
+        }
+
+        /**
+         * Compares this Short instance with another.
+         * @param s - the Short instance to be compared
+         * @return zero if this object represents the same short 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 short& s ) const;
+
+        /**
+         * @returns true if the two Short Objects have the same value.
+         */
+        bool equals( const short& s ) const {
+            return this->value == s;
+        }
+
+        /**
+         * Compares equality between this object and the one passed.
+         * @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 {
+            return this->value == s;
+        }
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @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 {
+            return this->value < s;
         }
 
         /**

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.cpp?view=diff&rev=562183&r1=562182&r2=562183
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.cpp Thu Aug  2 10:08:58
2007
@@ -47,6 +47,16 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+bool UUID::operator==( const UUID& value ) const {
+    return this->equals( value );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool UUID::operator<( const UUID& value ) const {
+    return this->compareTo( value ) == -1 ? true : false;
+}
+
+////////////////////////////////////////////////////////////////////////////////
 std::string UUID::toString() const {
     char buffer[APR_UUID_FORMATTED_LENGTH+1] = {0};
     apr_uuid_format( &buffer[0], &apr_uuid );

Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.h?view=diff&rev=562183&r1=562182&r2=562183
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.h (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.h Thu Aug  2 10:08:58 2007
@@ -124,6 +124,21 @@
         virtual bool equals( const UUID& value ) const;
 
         /**
+         * Compares equality between this object and the one passed.
+         * @param value - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator==( const UUID& value ) const;
+
+        /**
+         * Compares this object to another and returns true if this object
+         * is considered to be less than the one passed.  This
+         * @param value - the value to be compared to this one.
+         * @return true if this object is equal to the one passed.
+         */
+        virtual bool operator<( const UUID& value ) const;
+
+        /**
          * Returns a String object representing this UUID.  UUID's are formatted
          * as: 00112233-4455-6677-8899-AABBCCDDEEFF whose length is 36.
          * @returns formatted string for this UUID



Mime
View raw message