activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r550599 - in /activemq/activemq-cpp/trunk/src: main/Makefile.am main/activemq/util/Endian.cpp main/activemq/util/Endian.h test/Makefile.am test/activemq/util/Endian.cpp test/activemq/util/Endian.h
Date Mon, 25 Jun 2007 20:48:14 GMT
Author: tabish
Date: Mon Jun 25 13:48:13 2007
New Revision: 550599

URL: http://svn.apache.org/viewvc?view=rev&rev=550599
Log:
Cleaning up unused code from the library, moving to test until it can be removed completely.

Added:
    activemq/activemq-cpp/trunk/src/test/activemq/util/Endian.cpp
    activemq/activemq-cpp/trunk/src/test/activemq/util/Endian.h
Removed:
    activemq/activemq-cpp/trunk/src/main/activemq/util/Endian.cpp
    activemq/activemq-cpp/trunk/src/main/activemq/util/Endian.h
Modified:
    activemq/activemq-cpp/trunk/src/main/Makefile.am
    activemq/activemq-cpp/trunk/src/test/Makefile.am

Modified: activemq/activemq-cpp/trunk/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/Makefile.am?view=diff&rev=550599&r1=550598&r2=550599
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/main/Makefile.am Mon Jun 25 13:48:13 2007
@@ -94,7 +94,6 @@
     activemq/transport/filters/LoggingTransportFactory.cpp \
     activemq/util/StringTokenizer.cpp \
     activemq/util/Guid.cpp \
-    activemq/util/Endian.cpp \
     activemq/util/Date.cpp \
     activemq/util/Math.cpp \
     activemq/util/Random.cpp \
@@ -276,7 +275,6 @@
     activemq/transport/filters/TcpTransportFactory.h \
     activemq/transport/filters/LoggingTransport.h \
     activemq/transport/filters/LoggingTransportFactory.h \
-    activemq/util/Endian.h \
     activemq/util/Number.h \
     activemq/util/Config.h \
     activemq/util/Character.h \

Modified: activemq/activemq-cpp/trunk/src/test/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/Makefile.am?view=diff&rev=550599&r1=550598&r2=550599
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/test/Makefile.am Mon Jun 25 13:48:13 2007
@@ -82,6 +82,7 @@
   activemq/transport/TransportFactoryMapTest.cpp \
   activemq/util/BooleanTest.cpp \
   activemq/util/DateTest.cpp \
+  activemq/util/Endian.cpp \
   activemq/util/GuidTest.cpp \
   activemq/util/IntegerTest.cpp \
   activemq/util/LongTest.cpp \

Added: activemq/activemq-cpp/trunk/src/test/activemq/util/Endian.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/util/Endian.cpp?view=auto&rev=550599
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/util/Endian.cpp (added)
+++ activemq/activemq-cpp/trunk/src/test/activemq/util/Endian.cpp Mon Jun 25 13:48:13 2007
@@ -0,0 +1,116 @@
+/*
+ * 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.
+ */
+
+#include "Endian.h"
+#include <activemq/util/Config.h>
+#include <string.h>
+
+using namespace activemq::util;
+
+////////////////////////////////////////////////////////////////////////////////
+void Endian::byteSwap(unsigned char* data, int dataLength) {
+            
+    #ifdef WORDS_BIGENDIAN
+        return;
+    #endif
+    
+    for (int i = 0; i<dataLength/2; i++) {
+        unsigned char temp = data[i];
+        data[i] = data[dataLength-1-i];
+        data[dataLength-1-i] = temp;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned char Endian::byteSwap( unsigned char value ){
+    
+    #ifdef WORDS_BIGENDIAN
+        return value;
+    #endif
+
+    return value;            
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned short Endian::byteSwap( unsigned short value ){
+
+    #ifdef WORDS_BIGENDIAN
+        return value;
+    #endif
+
+    return (((unsigned short)value & 0xFF00 ) >> 8 ) |
+           (((unsigned short)value & 0x00FF ) << 8 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned int Endian::byteSwap( unsigned int value ){
+
+    #ifdef WORDS_BIGENDIAN
+        return value;
+    #endif
+
+    return (((unsigned int)value & 0xFF000000 ) >> 24 ) |
+           (((unsigned int)value & 0x00FF0000 ) >> 8 )  |
+           (((unsigned int)value & 0x0000FF00 ) << 8 )  |
+           (((unsigned int)value & 0x000000FF ) << 24 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+unsigned long long Endian::byteSwap( unsigned long long value ){
+
+    #ifdef WORDS_BIGENDIAN
+        return value;
+    #endif
+
+    return (((unsigned long long)value & 0xFF00000000000000ULL ) >> 56 ) |
+           (((unsigned long long)value & 0x00FF000000000000ULL ) >> 40 ) |
+           (((unsigned long long)value & 0x0000FF0000000000ULL ) >> 24 ) |
+           (((unsigned long long)value & 0x000000FF00000000ULL ) >> 8 )  |
+           (((unsigned long long)value & 0x00000000FF000000ULL ) << 8 )  |
+           (((unsigned long long)value & 0x0000000000FF0000ULL ) << 24 ) |
+           (((unsigned long long)value & 0x000000000000FF00ULL ) << 40 ) |
+           (((unsigned long long)value & 0x00000000000000FFULL ) << 56 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+float Endian::byteSwap( float value ){
+
+    #ifdef WORDS_BIGENDIAN
+        return value;
+    #endif
+
+    unsigned int lvalue = 0;
+    memcpy( &lvalue, &value, sizeof( float ) );
+    lvalue = byteSwap( lvalue );
+    memcpy( &value, &lvalue, sizeof( unsigned int ) );
+    return value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+double Endian::byteSwap( double value ){
+
+    #ifdef WORDS_BIGENDIAN
+        return value;
+    #endif
+
+    unsigned long long lvalue = 0;
+    memcpy( &lvalue, &value, sizeof( double ) );
+    lvalue = byteSwap( lvalue );
+    memcpy( &value, &lvalue, sizeof( unsigned long long ) );
+    return value;
+}
+

Added: activemq/activemq-cpp/trunk/src/test/activemq/util/Endian.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/util/Endian.h?view=auto&rev=550599
==============================================================================
--- activemq/activemq-cpp/trunk/src/test/activemq/util/Endian.h (added)
+++ activemq/activemq-cpp/trunk/src/test/activemq/util/Endian.h Mon Jun 25 13:48:13 2007
@@ -0,0 +1,43 @@
+/*
+ * 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 ACTIVEMQ_UTIL_ENDIAN_H
+#define ACTIVEMQ_UTIL_ENDIAN_H
+
+namespace activemq{
+namespace util{
+    
+    class Endian{
+    public:
+    
+        static void byteSwap(unsigned char* data, int dataLength);
+        
+        static unsigned char byteSwap( unsigned char value );
+        
+        static unsigned short byteSwap( unsigned short value );
+        
+        static unsigned int byteSwap( unsigned int value );
+        
+        static unsigned long long byteSwap( unsigned long long value );
+
+        static float byteSwap( float value );
+        
+        static double byteSwap( double value );
+    };
+    
+}}
+
+#endif /*ACTIVEMQ_UTIL_ENDIAN_H*/



Mime
View raw message