activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1447831 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main: ./ activemq/commands/ activemq/util/ decaf/internal/net/ssl/openssl/ decaf/internal/util/ decaf/lang/ decaf/net/ decaf/util/
Date Tue, 19 Feb 2013 17:22:37 GMT
Author: tabish
Date: Tue Feb 19 17:22:37 2013
New Revision: 1447831

URL: http://svn.apache.org/r1447831
Log:
Remove some more APR usage an internalize.

Added:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/StringUtils.cpp
  (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/StringUtils.h  
(with props)
Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/IdGenerator.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Boolean.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Character.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/URI.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am?rev=1447831&r1=1447830&r2=1447831&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Tue Feb 19 17:22:37 2013
@@ -360,6 +360,7 @@ cc_sources = \
     decaf/internal/util/HexStringParser.cpp \
     decaf/internal/util/Resource.cpp \
     decaf/internal/util/ResourceLifecycleManager.cpp \
+    decaf/internal/util/StringUtils.cpp \
     decaf/internal/util/TimerTaskHeap.cpp \
     decaf/internal/util/concurrent/ExecutorsSupport.cpp \
     decaf/internal/util/concurrent/SynchronizableImpl.cpp \
@@ -963,6 +964,7 @@ h_sources = \
     decaf/internal/util/HexStringParser.h \
     decaf/internal/util/Resource.h \
     decaf/internal/util/ResourceLifecycleManager.h \
+    decaf/internal/util/StringUtils.h \
     decaf/internal/util/TimerTaskHeap.h \
     decaf/internal/util/concurrent/Atomics.h \
     decaf/internal/util/concurrent/ExecutorsSupport.h \

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.cpp?rev=1447831&r1=1447830&r2=1447831&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/commands/ActiveMQDestination.cpp
Tue Feb 19 17:22:37 2013
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 #include <activemq/commands/ActiveMQDestination.h>
-#include <decaf/lang/exceptions/NullPointerException.h>
 #include <activemq/util/URISupport.h>
 #include <activemq/util/CMSExceptionSupport.h>
 #include <activemq/util/AdvisorySupport.h>
@@ -27,12 +26,13 @@
 
 #include <decaf/util/StringTokenizer.h>
 #include <decaf/util/StlSet.h>
-
-#include <apr_strings.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
+#include <decaf/internal/util/StringUtils.h>
 
 using namespace activemq;
 using namespace activemq::util;
 using namespace activemq::commands;
+using namespace decaf::internal::util;
 using namespace decaf::util;
 using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
@@ -268,7 +268,7 @@ int ActiveMQDestination::compareTo(const
         return 0;
     }
 
-    int valueComp = apr_strnatcmp(this->getPhysicalName().c_str(), value.getPhysicalName().c_str());
+    int valueComp = StringUtils::compare(this->getPhysicalName().c_str(), value.getPhysicalName().c_str());
     if (valueComp != 0) {
         return valueComp;
     }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/IdGenerator.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/IdGenerator.cpp?rev=1447831&r1=1447830&r2=1447831&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/IdGenerator.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/util/IdGenerator.cpp Tue Feb
19 17:22:37 2013
@@ -24,10 +24,9 @@
 #include <decaf/net/ServerSocket.h>
 #include <decaf/util/concurrent/Mutex.h>
 
+#include <decaf/internal/util/StringUtils.h>
 #include <decaf/lang/exceptions/RuntimeException.h>
 
-#include <apr_strings.h>
-
 using namespace activemq;
 using namespace activemq::util;
 using namespace decaf;
@@ -36,6 +35,7 @@ using namespace decaf::lang::exceptions;
 using namespace decaf::net;
 using namespace decaf::util;
 using namespace decaf::util::concurrent;
+using namespace decaf::internal::util;
 
 ////////////////////////////////////////////////////////////////////////////////
 IdGeneratorKernel* IdGenerator::kernel = NULL;
@@ -152,7 +152,7 @@ int IdGenerator::compare(const std::stri
 
     if (!seed1.empty() && !seed2.empty()) {
 
-        result = apr_strnatcmp(seed1.c_str(), seed2.c_str());
+        result = StringUtils::compare(seed1.c_str(), seed2.c_str());
 
         if (result == 0) {
             long long count1 = IdGenerator::getSequenceFromId(id1);

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.cpp?rev=1447831&r1=1447830&r2=1447831&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/net/ssl/openssl/OpenSSLSocket.cpp
Tue Feb 19 17:22:37 2013
@@ -24,14 +24,13 @@
     #include <openssl/bio.h>
 #endif
 
-#include <apr_strings.h>
-
 #include <decaf/net/SocketImpl.h>
 #include <decaf/io/IOException.h>
 #include <decaf/net/SocketException.h>
 #include <decaf/lang/Boolean.h>
 #include <decaf/lang/exceptions/NullPointerException.h>
 #include <decaf/lang/exceptions/IndexOutOfBoundsException.h>
+#include <decaf/internal/util/StringUtils.h>
 #include <decaf/internal/net/SocketFileDescriptor.h>
 #include <decaf/internal/net/ssl/openssl/OpenSSLParameters.h>
 #include <decaf/internal/net/ssl/openssl/OpenSSLSocketException.h>
@@ -47,6 +46,7 @@ using namespace decaf::net;
 using namespace decaf::net::ssl;
 using namespace decaf::util::concurrent;
 using namespace decaf::internal;
+using namespace decaf::internal::util;
 using namespace decaf::internal::net;
 using namespace decaf::internal::net::ssl;
 using namespace decaf::internal::net::ssl::openssl;
@@ -666,7 +666,7 @@ void OpenSSLSocket::verifyServerCert( co
         X509_EXTENSION* extension = X509_get_ext( cert, ix );
         const char* extensionName = OBJ_nid2sn( OBJ_obj2nid( X509_EXTENSION_get_object( extension
) ) );
 
-        if( apr_strnatcmp( "subjectAltName", extensionName ) == 0 ) {
+        if( StringUtils::compare( "subjectAltName", extensionName ) == 0 ) {
 
             X509V3_EXT_METHOD* method = (X509V3_EXT_METHOD*)X509V3_EXT_get( extension );
             if( method == NULL ) {
@@ -683,8 +683,8 @@ void OpenSSLSocket::verifyServerCert( co
 
             for( int iy = 0; iy < sk_CONF_VALUE_num( confValue ); iy++ ) {
                 value = sk_CONF_VALUE_value( confValue, iy );
-                if( ( apr_strnatcmp( value->name, "DNS" ) == 0 ) &&
-                      apr_strnatcmp( value->value, serverName.c_str() ) == 0 ) {
+                if( ( StringUtils::compare( value->name, "DNS" ) == 0 ) &&
+                      StringUtils::compare( value->value, serverName.c_str() ) == 0 )
{
 
                     // Found it.
                     return;
@@ -698,7 +698,7 @@ void OpenSSLSocket::verifyServerCert( co
 
     if( subject != NULL && X509_NAME_get_text_by_NID( subject, NID_commonName, buffer,
256 ) > 0 ) {
         buffer[255] = 0;
-        if( apr_strnatcmp( buffer, serverName.c_str() ) == 0 ) {
+        if( StringUtils::compare( buffer, serverName.c_str() ) == 0 ) {
             return;
         }
     }

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/StringUtils.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/StringUtils.cpp?rev=1447831&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/StringUtils.cpp
(added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/StringUtils.cpp
Tue Feb 19 17:22:37 2013
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicurLeftble law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "StringUtils.h"
+
+#include <decaf/lang/Character.h>
+
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::internal;
+using namespace decaf::internal::util;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+    int compareRight(char const* left, char const* right) {
+
+        int bias = 0;
+
+        // The longest run of digits wins.  That aside, the greatest
+        // value wins, but we don't know that it will until we've scanned
+        // both numbers to know that they have the same magnitude, so we
+        // remember it in BIAS.
+        for (;; left++, ++right) {
+            if (!Character::isDigit(*left) && !Character::isDigit(*right)) {
+                break;
+            } else if (!Character::isDigit(*left)) {
+                return -1;
+            } else if (!Character::isDigit(*right)) {
+                return +1;
+            } else if (*left < *right) {
+                if (!bias) bias = -1;
+            } else if (*left > *right) {
+                if (!bias) bias = +1;
+            } else if (!*left && !*right) {
+                break;
+            }
+        }
+
+        return bias;
+    }
+
+    int compareLeft(char const* left, char const* right) {
+        // Compare two left-aligned numbers: the first to have a
+        // different value wins.
+        for (;; left++, right++) {
+            if (!Character::isDigit(*left) && !Character::isDigit(*right)) {
+                break;
+            } else if (!Character::isDigit(*left)) {
+                return -1;
+            } else if (!Character::isDigit(*right)) {
+                return +1;
+            } else if (*left < *right) {
+                return -1;
+            } else if (*left > *right) {
+                return +1;
+            }
+        }
+
+        return 0;
+    }
+
+    int doCompare(char const* left, char const* right, bool ignoreCase) {
+        int lIndex = 0;
+        int rIndex = 0;
+        char curLeft = 0;
+        char curRight = 0;
+
+        bool fractional = false;
+        int result = 0;
+
+        while (true) {
+            curLeft = left[lIndex];
+            curRight = right[rIndex];
+
+            while (Character::isWhitespace(curLeft)) {
+                curLeft = left[++lIndex];
+            }
+
+            while (Character::isWhitespace(curRight)) {
+                curRight = left[++rIndex];
+            }
+
+            if (Character::isDigit(curLeft) && Character::isDigit(curRight)) {
+                fractional = (curLeft == '0' || curRight == '0');
+
+                if (fractional) {
+                    if ((result = compareLeft(left + lIndex, right + rIndex)) != 0) {
+                        return result;
+                    }
+                } else {
+                    if ((result = compareRight(left + lIndex, right + rIndex)) != 0) {
+                        return result;
+                    }
+                }
+            }
+
+            if (!curLeft && !curRight) {
+                return 0;
+            }
+
+            if (ignoreCase) {
+                curLeft = Character::toUpperCase(curLeft);
+                curRight = Character::toUpperCase(curRight);
+            }
+
+            if (curLeft < curRight) {
+                return -1;
+            } else if (curLeft > curRight) {
+                return +1;
+            }
+
+            ++lIndex;
+            ++rIndex;
+        }
+
+        return 0;
+    }
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int StringUtils::compareIgnoreCase(const char* left, const char* right) {
+    return doCompare(left, right, true);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int StringUtils::compare(const char* left, const char* right) {
+    return doCompare(left, right, false);
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/StringUtils.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/StringUtils.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/StringUtils.h?rev=1447831&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/StringUtils.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/StringUtils.h Tue
Feb 19 17:22:37 2013
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _DECAF_INTERNAL_UTIL_STRINGUTILS_H_
+#define STRINGUTILS_H_
+
+#include <decaf/util/Config.h>
+
+namespace decaf {
+namespace internal {
+namespace util {
+
+    class StringUtils {
+    private:
+
+        StringUtils(const StringUtils&);
+        StringUtils operator= (const StringUtils&);
+
+    private:
+
+        StringUtils() {}
+
+    public:
+
+        virtual ~StringUtils() {}
+
+        /**
+         * Perform a comparison between two strings using natural ordering and ignoring case.
+         *
+         * @param left
+         *      The left-hand string of the comparison.
+         * @param right
+         *      The right-hand string of the comparison.
+         *
+         * @returns a negative integer, zero, or a positive integer as the specified string
+         *          is greater than, equal to, or less than this String, ignoring case considerations.
+         */
+        static int compareIgnoreCase(const char* left, const char* right);
+
+        /**
+         * Perform a comparison between two strings using natural ordering case is not ignored
+         * here, so two otherwise equal string will not match if case differes.
+         *
+         * @param left
+         *      The left-hand string of the comparison.
+         * @param right
+         *      The right-hand string of the comparison.
+         *
+         * @returns a negative integer, zero, or a positive integer as the specified string
+         *          is greater than, equal to, or less than this String, ignoring case considerations.
+         */
+        static int compare(const char* left, const char* right);
+
+    };
+
+}}}
+
+#endif /* _DECAF_INTERNAL_UTIL_STRINGUTILS_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/StringUtils.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Boolean.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Boolean.cpp?rev=1447831&r1=1447830&r2=1447831&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Boolean.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Boolean.cpp Tue Feb 19 17:22:37
2013
@@ -18,10 +18,12 @@
 #include "Boolean.h"
 #include <sstream>
 #include <apr.h>
-#include <apr_strings.h>
+
+#include <decaf/internal/util/StringUtils.h>
 
 using namespace decaf;
 using namespace decaf::lang;
+using namespace decaf::internal::util;
 
 ////////////////////////////////////////////////////////////////////////////////
 const Boolean Boolean::_FALSE(false);
@@ -95,7 +97,7 @@ Boolean Boolean::valueOf(bool value) {
 
 ////////////////////////////////////////////////////////////////////////////////
 bool Boolean::parseBoolean(const std::string& value) {
-    return apr_strnatcasecmp(value.c_str(), "true") == 0;
+    return StringUtils::compareIgnoreCase(value.c_str(), "true") == 0;
 }
 
 ////////////////////////////////////////////////////////////////////////////////

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Character.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Character.h?rev=1447831&r1=1447830&r2=1447831&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Character.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Character.h Tue Feb 19 17:22:37
2013
@@ -289,7 +289,43 @@ namespace lang{
          * @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 );
+        static int digit(char c, int radix);
+
+        /**
+         * Returns the lower case equivalent for the specified character if the
+         * character is an upper case letter. Otherwise, the specified character is
+         * returned unchanged.
+         *
+         * @param value
+         *      the character to convert if needed.
+         * @return if value is an upper case character then its lower case
+         *         counterpart, otherwise just returns value unchanged.
+         */
+        static char toLowerCase(char value) {
+            if ('A' <= value && value <= 'Z') {
+                return (char) (value + ('a' - 'A'));
+            }
+
+            return value;
+        }
+
+        /**
+         * Returns the upper case equivalent for the specified character if the
+         * character is a lower case letter. Otherwise, the specified character is
+         * returned unchanged.
+         *
+         * @param value
+         *      the character to convert to upper case if needed.
+         * @return if value is a lower case character then its upper case
+         *         counterpart, otherwise just returns value unchanged.
+         */
+        static char toUpperCase(char value) {
+            if ('a' <= value && value <= 'z') {
+                return (char) (value - ('a' - 'A'));
+            }
+
+            return value;
+        }
 
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/URI.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/URI.cpp?rev=1447831&r1=1447830&r2=1447831&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/URI.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/URI.cpp Tue Feb 19 17:22:37
2013
@@ -17,11 +17,10 @@
 
 #include "URI.h"
 
-#include <apr_strings.h>
-#include <apr_lib.h>
 #include <decaf/lang/Integer.h>
+#include <decaf/lang/Character.h>
 #include <decaf/internal/net/URIHelper.h>
-
+#include <decaf/internal/util/StringUtils.h>
 #include <decaf/internal/net/URIEncoderDecoder.h>
 
 using namespace std;
@@ -29,6 +28,7 @@ using namespace decaf;
 using namespace decaf::net;
 using namespace decaf::internal;
 using namespace decaf::internal::net;
+using namespace decaf::internal::util;
 using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 
@@ -271,7 +271,7 @@ int URI::compareTo( const URI& uri ) con
     } else if( this->uri.getScheme() != "" && uri.getScheme() == "" ) {
         return 1;
     } else if( this->uri.getScheme() != "" && uri.getScheme() != "" ) {
-        ret = apr_strnatcasecmp( this->uri.getScheme().c_str(), uri.getScheme().c_str()
);
+        ret = StringUtils::compareIgnoreCase(this->uri.getScheme().c_str(), uri.getScheme().c_str());
         if( ret != 0 ) {
             return ret > 0 ? 1 : -1;
         }
@@ -283,8 +283,8 @@ int URI::compareTo( const URI& uri ) con
     } else if( this->uri.isOpaque() && !uri.isOpaque() ) {
         return 1;
     } else if( this->uri.isOpaque() && uri.isOpaque() ) {
-        ret = apr_strnatcmp( this->getSchemeSpecificPart().c_str(),
-                             uri.getSchemeSpecificPart().c_str() );
+        ret = StringUtils::compare(this->getSchemeSpecificPart().c_str(),
+                                   uri.getSchemeSpecificPart().c_str());
         if( ret != 0 ) {
             return ret > 0 ? 1 : -1;
         }
@@ -307,15 +307,15 @@ int URI::compareTo( const URI& uri ) con
                 } else if( this->getUserInfo() == "" && uri.getUserInfo() != ""
) {
                     return -1;
                 } else if( this->getUserInfo() != "" && uri.getUserInfo() != ""
) {
-                    ret = apr_strnatcmp( this->getUserInfo().c_str(),
-                                         uri.getUserInfo().c_str() );
+                    ret = StringUtils::compare(this->getUserInfo().c_str(),
+                                               uri.getUserInfo().c_str());
                     if( ret != 0 ) {
                         return ret > 0 ? 1 : -1;
                     }
                 }
 
                 // userinfo's are the same, compare hostname
-                ret = apr_strnatcasecmp( this->uri.getHost().c_str(), uri.getHost().c_str()
);
+                ret = StringUtils::compareIgnoreCase(this->uri.getHost().c_str(), uri.getHost().c_str());
                 if( ret != 0 ) {
                     return ret > 0 ? 1 : -1;
                 }
@@ -328,8 +328,7 @@ int URI::compareTo( const URI& uri ) con
             } else {
 
                 // one or both are registry based, compare the whole authority
-                ret = apr_strnatcmp( this->uri.getAuthority().c_str(),
-                                     uri.getAuthority().c_str() );
+                ret = StringUtils::compare(this->uri.getAuthority().c_str(), uri.getAuthority().c_str());
                 if( ret != 0 ) {
                     return ret > 0 ? 1 : -1;
                 }
@@ -338,7 +337,7 @@ int URI::compareTo( const URI& uri ) con
 
         // authorities are the same
         // compare paths
-        ret = apr_strnatcmp( this->getPath().c_str(), uri.getPath().c_str() );
+        ret = StringUtils::compare(this->getPath().c_str(), uri.getPath().c_str());
         if( ret != 0 ) {
             return ret > 0 ? 1 : -1;
         }
@@ -349,7 +348,7 @@ int URI::compareTo( const URI& uri ) con
         } else if( this->getQuery() == "" && uri.getQuery() != "" ) {
             return -1;
         } else if( this->getQuery() != "" && uri.getQuery() != "" ) {
-            ret = apr_strnatcmp( this->getQuery().c_str(), uri.getQuery().c_str() );
+            ret = StringUtils::compare(this->getQuery().c_str(), uri.getQuery().c_str());
             if( ret != 0 ) {
                 return ret > 0 ? 1 : -1;
             }
@@ -362,7 +361,7 @@ int URI::compareTo( const URI& uri ) con
     } else if( this->getFragment() == "" && uri.getFragment() != "" ) {
         return -1;
     } else if( this->getFragment() != "" && uri.getFragment() != "" ) {
-        ret = apr_strnatcmp( this->getFragment().c_str(), uri.getFragment().c_str() );
+        ret = StringUtils::compare(this->getFragment().c_str(), uri.getFragment().c_str());
         if( ret != 0 ) {
             return ret > 0 ? 1 : -1;
         }
@@ -394,7 +393,7 @@ bool URI::equals( const URI& uri ) const
 
     } else if( uri.uri.getScheme() != "" && this->uri.getScheme() != "" ) {
 
-        if( apr_strnatcasecmp( uri.uri.getScheme().c_str(), this->uri.getScheme().c_str()
) != 0 ) {
+        if( StringUtils::compareIgnoreCase(uri.uri.getScheme().c_str(), this->uri.getScheme().c_str()
) != 0) {
             return false;
         }
     }
@@ -442,7 +441,7 @@ bool URI::equals( const URI& uri ) const
 
             } else { // uri.host != "" && host != "", so server-based
 
-                if( apr_strnatcasecmp( uri.uri.getHost().c_str(), this->uri.getHost().c_str()
) != 0 ) {
+                if( StringUtils::compareIgnoreCase(uri.uri.getHost().c_str(), this->uri.getHost().c_str()
) != 0) {
                     return false;
                 }
 
@@ -544,7 +543,7 @@ std::string URI::decode( const std::stri
 bool URI::equalsHexCaseInsensitive( const std::string& first, const std::string&
second ) const {
 
     if( first.find( '%' ) != second.find( '%' ) ) {
-        return apr_strnatcmp( first.c_str(), second.c_str() ) == 0;
+        return StringUtils::compare(first.c_str(), second.c_str()) == 0;
     }
 
     std::size_t index = 0;
@@ -560,8 +559,8 @@ bool URI::equalsHexCaseInsensitive( cons
             return false;
         }
 
-        match = apr_strnatcasecmp( first.substr( index + 1, 3 ).c_str(),
-                                   second.substr( index + 1, 3 ).c_str() ) == 0;
+        match = StringUtils::compareIgnoreCase(first.substr(index + 1, 3).c_str(),
+                                               second.substr(index + 1, 3).c_str()) == 0;
 
         if( !match ) {
             return false;
@@ -592,7 +591,7 @@ std::string URI::convertHexToLowerCase( 
         string temp = s.substr( index + 1, 3 );
 
         for( size_t i = 0; i < temp.length(); ++i ) {
-            result.append( 1, (char)apr_tolower( temp.at(i) ) );
+            result.append(1, Character::toLowerCase(temp.at(i)));
         }
 
         index += 3;

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.cpp?rev=1447831&r1=1447830&r2=1447831&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.cpp Tue Feb 19 17:22:37
2013
@@ -16,10 +16,10 @@
  */
 
 #include "UUID.h"
-#include <apr_strings.h>
 #include <stdio.h>
 #include <apr_md5.h>
 #include <apr_uuid.h>
+#include <decaf/internal/util/StringUtils.h>
 #include <decaf/lang/exceptions/RuntimeException.h>
 #include <decaf/lang/exceptions/UnsupportedOperationException.h>
 #include <decaf/lang/exceptions/IllegalArgumentException.h>
@@ -27,6 +27,7 @@
 using namespace std;
 using namespace decaf;
 using namespace decaf::util;
+using namespace decaf::internal::util;
 using namespace decaf::lang;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -174,7 +175,7 @@ UUID::~UUID() {
 
 ////////////////////////////////////////////////////////////////////////////////
 int UUID::compareTo(const UUID& value) const {
-    return apr_strnatcmp(this->toString().c_str(), value.toString().c_str());
+    return StringUtils::compare(this->toString().c_str(), value.toString().c_str());
 }
 
 ////////////////////////////////////////////////////////////////////////////////



Mime
View raw message