activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r560827 - in /activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang: Character.cpp Character.h Integer.cpp
Date Sun, 29 Jul 2007 22:01:04 GMT
Author: tabish
Date: Sun Jul 29 15:01:00 2007
New Revision: 560827

URL: http://svn.apache.org/viewvc?view=rev&rev=560827
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/Character.cpp
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Character.h
    activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/lang/Integer.cpp

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=560827&r1=560826&r2=560827
==============================================================================
--- 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 Sun Jul 29 15:01:00
2007
@@ -35,3 +35,19 @@
 std::string Character::toString() const {
     return string( 1, this->value );
 }
+
+////////////////////////////////////////////////////////////////////////////////
+int Character::digit( char c, int radix ) {
+    if( radix >= MIN_RADIX && radix <= MAX_RADIX ) {
+        int result = -1;
+        if( '0' <= c && c <= '9' ) {
+            result = c - '0';
+        } else if( 'a' <= c && c <= 'z' ) {
+            result = c - ('a' - 10);
+        } else if( 'A' <= c && c <= 'Z' ) {
+            result = c - ('A' - 10);
+        }
+        return result < radix ? result : -1;
+    }
+    return -1;
+}

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=560827&r1=560826&r2=560827
==============================================================================
--- 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 Sun Jul 29 15:01:00
2007
@@ -196,6 +196,30 @@
             return isLetter(c) || isDigit(c);
         }
 
+        /**
+         * Returns the numeric value of the character ch in the specified radix.
+         *
+         * If the radix is not in the range MIN_RADIX <= radix <= MAX_RADIX or if
+         * the value of ch is not a valid digit in the specified radix, -1 is
+         * returned. A character is a valid digit if at least one of the following
+         * is true:
+         *
+         *    * The method isDigit is true of the character and the single-character
+         *      decomposition is less than the specified radix. In this case the
+         *      decimal digit value is returned.
+         *    * The character is one of the uppercase Latin letters 'A' through 'Z'
+         *      and its code is less than radix + 'A' - 10. In this case,
+         *      ch - 'A' + 10 is returned.
+         *    * The character is one of the lowercase Latin letters 'a' through 'z'
+         *      and its code is less than radix + 'a' - 10. In this case,
+         *      ch - 'a' + 10 is returned.
+         *
+         * @param c - the char to be converted
+         * @param radix - the radix of the number
+         * @returns the numeric value of the number represented in the given radix
+         */
+        static int digit( char c, int radix );
+
     };
 
 }}

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=560827&r1=560826&r2=560827
==============================================================================
--- 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 Sun Jul 29 15:01:00
2007
@@ -15,7 +15,8 @@
  * limitations under the License.
  */
 
-#include "Integer.h"
+#include <decaf/lang/Integer.h>
+#include <decaf/lang/Character.h>
 #include <sstream>
 
 using namespace decaf;
@@ -84,7 +85,7 @@
 
     while( offset < length ) {
         //TODO
-        int digit = 0;//Character.digit(string.charAt(offset++), radix);
+        int digit = Character::digit( value[offset++], radix );
         if( digit == -1 ) {
             throw NumberFormatException(
                 __FILE__, __LINE__,



Mime
View raw message