activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1457307 [2/6] - in /activemq/activemq-cpp/trunk/activemq-cpp/src: main/ main/decaf/internal/ main/decaf/internal/net/ main/decaf/internal/security/ main/decaf/internal/security/provider/ main/decaf/internal/security/provider/crypto/ main/d...
Date Sat, 16 Mar 2013 21:14:12 GMT
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD5MessageDigestSpi.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD5MessageDigestSpi.cpp?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD5MessageDigestSpi.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD5MessageDigestSpi.cpp Sat Mar 16 21:14:01 2013
@@ -0,0 +1,498 @@
+/*
+ * This is work is derived from material Copyright RSA Data Security, Inc.
+ *
+ * The RSA copyright statement and Licence for that original material is
+ * included below. This is followed by the Apache copyright statement and
+ * licence for the modifications made to that material.
+ */
+
+/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
+ */
+
+/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+   rights reserved.
+
+   License to copy and use this software is granted provided that it
+   is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+   Algorithm" in all material mentioning or referencing this software
+   or this function.
+
+   License is also granted to make and use derivative works provided
+   that such works are identified as "derived from the RSA Data
+   Security, Inc. MD5 Message-Digest Algorithm" in all material
+   mentioning or referencing the derived work.
+
+   RSA Data Security, Inc. makes no representations concerning either
+   the merchantability of this software or the suitability of this
+   software for any particular purpose. It is provided "as is"
+   without express or implied warranty of any kind.
+
+   These notices must be retained in any copies of any part of this
+   documentation and/or software.
+ */
+
+/* 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.
+ */
+
+/*
+ * The encode() routine uses much code obtained from the FreeBSD 3.0
+ * MD5 crypt() function, which is licenced as follows:
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * <phk@login.dknet.dk> wrote this file.  As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
+ * ----------------------------------------------------------------------------
+ */
+
+#include "MD5MessageDigestSpi.h"
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <decaf/lang/System.h>
+#include <decaf/security/DigestException.h>
+
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::security;
+using namespace decaf::internal;
+using namespace decaf::internal::security;
+using namespace decaf::internal::security::provider;
+using namespace decaf::internal::security::provider::crypto;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+#define DECAF_MD5_DIGESTSIZE 16
+
+#define S11 7
+#define S12 12
+#define S13 17
+#define S14 22
+#define S21 5
+#define S22 9
+#define S23 14
+#define S24 20
+#define S31 4
+#define S32 11
+#define S33 16
+#define S34 23
+#define S41 6
+#define S42 10
+#define S43 15
+#define S44 21
+
+static const unsigned char PADDING[64] =
+{
+    0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+// F, G, H and I are basic MD5 functions.
+#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
+#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define I(x, y, z) ((y) ^ ((x) | (~z)))
+
+// ROTATE_LEFT rotates x left n bits.
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
+// Rotation is separate from addition to prevent recomputation.
+#define FF(a, b, c, d, x, s, ac) { \
+    (a) += F ((b), (c), (d)) + (x) + (unsigned int)(ac); \
+    (a) = ROTATE_LEFT ((a), (s)); \
+    (a) += (b); \
+}
+#define GG(a, b, c, d, x, s, ac) { \
+    (a) += G ((b), (c), (d)) + (x) + (unsigned int)(ac); \
+    (a) = ROTATE_LEFT ((a), (s)); \
+    (a) += (b); \
+}
+#define HH(a, b, c, d, x, s, ac) { \
+    (a) += H ((b), (c), (d)) + (x) + (unsigned int)(ac); \
+    (a) = ROTATE_LEFT ((a), (s)); \
+    (a) += (b); \
+}
+#define II(a, b, c, d, x, s, ac) { \
+    (a) += I ((b), (c), (d)) + (x) + (unsigned int)(ac); \
+    (a) = ROTATE_LEFT ((a), (s)); \
+    (a) += (b); \
+}
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+namespace decaf {
+namespace internal {
+namespace security {
+namespace provider {
+namespace crypto {
+
+    class MD5MessageDigestSpiImpl {
+    public:
+
+        // state (ABCD)
+        apr_uint32_t state[4];
+        // number of bits, modulo 2^64 (lsb first)
+        unsigned int count[2];
+        // Digest Input buffer
+        unsigned char buffer[64];
+
+    public:
+
+        MD5MessageDigestSpiImpl() : state(), count(), buffer() {
+            reset();
+        }
+
+        void reset() {
+            count[0] = count[1] = 0;
+
+            // Load magic initialization constants.
+            state[0] = 0x67452301;
+            state[1] = 0xefcdab89;
+            state[2] = 0x98badcfe;
+            state[3] = 0x10325476;
+
+            memset(buffer, 0, 64);
+        }
+
+        // MD5 block update operation. Continues an MD5 message-digest
+        // operation, processing another message block, and updating the
+        // context.
+        void update(const unsigned char* vinput, int inputLen) {
+            const unsigned char *input = vinput;
+            int i;
+            int idx;
+            int partLen;
+
+            // Compute number of bytes mod 64
+            idx = (unsigned int)((count[0] >> 3) & 0x3F);
+
+            // Update number of bits
+            if ((count[0] += ((unsigned int)inputLen << 3)) < ((unsigned int)inputLen << 3)) {
+                count[1]++;
+            }
+
+            count[1] += (unsigned int)inputLen >> 29;
+
+            partLen = 64 - idx;
+
+            // Transform as many times as possible.
+            if (inputLen >= partLen) {
+                memcpy(&buffer[idx], input, partLen);
+                MD5Transform(state, buffer);
+
+                for (i = partLen; i + 63 < inputLen; i += 64) {
+                    MD5Transform(state, &input[i]);
+                }
+
+                idx = 0;
+            } else {
+                i = 0;
+            }
+
+            // Buffer remaining input
+            memcpy(&buffer[idx], &input[i], inputLen - i);
+        }
+
+        // MD5 finalization. Ends an MD5 message-digest operation, writing the
+        // the message digest and then reset.
+        void finalize(unsigned char digest[DECAF_MD5_DIGESTSIZE]) {
+            unsigned char bits[8];
+            unsigned int idx;
+            unsigned int padLen;
+
+            // Save number of bits
+            encode(bits, count, 8);
+
+            // Pad out to 56 mod 64.
+            idx = (unsigned int)((count[0] >> 3) & 0x3f);
+            padLen = (idx < 56) ? (56 - idx) : (120 - idx);
+            update(PADDING, padLen);
+
+            // Append length (before padding)
+            update(bits, 8);
+
+            // Store state in digest
+            encode(digest, state, DECAF_MD5_DIGESTSIZE);
+
+            reset();
+        }
+
+    private:
+
+        // MD5 basic transformation. Transforms state based on block.
+        static void MD5Transform(unsigned int state[4], const unsigned char block[64]) {
+            unsigned int a = state[0];
+            unsigned int b = state[1];
+            unsigned int c = state[2];
+            unsigned int d = state[3];
+            unsigned int x[DECAF_MD5_DIGESTSIZE];
+
+            decode(x, block, 64);
+
+            /* Round 1 */
+            FF(a, b, c, d, x[0],  S11, 0xd76aa478); /* 1 */
+            FF(d, a, b, c, x[1],  S12, 0xe8c7b756); /* 2 */
+            FF(c, d, a, b, x[2],  S13, 0x242070db); /* 3 */
+            FF(b, c, d, a, x[3],  S14, 0xc1bdceee); /* 4 */
+            FF(a, b, c, d, x[4],  S11, 0xf57c0faf); /* 5 */
+            FF(d, a, b, c, x[5],  S12, 0x4787c62a); /* 6 */
+            FF(c, d, a, b, x[6],  S13, 0xa8304613); /* 7 */
+            FF(b, c, d, a, x[7],  S14, 0xfd469501); /* 8 */
+            FF(a, b, c, d, x[8],  S11, 0x698098d8); /* 9 */
+            FF(d, a, b, c, x[9],  S12, 0x8b44f7af); /* 10 */
+            FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
+            FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
+            FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
+            FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
+            FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
+            FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
+
+            /* Round 2 */
+            GG(a, b, c, d, x[1],  S21, 0xf61e2562); /* 17 */
+            GG(d, a, b, c, x[6],  S22, 0xc040b340); /* 18 */
+            GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
+            GG(b, c, d, a, x[0],  S24, 0xe9b6c7aa); /* 20 */
+            GG(a, b, c, d, x[5],  S21, 0xd62f105d); /* 21 */
+            GG(d, a, b, c, x[10], S22, 0x2441453);  /* 22 */
+            GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
+            GG(b, c, d, a, x[4],  S24, 0xe7d3fbc8); /* 24 */
+            GG(a, b, c, d, x[9],  S21, 0x21e1cde6); /* 25 */
+            GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
+            GG(c, d, a, b, x[3],  S23, 0xf4d50d87); /* 27 */
+            GG(b, c, d, a, x[8],  S24, 0x455a14ed); /* 28 */
+            GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
+            GG(d, a, b, c, x[2],  S22, 0xfcefa3f8); /* 30 */
+            GG(c, d, a, b, x[7],  S23, 0x676f02d9); /* 31 */
+            GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
+
+            /* Round 3 */
+            HH(a, b, c, d, x[5],  S31, 0xfffa3942); /* 33 */
+            HH(d, a, b, c, x[8],  S32, 0x8771f681); /* 34 */
+            HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
+            HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
+            HH(a, b, c, d, x[1],  S31, 0xa4beea44); /* 37 */
+            HH(d, a, b, c, x[4],  S32, 0x4bdecfa9); /* 38 */
+            HH(c, d, a, b, x[7],  S33, 0xf6bb4b60); /* 39 */
+            HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
+            HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
+            HH(d, a, b, c, x[0],  S32, 0xeaa127fa); /* 42 */
+            HH(c, d, a, b, x[3],  S33, 0xd4ef3085); /* 43 */
+            HH(b, c, d, a, x[6],  S34, 0x4881d05);  /* 44 */
+            HH(a, b, c, d, x[9],  S31, 0xd9d4d039); /* 45 */
+            HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
+            HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
+            HH(b, c, d, a, x[2],  S34, 0xc4ac5665); /* 48 */
+
+            /* Round 4 */
+            II(a, b, c, d, x[0],  S41, 0xf4292244); /* 49 */
+            II(d, a, b, c, x[7],  S42, 0x432aff97); /* 50 */
+            II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
+            II(b, c, d, a, x[5],  S44, 0xfc93a039); /* 52 */
+            II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
+            II(d, a, b, c, x[3],  S42, 0x8f0ccc92); /* 54 */
+            II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
+            II(b, c, d, a, x[1],  S44, 0x85845dd1); /* 56 */
+            II(a, b, c, d, x[8],  S41, 0x6fa87e4f); /* 57 */
+            II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
+            II(c, d, a, b, x[6],  S43, 0xa3014314); /* 59 */
+            II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
+            II(a, b, c, d, x[4],  S41, 0xf7537e82); /* 61 */
+            II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
+            II(c, d, a, b, x[2],  S43, 0x2ad7d2bb); /* 63 */
+            II(b, c, d, a, x[9],  S44, 0xeb86d391); /* 64 */
+
+            state[0] += a;
+            state[1] += b;
+            state[2] += c;
+            state[3] += d;
+
+            // clear any sensitive information.
+            memset(x, 0, sizeof(x));
+        }
+
+        static void decode(unsigned int* output, const unsigned char* input, unsigned int length) {
+            unsigned int i, j;
+
+            for (i = 0, j = 0; j < length; i++, j += 4)
+                output[i] = ((unsigned int)input[j])             |
+                            (((unsigned int)input[j + 1]) << 8)  |
+                            (((unsigned int)input[j + 2]) << 16) |
+                            (((unsigned int)input[j + 3]) << 24);
+        }
+
+        static void encode(unsigned char* output, const unsigned int* input, unsigned int length) {
+            unsigned int i, j;
+            unsigned int k;
+
+            for (i = 0, j = 0; j < length; i++, j += 4) {
+                k = input[i];
+                output[j]     = (unsigned char)(k & 0xff);
+                output[j + 1] = (unsigned char)((k >> 8) & 0xff);
+                output[j + 2] = (unsigned char)((k >> 16) & 0xff);
+                output[j + 3] = (unsigned char)((k >> 24) & 0xff);
+            }
+        }
+    };
+
+}}}}}
+
+////////////////////////////////////////////////////////////////////////////////
+MD5MessageDigestSpi::MD5MessageDigestSpi() : MessageDigestSpi(), impl(new MD5MessageDigestSpiImpl) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+MD5MessageDigestSpi::~MD5MessageDigestSpi() {
+    delete this->impl;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+MessageDigestSpi* MD5MessageDigestSpi::clone() {
+    MD5MessageDigestSpi* clone = new MD5MessageDigestSpi;
+
+    System::arraycopy(clone->impl->state, 0, this->impl->state, 0, 4);
+    System::arraycopy(clone->impl->count, 0, this->impl->count, 0, 2);
+    System::arraycopy(clone->impl->buffer, 0, this->impl->buffer, 0, 64);
+
+    return clone;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int MD5MessageDigestSpi::engineGetDigestLength() {
+    return DECAF_MD5_DIGESTSIZE;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MD5MessageDigestSpi::engineUpdate(unsigned char input) {
+    this->impl->update(&input, 1);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MD5MessageDigestSpi::engineUpdate(const unsigned char* input, int size, int offset, int length) {
+
+    if (input == NULL && size > 0) {
+        throw DigestException(__FILE__, __LINE__, "Null buffer parameter.");
+    }
+
+    if (size <= 0) {
+        return;
+    }
+
+    if (offset < 0 || length < 0) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__, "Incorrect offset or length value.");
+    }
+
+    if (offset + length > size) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__, "Incorrect offset or length value.");
+    }
+
+    this->impl->update(&input[offset], length);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MD5MessageDigestSpi::engineUpdate(const std::vector<unsigned char>& input) {
+
+    if (input.empty()) {
+        return;
+    }
+
+    this->impl->update(&input[0], (int)input.size());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MD5MessageDigestSpi::engineUpdate(decaf::nio::ByteBuffer& input) {
+
+    if (!input.hasRemaining()) {
+        return;
+    }
+    unsigned char* temp;
+    if (input.hasArray()) {
+        temp = input.array();
+        int offset = input.arrayOffset();
+        int position = input.position();
+        int limit = input.limit();
+        engineUpdate(temp, limit - position, offset + position, limit - position);
+        input.position(limit);
+    } else {
+        int length = input.limit() - input.position();
+        temp = new unsigned char[length];
+        input.get(temp, length, 0, length);
+        engineUpdate(temp, length, 0, length);
+        delete temp;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MD5MessageDigestSpi::engineReset() {
+    this->impl->reset();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::vector<unsigned char> MD5MessageDigestSpi::engineDigest() {
+
+    std::vector<unsigned char> buffer;
+    buffer.resize(DECAF_MD5_DIGESTSIZE);
+    this->impl->finalize(&buffer[0]);
+
+    return buffer;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int MD5MessageDigestSpi::engineDigest(unsigned char* buffer, int size, int offset, int length) {
+
+    if (buffer == NULL) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__, "Null buffer parameter.");
+    }
+
+    if (size < engineGetDigestLength()) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__,
+            "The value of size parameter is less than the actual digest length.");
+    }
+
+    if (length < engineGetDigestLength()) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__,
+            "The value of length parameter is less than the actual digest length.");
+    }
+
+    if (offset < 0) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__, "Invalid negative offset.");
+    }
+
+    if (offset + length > size) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__, "Incorrect offset or length value.");
+    }
+
+    std::vector<unsigned char> temp = engineDigest();
+    if (length < (int)temp.size()) {
+        throw DigestException(__FILE__, __LINE__,
+            "The value of length parameter is less than the actual digest length..");
+    }
+
+    System::arraycopy(&temp[0], 0, buffer, offset, temp.size());
+    return (int)temp.size();
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD5MessageDigestSpi.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD5MessageDigestSpi.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD5MessageDigestSpi.h?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD5MessageDigestSpi.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD5MessageDigestSpi.h Sat Mar 16 21:14:01 2013
@@ -0,0 +1,80 @@
+/*
+ * 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_SECURITY_PROVIDER_CRYPTO_MD5MESSAGEDIGESTSPI_H_
+#define _DECAF_INTERNAL_SECURITY_PROVIDER_CRYPTO_MD5MESSAGEDIGESTSPI_H_
+
+#include <decaf/util/Config.h>
+
+#include <decaf/security/MessageDigestSpi.h>
+
+namespace decaf {
+namespace internal {
+namespace security {
+namespace provider {
+namespace crypto {
+
+    class MD5MessageDigestSpiImpl;
+
+    /**
+     * MD5 MessageDigestSpi
+     *
+     * @since 1.0
+     */
+    class DECAF_API MD5MessageDigestSpi : public decaf::security::MessageDigestSpi {
+    private:
+
+        MD5MessageDigestSpi(const MD5MessageDigestSpi&);
+        MD5MessageDigestSpi& operator= (const MD5MessageDigestSpi&);
+
+        MD5MessageDigestSpiImpl* impl;
+
+    public:
+
+        MD5MessageDigestSpi();
+
+        virtual ~MD5MessageDigestSpi();
+
+    public:
+
+        virtual bool isCloneable() const {
+            return true;
+        }
+
+        virtual MessageDigestSpi* clone();
+
+        virtual int engineGetDigestLength();
+
+        virtual void engineUpdate(unsigned char input);
+
+        virtual void engineUpdate(const unsigned char* input, int size, int offset, int length);
+
+        virtual void engineReset();
+
+        virtual void engineUpdate(const std::vector<unsigned char>& input);
+
+        virtual void engineUpdate(decaf::nio::ByteBuffer& input);
+
+        virtual std::vector<unsigned char> engineDigest();
+
+        virtual int engineDigest(unsigned char* buffer, int size, int offset, int length);
+
+    };
+
+}}}}}
+
+#endif /* _DECAF_INTERNAL_SECURITY_PROVIDER_CRYPTO_MD5MESSAGEDIGESTSPI_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/MD5MessageDigestSpi.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/SHA1MessageDigestSpi.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/SHA1MessageDigestSpi.cpp?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/SHA1MessageDigestSpi.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/SHA1MessageDigestSpi.cpp Sat Mar 16 21:14:01 2013
@@ -0,0 +1,390 @@
+/* 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 "SHA1MessageDigestSpi.h"
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <decaf/lang/System.h>
+#include <decaf/security/DigestException.h>
+
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::security;
+using namespace decaf::internal;
+using namespace decaf::internal::security;
+using namespace decaf::internal::security::provider;
+using namespace decaf::internal::security::provider::crypto;
+
+////////////////////////////////////////////////////////////////////////////////
+namespace {
+
+#define DECAF_SHA1_DIGESTSIZE 20
+
+/* SHA f()-functions */
+#define f1(x,y,z) ((x & y) | (~x & z))
+#define f2(x,y,z) (x ^ y ^ z)
+#define f3(x,y,z) ((x & y) | (x & z) | (y & z))
+#define f4(x,y,z) (x ^ y ^ z)
+
+// SHA constants
+#define CONST1 0x5a827999
+#define CONST2 0x6ed9eba1
+#define CONST3 0x8f1bbcdc
+#define CONST4 0xca62c1d6
+
+// 32-bit rotate
+#define ROT32(x,n) ((x << n) | (x >> (32 - n)))
+
+#define FUNC(n,i) \
+    temp = ROT32(A,5) + f##n(B,C,D) + E + W[i] + CONST##n; \
+    E = D; D = C; C = ROT32(B,30); B = A; A = temp
+
+#define SHA_BLOCKSIZE 64
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+namespace decaf {
+namespace internal {
+namespace security {
+namespace provider {
+namespace crypto {
+
+    class SHA1MessageDigestSpiImpl {
+    public:
+
+        // message digest
+        unsigned int state[5];
+        // 64-bit bit counts
+        unsigned int count[2];
+        // SHA data buffer
+        unsigned int data[16];
+        // unprocessed amount in data form last update
+        int local;
+
+    private:
+
+        union endianTest {
+            long Long;
+            char Char[sizeof(long)];
+        };
+
+        static bool isLittleEndian() {
+            static union endianTest u;
+            u.Long = 1;
+            return (u.Char[0] == 1);
+        }
+
+        static void maybeReverseBytes(unsigned int* buffer, int count) {
+
+            int i;
+            unsigned char ct[4], *cp;
+
+            if (isLittleEndian()) { // do the swap only if it is little endian
+                count = (int)(count / 4);
+                cp = (unsigned char*) buffer;
+                for (i = 0; i < count; ++i) {
+                    ct[0] = cp[0];
+                    ct[1] = cp[1];
+                    ct[2] = cp[2];
+                    ct[3] = cp[3];
+                    cp[0] = ct[3];
+                    cp[1] = ct[2];
+                    cp[2] = ct[1];
+                    cp[3] = ct[0];
+                    cp += sizeof(int);
+                }
+            }
+        }
+
+        static void SHA1Transform(unsigned int state[5], const unsigned int buffer[16]) {
+            int i;
+            unsigned int temp, A, B, C, D, E, W[80];
+
+            for (i = 0; i < 16; ++i) {
+                W[i] = buffer[i];
+            }
+            for (i = 16; i < 80; ++i) {
+                W[i] = W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16];
+            }
+            A = state[0];
+            B = state[1];
+            C = state[2];
+            D = state[3];
+            E = state[4];
+
+            FUNC(1, 0);  FUNC(1, 1);  FUNC(1, 2);  FUNC(1, 3);  FUNC(1, 4);
+            FUNC(1, 5);  FUNC(1, 6);  FUNC(1, 7);  FUNC(1, 8);  FUNC(1, 9);
+            FUNC(1,10);  FUNC(1,11);  FUNC(1,12);  FUNC(1,13);  FUNC(1,14);
+            FUNC(1,15);  FUNC(1,16);  FUNC(1,17);  FUNC(1,18);  FUNC(1,19);
+
+            FUNC(2,20);  FUNC(2,21);  FUNC(2,22);  FUNC(2,23);  FUNC(2,24);
+            FUNC(2,25);  FUNC(2,26);  FUNC(2,27);  FUNC(2,28);  FUNC(2,29);
+            FUNC(2,30);  FUNC(2,31);  FUNC(2,32);  FUNC(2,33);  FUNC(2,34);
+            FUNC(2,35);  FUNC(2,36);  FUNC(2,37);  FUNC(2,38);  FUNC(2,39);
+
+            FUNC(3,40);  FUNC(3,41);  FUNC(3,42);  FUNC(3,43);  FUNC(3,44);
+            FUNC(3,45);  FUNC(3,46);  FUNC(3,47);  FUNC(3,48);  FUNC(3,49);
+            FUNC(3,50);  FUNC(3,51);  FUNC(3,52);  FUNC(3,53);  FUNC(3,54);
+            FUNC(3,55);  FUNC(3,56);  FUNC(3,57);  FUNC(3,58);  FUNC(3,59);
+
+            FUNC(4,60);  FUNC(4,61);  FUNC(4,62);  FUNC(4,63);  FUNC(4,64);
+            FUNC(4,65);  FUNC(4,66);  FUNC(4,67);  FUNC(4,68);  FUNC(4,69);
+            FUNC(4,70);  FUNC(4,71);  FUNC(4,72);  FUNC(4,73);  FUNC(4,74);
+            FUNC(4,75);  FUNC(4,76);  FUNC(4,77);  FUNC(4,78);  FUNC(4,79);
+
+            state[0] += A;
+            state[1] += B;
+            state[2] += C;
+            state[3] += D;
+            state[4] += E;
+        }
+
+    public:
+
+        SHA1MessageDigestSpiImpl() : state(), count(), data(), local() {
+            reset();
+        }
+
+        void reset() {
+            state[0] = 0x67452301;
+            state[1] = 0xefcdab89;
+            state[2] = 0x98badcfe;
+            state[3] = 0x10325476;
+            state[4] = 0xc3d2e1f0;
+            count[0] = 0;
+            count[0] = 0;
+            local = 0;
+        }
+
+        void update(const unsigned char* input, int length) {
+            int i;
+
+            if ((count[0] + ((unsigned int) length << 3)) < count[0]) {
+                ++count[1];
+            }
+            count[0] += (unsigned int) length << 3;
+            count[1] += (unsigned int) length >> 29;
+            if (local) {
+                i = SHA_BLOCKSIZE - local;
+                if (i > length) {
+                    i = length;
+                }
+                memcpy(((unsigned char*) data) + local, input, i);
+
+                length -= i;
+                input += i;
+                local += i;
+
+                if (local == SHA_BLOCKSIZE) {
+                    maybeReverseBytes(data, SHA_BLOCKSIZE);
+                    SHA1Transform(state, data);
+                } else {
+                    return;
+                }
+            }
+
+            while (length >= SHA_BLOCKSIZE) {
+                memcpy(data, input, SHA_BLOCKSIZE);
+                input += SHA_BLOCKSIZE;
+                length -= SHA_BLOCKSIZE;
+                maybeReverseBytes(data, SHA_BLOCKSIZE);
+                SHA1Transform(state, data);
+            }
+            memcpy(data, input, length);
+            local = length;
+        }
+
+        void finalize(unsigned char digest[DECAF_SHA1_DIGESTSIZE]) {
+            int index, i, j;
+            unsigned int lo_bit_count, hi_bit_count, k;
+
+            lo_bit_count = count[0];
+            hi_bit_count = count[1];
+            index = (int) ((lo_bit_count >> 3) & 0x3f);
+            ((unsigned char*) data)[index++] = 0x80;
+
+            if (index > SHA_BLOCKSIZE - 8) {
+                memset(((unsigned char*) data) + index, 0, SHA_BLOCKSIZE - index);
+                maybeReverseBytes(data, SHA_BLOCKSIZE);
+                SHA1Transform(state, data);
+                memset((unsigned char*) data, 0, SHA_BLOCKSIZE - 8);
+            } else {
+              memset(((unsigned char*) data) + index, 0, SHA_BLOCKSIZE - 8 - index);
+            }
+
+            maybeReverseBytes(data, SHA_BLOCKSIZE);
+            data[14] = hi_bit_count;
+            data[15] = lo_bit_count;
+            SHA1Transform(state, data);
+
+            for (i = 0, j = 0; j < DECAF_SHA1_DIGESTSIZE; i++) {
+                k = state[i];
+                digest[j++] = (unsigned char) ((k >> 24) & 0xff);
+                digest[j++] = (unsigned char) ((k >> 16) & 0xff);
+                digest[j++] = (unsigned char) ((k >> 8) & 0xff);
+                digest[j++] = (unsigned char) (k & 0xff);
+            }
+        }
+    };
+
+}}}}}
+
+////////////////////////////////////////////////////////////////////////////////
+SHA1MessageDigestSpi::SHA1MessageDigestSpi() : MessageDigestSpi(), impl(new SHA1MessageDigestSpiImpl) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+SHA1MessageDigestSpi::~SHA1MessageDigestSpi() {
+    delete this->impl;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+MessageDigestSpi* SHA1MessageDigestSpi::clone() {
+    SHA1MessageDigestSpi* clone = new SHA1MessageDigestSpi;
+
+    System::arraycopy(clone->impl->state, 0, this->impl->state, 0, 5);
+    System::arraycopy(clone->impl->count, 0, this->impl->count, 0, 2);
+    System::arraycopy(clone->impl->data, 0, this->impl->data, 0, 16);
+    clone->impl->local = this->impl->local;
+
+    return clone;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int SHA1MessageDigestSpi::engineGetDigestLength() {
+    return DECAF_SHA1_DIGESTSIZE;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SHA1MessageDigestSpi::engineUpdate(unsigned char input) {
+    this->impl->update(&input, 1);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SHA1MessageDigestSpi::engineUpdate(const unsigned char* input, int size, int offset, int length) {
+
+    if (input == NULL && size > 0) {
+        throw DigestException(__FILE__, __LINE__, "Null buffer parameter.");
+    }
+
+    if (size <= 0) {
+        return;
+    }
+
+    if (offset < 0 || length < 0) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__, "Incorrect offset or length value.");
+    }
+
+    if (offset + length > size) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__, "Incorrect offset or length value.");
+    }
+
+    this->impl->update(&input[offset], length);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SHA1MessageDigestSpi::engineUpdate(const std::vector<unsigned char>& input) {
+
+    if (input.empty()) {
+        return;
+    }
+
+    this->impl->update(&input[0], (int)input.size());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SHA1MessageDigestSpi::engineUpdate(decaf::nio::ByteBuffer& input) {
+
+    if (!input.hasRemaining()) {
+        return;
+    }
+    unsigned char* temp;
+    if (input.hasArray()) {
+        temp = input.array();
+        int offset = input.arrayOffset();
+        int position = input.position();
+        int limit = input.limit();
+        engineUpdate(temp, limit - position, offset + position, limit - position);
+        input.position(limit);
+    } else {
+        int length = input.limit() - input.position();
+        temp = new unsigned char[length];
+        input.get(temp, length, 0, length);
+        engineUpdate(temp, length, 0, length);
+        delete temp;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void SHA1MessageDigestSpi::engineReset() {
+    this->impl->reset();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::vector<unsigned char> SHA1MessageDigestSpi::engineDigest() {
+
+    std::vector<unsigned char> buffer;
+    buffer.resize(DECAF_SHA1_DIGESTSIZE);
+    this->impl->finalize(&buffer[0]);
+
+    return buffer;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int SHA1MessageDigestSpi::engineDigest(unsigned char* buffer, int size, int offset, int length) {
+
+    if (buffer == NULL) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__, "Null buffer parameter.");
+    }
+
+    if (size < engineGetDigestLength()) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__,
+            "The value of size parameter is less than the actual digest length.");
+    }
+
+    if (length < engineGetDigestLength()) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__,
+            "The value of length parameter is less than the actual digest length.");
+    }
+
+    if (offset < 0) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__, "Invalid negative offset.");
+    }
+
+    if (offset + length > size) {
+        engineReset();
+        throw DigestException(__FILE__, __LINE__, "Incorrect offset or length value.");
+    }
+
+    std::vector<unsigned char> temp = engineDigest();
+    if (length < (int)temp.size()) {
+        throw DigestException(__FILE__, __LINE__,
+            "The value of length parameter is less than the actual digest length..");
+    }
+
+    System::arraycopy(&temp[0], 0, buffer, offset, temp.size());
+    return (int)temp.size();
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/SHA1MessageDigestSpi.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/SHA1MessageDigestSpi.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/SHA1MessageDigestSpi.h?rev=1457307&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/SHA1MessageDigestSpi.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/SHA1MessageDigestSpi.h Sat Mar 16 21:14:01 2013
@@ -0,0 +1,80 @@
+/*
+ * 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_SECURITY_PROVIDER_CRYPTO_SHA1MESSAGEDIGESTSPI_H_
+#define _DECAF_INTERNAL_SECURITY_PROVIDER_CRYPTO_SHA1MESSAGEDIGESTSPI_H_
+
+#include <decaf/util/Config.h>
+
+#include <decaf/security/MessageDigestSpi.h>
+
+namespace decaf {
+namespace internal {
+namespace security {
+namespace provider {
+namespace crypto {
+
+    class SHA1MessageDigestSpiImpl;
+
+    /**
+     * SHA1 MessageDigestSpi
+     *
+     * @since 1.0
+     */
+    class DECAF_API SHA1MessageDigestSpi : public decaf::security::MessageDigestSpi {
+    private:
+
+        SHA1MessageDigestSpi(const SHA1MessageDigestSpi&);
+        SHA1MessageDigestSpi& operator= (const SHA1MessageDigestSpi&);
+
+        SHA1MessageDigestSpiImpl* impl;
+
+    public:
+
+        SHA1MessageDigestSpi();
+
+        virtual ~SHA1MessageDigestSpi();
+
+    public:
+
+        virtual bool isCloneable() const {
+            return true;
+        }
+
+        virtual MessageDigestSpi* clone();
+
+        virtual int engineGetDigestLength();
+
+        virtual void engineUpdate(unsigned char input);
+
+        virtual void engineUpdate(const unsigned char* input, int size, int offset, int length);
+
+        virtual void engineReset();
+
+        virtual void engineUpdate(const std::vector<unsigned char>& input);
+
+        virtual void engineUpdate(decaf::nio::ByteBuffer& input);
+
+        virtual std::vector<unsigned char> engineDigest();
+
+        virtual int engineDigest(unsigned char* buffer, int size, int offset, int length);
+
+    };
+
+}}}}}
+
+#endif /* _DECAF_INTERNAL_SECURITY_PROVIDER_CRYPTO_SHA1MESSAGEDIGESTSPI_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/security/provider/crypto/SHA1MessageDigestSpi.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Byte.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Byte.cpp?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Byte.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Byte.cpp Sat Mar 16 21:14:01 2013
@@ -24,6 +24,11 @@ using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
+const unsigned char Byte::MIN_VALUE = 0x7F;
+const unsigned char Byte::MAX_VALUE = 0x80;
+const int Byte::SIZE = 8;
+
+////////////////////////////////////////////////////////////////////////////////
 Byte::Byte( unsigned char value ) : value(value) {
 }
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Byte.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Byte.h?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Byte.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Byte.h Sat Mar 16 21:14:01 2013
@@ -37,13 +37,13 @@ namespace lang{
     public:
 
         /** The minimum value that a unsigned char can take on. */
-        static const unsigned char MIN_VALUE = 0x7F;
+        static const unsigned char MIN_VALUE;
 
         /** The maximum value that a unsigned char can take on. */
-        static const unsigned char MAX_VALUE = 0x80;
+        static const unsigned char MAX_VALUE;
 
-        /** The size of the primitive charactor in bits. */
-        static const int SIZE = 8;
+        /** The size of the primitive character in bits. */
+        static const int SIZE;
 
     public:
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Double.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Double.cpp?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Double.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Double.cpp Sat Mar 16 21:14:01 2013
@@ -27,6 +27,7 @@ using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
+const int Double::SIZE = 64;
 const double Double::MAX_VALUE = 1.7976931348623157e+308;
 const double Double::MIN_VALUE = 5e-324;
 const double Double::NaN = std::numeric_limits<double>::quiet_NaN();

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Double.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Double.h?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Double.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Double.h Sat Mar 16 21:14:01 2013
@@ -37,7 +37,7 @@ namespace lang{
     public:
 
         /** The size in bits of the primitive int type */
-        static const int SIZE = 64;
+        static const int SIZE;
 
         /** The maximum value that the primitive type can hold */
         static const double MAX_VALUE;

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Float.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Float.cpp?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Float.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Float.cpp Sat Mar 16 21:14:01 2013
@@ -26,6 +26,7 @@ using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
+const int Float::SIZE = 32;
 const float Float::MAX_VALUE = 3.40282346638528860e+38f;
 const float Float::MIN_VALUE = 1.40129846432481707e-45f;
 const float Float::NaN = std::numeric_limits<float>::quiet_NaN();

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Float.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Float.h?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Float.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Float.h Sat Mar 16 21:14:01 2013
@@ -37,7 +37,7 @@ namespace lang{
     public:
 
         /** The size in bits of the primitive int type */
-        static const int SIZE = 32;
+        static const int SIZE;
 
         /** The maximum value that the primitive type can hold */
         static const float MAX_VALUE;

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Integer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Integer.cpp?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Integer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Integer.cpp Sat Mar 16 21:14:01 2013
@@ -28,6 +28,11 @@ using namespace decaf::lang;
 using namespace decaf::lang::exceptions;
 
 ////////////////////////////////////////////////////////////////////////////////
+const int Integer::SIZE = 32;
+const int Integer::MAX_VALUE = (int)0x7FFFFFFF;
+const int Integer::MIN_VALUE = (int)0x80000000;
+
+////////////////////////////////////////////////////////////////////////////////
 Integer::Integer( int value ) :value(value) {
 }
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Integer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Integer.h?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Integer.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Integer.h Sat Mar 16 21:14:01 2013
@@ -32,19 +32,19 @@ namespace lang{
                               public Comparable<int> {
     private:
 
-        // The primitve Integer value.
+        // The primitive Integer value.
         int value;
 
     public:
 
         /** The size in bits of the primitive int type */
-        static const int SIZE = 32;
+        static const int SIZE;
 
         /** The maximum value that the primitive type can hold */
-        static const int MAX_VALUE = (int)0x7FFFFFFF;
+        static const int MAX_VALUE;
 
         /** The minimum value that the primitive type can hold */
-        static const int MIN_VALUE = (int)0x80000000;
+        static const int MIN_VALUE;
 
     public:
 
@@ -52,7 +52,7 @@ namespace lang{
          * @param value
          *      The primitive value to wrap in an <code>Integer</code> instance.
          */
-        Integer( int value );
+        Integer(int value);
 
         /**
          * Constructs a new Integer and attempts to convert the given string to an int
@@ -64,9 +64,10 @@ namespace lang{
          *
          * @throws NumberFormatException if the string is not a a valid integer.
          */
-        Integer( const std::string& value );
+        Integer(const std::string& value);
 
-        virtual ~Integer() {}
+        virtual ~Integer() {
+        }
 
         /**
          * Compares this Integer instance with another.
@@ -76,13 +77,13 @@ namespace lang{
          * than the passed in value, and -1 if this object represents a value
          * less than the passed in value.
          */
-        virtual int compareTo( const Integer& i ) const;
+        virtual int compareTo(const Integer& i) const;
 
         /**
          * @param i - the Integer object to compare against.
          * @returns true if the two Integer Objects have the same value.
          */
-        bool equals( const Integer& i ) const {
+        bool equals(const Integer& i) const {
             return this->value == i.value;
         }
 
@@ -91,7 +92,7 @@ namespace lang{
          * @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 {
+        virtual bool operator==(const Integer& i) const {
             return this->value == i.value;
         }
 
@@ -101,7 +102,7 @@ namespace lang{
          * @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 {
+        virtual bool operator<(const Integer& i) const {
             return this->value < i.value;
         }
 
@@ -113,13 +114,13 @@ namespace lang{
          * than the passed in value, and -1 if this object represents a value
          * less than the passed in value.
          */
-        virtual int compareTo( const int& i ) const;
+        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 {
+        bool equals(const int& i) const {
             return this->value == i;
         }
 
@@ -128,7 +129,7 @@ namespace lang{
          * @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 {
+        virtual bool operator==(const int& i) const {
             return this->value == i;
         }
 
@@ -138,7 +139,7 @@ namespace lang{
          * @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 {
+        virtual bool operator<(const int& i) const {
             return this->value < i;
         }
 
@@ -152,7 +153,7 @@ namespace lang{
          * @return double the value of the receiver.
          */
         virtual double doubleValue() const {
-            return (double)this->value;
+            return (double) this->value;
         }
 
         /**
@@ -160,7 +161,7 @@ namespace lang{
          * @return float the value of the receiver.
          */
         virtual float floatValue() const {
-            return (float)this->value;
+            return (float) this->value;
         }
 
         /**
@@ -168,7 +169,7 @@ namespace lang{
          * @return int the value of the receiver.
          */
         virtual unsigned char byteValue() const {
-            return (unsigned char)this->value;
+            return (unsigned char) this->value;
         }
 
         /**
@@ -176,7 +177,7 @@ namespace lang{
          * @return int the value of the receiver.
          */
         virtual short shortValue() const {
-            return (short)this->value;
+            return (short) this->value;
         }
 
         /**
@@ -192,10 +193,11 @@ namespace lang{
          * @return long the value of the receiver.
          */
         virtual long long longValue() const {
-            return (long long)this->value;
+            return (long long) this->value;
         }
 
-    public:  // Statics
+    public:
+        // Statics
 
         /**
          * Decodes a String into a Integer. Accepts decimal, hexadecimal, and octal
@@ -212,7 +214,7 @@ namespace lang{
          * @returns a Integer object containing the decoded value
          * @throws NumberFomatException if the string is not formatted correctly.
          */
-        static Integer decode( const std::string& value );
+        static Integer decode(const std::string& value);
 
         /**
          * Returns the value obtained by reversing the order of the bytes in the
@@ -220,7 +222,7 @@ namespace lang{
          * @param value - the int whose bytes we are to reverse
          * @return the reversed int.
          */
-        static int reverseBytes( int value );
+        static int reverseBytes(int value);
 
         /**
          * Returns the value obtained by reversing the order of the bits in the
@@ -228,7 +230,7 @@ namespace lang{
          * @param value - the value whose bits are to be reversed
          * @returns the reversed bits int.
          */
-        static int reverse( int value );
+        static int reverse(int value);
 
         /**
          * Parses the string argument as a signed int in the radix specified by
@@ -253,7 +255,7 @@ namespace lang{
          * @return the int represented by the string argument in the specified radix.
          * @throws NumberFormatException - If String does not contain a parsable int.
          */
-        static int parseInt( const std::string& s, int radix );
+        static int parseInt(const std::string& s, int radix);
 
         /**
          * Parses the string argument as a signed decimal int. The characters
@@ -266,15 +268,15 @@ namespace lang{
          * @returns the converted int value
          * @throws NumberFormatException if the string is not a int.
          */
-        static int parseInt( const std::string& s );
+        static int parseInt(const std::string& s);
 
         /**
          * Returns a Integer instance representing the specified int value.
          * @param value - the int to wrap
          * @return the new Integer object wrapping value.
          */
-        static Integer valueOf( int value ) {
-            return Integer( value );
+        static Integer valueOf(int value) {
+            return Integer(value);
         }
 
         /**
@@ -287,7 +289,7 @@ namespace lang{
          * @return new Integer Object wrapping the primitive
          * @throws NumberFormatException if the string is not a decimal int.
          */
-        static Integer valueOf( const std::string& value );
+        static Integer valueOf(const std::string& value);
 
         /**
          * Returns a Integer object holding the value extracted from the specified
@@ -301,7 +303,7 @@ namespace lang{
          * @return new Integer Object wrapping the primitive
          * @throws NumberFormatException if the string is not a valid int.
          */
-        static Integer valueOf( const std::string& value, int radix );
+        static Integer valueOf(const std::string& value, int radix);
 
         /**
          * Returns the number of one-bits in the two's complement binary
@@ -311,7 +313,7 @@ namespace lang{
          * @return the number of one-bits in the two's complement binary
          *         representation of the specified int value.
          */
-        static int bitCount( int value );
+        static int bitCount(int value);
 
         /**
          * Converts the int to a String representation
@@ -319,7 +321,7 @@ namespace lang{
          *      The int to convert to a <code>std::string</code> instance.
          * @return string representation
          */
-        static std::string toString( int value );
+        static std::string toString(int value);
 
         /**
          * Returns a string representation of the first argument in the radix
@@ -344,7 +346,7 @@ namespace lang{
          * @param radix - the radix to format the string in
          * @returns an int formatted to the string value of the radix given.
          */
-        static std::string toString( int value, int radix );
+        static std::string toString(int value, int radix);
 
         /**
          * Returns a string representation of the integer argument as an unsigned
@@ -365,7 +367,7 @@ namespace lang{
          * @param value - the int to be translated to an Octal string
          * @returns the unsigned int value as a Octal string
          */
-        static std::string toHexString( int value );
+        static std::string toHexString(int value);
 
         /**
          * Returns a string representation of the integer argument as an unsigned
@@ -385,7 +387,7 @@ namespace lang{
          * @param value - the int to be translated to an Octal string
          * @returns the unsigned int value as a Octal string
          */
-        static std::string toOctalString( int value );
+        static std::string toOctalString(int value);
 
         /**
          * Returns a string representation of the integer argument as an unsigned
@@ -404,7 +406,7 @@ namespace lang{
          * @param value - the int to be translated to a binary string
          * @returns the unsigned int value as a binary string
          */
-        static std::string toBinaryString( int value );
+        static std::string toBinaryString(int value);
 
         /**
          * Returns an int value with at most a single one-bit, in the position of
@@ -416,7 +418,7 @@ namespace lang{
          * highest-order one-bit in the specified value, or zero if the specified
          * value is itself equal to zero.
          */
-        static int highestOneBit( int value );
+        static int highestOneBit(int value);
 
         /**
          * Returns an int value with at most a single one-bit, in the position of
@@ -428,7 +430,7 @@ namespace lang{
          * lowest-order one-bit in the specified value, or zero if the specified
          * value is itself equal to zero.
          */
-        static int lowestOneBit( int value );
+        static int lowestOneBit(int value);
 
         /**
          * Returns the number of zero bits preceding the highest-order ("leftmost")
@@ -447,7 +449,7 @@ namespace lang{
          * one-bit in the two's complement binary representation of the specified
          * int value, or 32 if the value is equal to zero.
          */
-        static int numberOfLeadingZeros( int value );
+        static int numberOfLeadingZeros(int value);
 
         /**
          * Returns the number of zero bits following the lowest-order ("rightmost")
@@ -459,7 +461,7 @@ namespace lang{
          * one-bit in the two's complement binary representation of the specified
          * int value, or 32 if the value is equal to zero.
          */
-        static int numberOfTrailingZeros( int value );
+        static int numberOfTrailingZeros(int value);
 
         /**
          * Returns the value obtained by rotating the two's complement binary
@@ -478,7 +480,7 @@ namespace lang{
          * representation of the specified int value left by the specified number
          * of bits.
          */
-        static int rotateLeft( int value, int distance );
+        static int rotateLeft(int value, int distance);
 
         /**
          * Returns the value obtained by rotating the two's complement binary
@@ -497,7 +499,7 @@ namespace lang{
          * representation of the specified int value right by the specified number
          * of bits.
          */
-        static int rotateRight( int value, int distance );
+        static int rotateRight(int value, int distance);
 
         /**
          * Returns the signum function of the specified int value. (The return value
@@ -506,12 +508,11 @@ namespace lang{
          * @param value - the int to be inspected
          * @return the signum function of the specified int value.
          */
-        static int signum( int value );
+        static int signum(int value);
 
     private:
 
-        static int parse( const std::string& value, int offset,
-                          int radix, bool negative );
+        static int parse(const std::string& value, int offset, int radix, bool negative);
 
     };
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Long.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Long.cpp?rev=1457307&r1=1457306&r2=1457307&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Long.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Long.cpp Sat Mar 16 21:14:01 2013
@@ -23,37 +23,42 @@ using namespace decaf;
 using namespace decaf::lang;
 
 ////////////////////////////////////////////////////////////////////////////////
-Long::Long( long long value ) : value(value) {
+const int Long::SIZE = 64;
+const long long Long::MAX_VALUE = (long long) 0x7FFFFFFFFFFFFFFFLL;
+const long long Long::MIN_VALUE = (long long) 0x8000000000000000LL;
+
+////////////////////////////////////////////////////////////////////////////////
+Long::Long(long long value) : value(value) {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Long::Long( const std::string& value ) : value(0) {
-    this->value = parseLong( value );
+Long::Long(const std::string& value) : value(0) {
+    this->value = parseLong(value);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int Long::compareTo( const Long& l ) const {
+int Long::compareTo(const Long& l) const {
     return this->value < l.value ? -1 : this->value == l.value ? 0 : 1;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int Long::compareTo( const long long& l ) const {
+int Long::compareTo(const long long& l) const {
     return this->value < l ? -1 : this->value == l ? 0 : 1;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int Long::bitCount( long long value ) {
+int Long::bitCount(long long value) {
 
-    if( value == 0 ) {
+    if (value == 0) {
         return 0;
     }
 
-    unsigned long long uvalue = (unsigned long long)value;
+    unsigned long long uvalue = (unsigned long long) value;
 
     uvalue = (uvalue & 0x5555555555555555LL) + ((uvalue >> 1) & 0x5555555555555555LL);
     uvalue = (uvalue & 0x3333333333333333LL) + ((uvalue >> 2) & 0x3333333333333333LL);
     // adjust for 64-bit integer
-    unsigned int i = (unsigned int)( (uvalue >> 32) + uvalue );
+    unsigned int i = (unsigned int) ((uvalue >> 32) + uvalue);
     i = (i & 0x0F0F0F0F) + ((i >> 4) & 0x0F0F0F0F);
     i = (i & 0x00FF00FF) + ((i >> 8) & 0x00FF00FF);
     i = (i & 0x0000FFFF) + ((i >> 16) & 0x0000FFFF);
@@ -61,67 +66,56 @@ int Long::bitCount( long long value ) {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Long Long::decode( const std::string& value ) {
+Long Long::decode(const std::string& value) {
 
-    int length = (int)value.length(), i = 0;
-    if( length == 0 ) {
-        throw exceptions::NumberFormatException(
-            __FILE__, __LINE__,
-            "Long::decode - Zero length string given." );
+    int length = (int) value.length(), i = 0;
+    if (length == 0) {
+        throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::decode - Zero length string given.");
     }
 
     char firstDigit = value[i];
     bool negative = firstDigit == '-';
-    if( negative ) {
-        if( length == 1 ) {
-            throw exceptions::NumberFormatException(
-                __FILE__, __LINE__,
-                "Long::decode - Invalid length string given.",
-                value.c_str() );
+    if (negative) {
+        if (length == 1) {
+            throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::decode - Invalid length string given.", value.c_str());
         }
         firstDigit = value[++i];
     }
 
     int base = 10;
-    if( firstDigit == '0' ) {
-        if( ++i == length ) {
-            return valueOf( 0LL );
-        }
-        if( ( firstDigit = value[i] ) == 'x' || firstDigit == 'X' ) {
-            if ( i == length ) {
-                throw exceptions::NumberFormatException(
-                    __FILE__, __LINE__,
-                    "Long::decode - Invalid length string given.",
-                    value.c_str() );
+    if (firstDigit == '0') {
+        if (++i == length) {
+            return valueOf(0LL);
+        }
+        if ((firstDigit = value[i]) == 'x' || firstDigit == 'X') {
+            if (i == length) {
+                throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::decode - Invalid length string given.", value.c_str());
             }
             i++;
             base = 16;
         } else {
             base = 8;
         }
-    } else if( firstDigit == '#' ) {
-        if( i == length ) {
-            throw exceptions::NumberFormatException(
-                __FILE__, __LINE__,
-                "Long::decode - Invalid length string given.",
-                value.c_str() );
+    } else if (firstDigit == '#') {
+        if (i == length) {
+            throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::decode - Invalid length string given.", value.c_str());
         }
         i++;
         base = 16;
     }
 
-    long long result = parse( value, i, base, negative );
-    return valueOf( result );
+    long long result = parse(value, i, base, negative);
+    return valueOf(result);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-long long Long::highestOneBit( long long value ) {
+long long Long::highestOneBit(long long value) {
 
-    if( value == 0 ) {
+    if (value == 0) {
         return 0;
     }
 
-    unsigned long long uvalue = (unsigned long long)value;
+    unsigned long long uvalue = (unsigned long long) value;
 
     uvalue |= (uvalue >> 1);
     uvalue |= (uvalue >> 2);
@@ -129,27 +123,27 @@ long long Long::highestOneBit( long long
     uvalue |= (uvalue >> 8);
     uvalue |= (uvalue >> 16);
     uvalue |= (uvalue >> 32);
-    return ( uvalue & ~( uvalue >> 1 ) );
+    return (uvalue & ~(uvalue >> 1));
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-long long Long::lowestOneBit( long long value ) {
-    if( value == 0 ) {
+long long Long::lowestOneBit(long long value) {
+    if (value == 0) {
         return 0;
     }
 
-    unsigned long long uvalue = (unsigned long long)value;
-    return ( uvalue & (-1 * uvalue) );
+    unsigned long long uvalue = (unsigned long long) value;
+    return (uvalue & (-1 * uvalue));
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int Long::numberOfLeadingZeros( long long value ) {
+int Long::numberOfLeadingZeros(long long value) {
 
-    if( value == 0 ) {
+    if (value == 0) {
         return 0;
     }
 
-    unsigned long long uvalue = (unsigned long long)value;
+    unsigned long long uvalue = (unsigned long long) value;
 
     value |= value >> 1;
     value |= value >> 2;
@@ -157,94 +151,78 @@ int Long::numberOfLeadingZeros( long lon
     value |= value >> 8;
     value |= value >> 16;
     value |= value >> 32;
-    return Long::bitCount( ~uvalue );
+    return Long::bitCount(~uvalue);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int Long::numberOfTrailingZeros( long long value ) {
-    if( value == 0 ) {
+int Long::numberOfTrailingZeros(long long value) {
+    if (value == 0) {
         return 0;
     }
 
-    unsigned long long uvalue = (unsigned long long)value;
-    return Long::bitCount( (uvalue & (-1 * uvalue)) - 1 );
+    unsigned long long uvalue = (unsigned long long) value;
+    return Long::bitCount((uvalue & (-1 * uvalue)) - 1);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-long long Long::parseLong( const std::string& value ) {
+long long Long::parseLong(const std::string& value) {
 
-    return Long::parseLong( value, 10 );
+    return Long::parseLong(value, 10);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-long long Long::parseLong( const std::string& value, int radix ) {
+long long Long::parseLong(const std::string& value, int radix) {
 
-    if( radix < Character::MIN_RADIX ||
-        radix > Character::MAX_RADIX ) {
-        throw exceptions::NumberFormatException(
-            __FILE__, __LINE__,
-            "Long::parseLong - Given Radix is out of range." );
+    if (radix < Character::MIN_RADIX || radix > Character::MAX_RADIX) {
+        throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::parseLong - Given Radix is out of range.");
     }
 
-    int length = (int)value.length();
+    int length = (int) value.length();
     int i = 0;
 
-    if( length == 0 ) {
-        throw exceptions::NumberFormatException(
-            __FILE__, __LINE__,
-            "Long::parseLong - Zero length string is illegal." );
+    if (length == 0) {
+        throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::parseLong - Zero length string is illegal.");
     }
 
     bool negative = value[i] == '-';
-    if( negative && ++i == length ) {
-        throw exceptions::NumberFormatException(
-            __FILE__, __LINE__,
-            "Long::parseLong - Only a minus given, string is invalid." );
+    if (negative && ++i == length) {
+        throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::parseLong - Only a minus given, string is invalid.");
     }
 
-    return Long::parse( value, i, radix, negative );
+    return Long::parse(value, i, radix, negative);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-long long Long::parse( const std::string& value, int offset,
-                       int radix, bool negative ) {
+long long Long::parse(const std::string& value, int offset, int radix, bool negative) {
 
     long long max = Long::MIN_VALUE / radix;
     long long result = 0;
     long long length = value.length();
 
-    while( offset < length ) {
-        int digit = Character::digit( value[offset++], radix );
+    while (offset < length) {
+        int digit = Character::digit(value[offset++], radix);
 
-        if( digit == -1 ) {
-            throw exceptions::NumberFormatException(
-                __FILE__, __LINE__,
-                "Long::parseLong - String contains no digit characters." );
+        if (digit == -1) {
+            throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::parseLong - String contains no digit characters.");
         }
 
-        if( max > result ) {
-            throw exceptions::NumberFormatException(
-                __FILE__, __LINE__,
-                "Long::parseLong - Parsed value greater than max for radix." );
+        if (max > result) {
+            throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::parseLong - Parsed value greater than max for radix.");
         }
 
         long long next = result * radix - digit;
 
-        if( next > result ) {
-            throw exceptions::NumberFormatException(
-                __FILE__, __LINE__,
-                "Long::parseLong - Only a minus given, string is invalid." );
+        if (next > result) {
+            throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::parseLong - Only a minus given, string is invalid.");
         }
 
         result = next;
     }
 
-    if( !negative ) {
+    if (!negative) {
         result = -result;
-        if( result < 0 ) {
-            throw exceptions::NumberFormatException(
-                __FILE__, __LINE__,
-                "Long::parseLong - Value less than zero, but no minus sign." );
+        if (result < 0) {
+            throw exceptions::NumberFormatException(__FILE__, __LINE__, "Long::parseLong - Value less than zero, but no minus sign.");
         }
     }
 
@@ -252,13 +230,13 @@ long long Long::parse( const std::string
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-long long Long::reverseBytes( long long value ) {
+long long Long::reverseBytes(long long value) {
 
-    if( value == 0 ) {
+    if (value == 0) {
         return 0;
     }
 
-    unsigned long long uvalue = (unsigned long long)value;
+    unsigned long long uvalue = (unsigned long long) value;
 
     long long b7 = (uvalue >> 56);
     long long b6 = (uvalue >> 40) & 0xFF00ULL;
@@ -268,66 +246,63 @@ long long Long::reverseBytes( long long 
     long long b2 = (uvalue & 0xFF0000ULL) << 24;
     long long b1 = (uvalue & 0xFF00ULL) << 40;
     long long b0 = (uvalue << 56);
-    return ( b0 | b1 | b2 | b3 | b4 | b5 | b6 | b7 );
+    return (b0 | b1 | b2 | b3 | b4 | b5 | b6 | b7);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-long long Long::reverse( long long value ) {
+long long Long::reverse(long long value) {
 
-    if( value == 0 ) {
+    if (value == 0) {
         return 0;
     }
 
-    unsigned long long uvalue = (unsigned long long)value;
+    unsigned long long uvalue = (unsigned long long) value;
 
     // From Hacker's Delight, 7-1, Figure 7-1
-    uvalue = ( ( uvalue & 0x5555555555555555ULL ) << 1 ) | ( (uvalue >> 1) &
-             0x5555555555555555ULL );
-    uvalue = ( ( uvalue & 0x3333333333333333ULL ) << 2 ) | ( (uvalue >> 2) &
-             0x3333333333333333ULL );
-    uvalue = ( ( uvalue & 0x0F0F0F0F0F0F0F0FULL ) << 4 ) | ( (uvalue >> 4) &
-             0x0F0F0F0F0F0F0F0FULL );
+    uvalue = ((uvalue & 0x5555555555555555ULL) << 1) | ((uvalue >> 1) & 0x5555555555555555ULL);
+    uvalue = ((uvalue & 0x3333333333333333ULL) << 2) | ((uvalue >> 2) & 0x3333333333333333ULL);
+    uvalue = ((uvalue & 0x0F0F0F0F0F0F0F0FULL) << 4) | ((uvalue >> 4) & 0x0F0F0F0F0F0F0F0FULL);
 
-    return reverseBytes( uvalue );
+    return reverseBytes(uvalue);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-long long Long::rotateLeft( long long value, int distance ) {
-    unsigned long long i = (unsigned long long)value;
+long long Long::rotateLeft(long long value, int distance) {
+    unsigned long long i = (unsigned long long) value;
     int j = distance & 0x1F;
-    return ( i << j ) | ( i >> (-j & 0x1F ) );
+    return (i << j) | (i >> (-j & 0x1F));
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-long long Long::rotateRight( long long value, int distance ) {
-    unsigned long long i = (unsigned long long)value;
+long long Long::rotateRight(long long value, int distance) {
+    unsigned long long i = (unsigned long long) value;
     int j = distance & 0x1F;
-    return ( i >> j ) | ( i << (-j & 0x1F ) );
+    return (i >> j) | (i << (-j & 0x1F));
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-int Long::signum( long long value ) {
-    return ( value == 0 ? 0 : ( value < 0 ? -1 : 1 ) );
+int Long::signum(long long value) {
+    return (value == 0 ? 0 : (value < 0 ? -1 : 1));
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 std::string Long::toString() const {
-    return Long::toString( this->value, 10 );
+    return Long::toString(this->value, 10);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string Long::toString( long long value ) {
-    return Long::toString( value, 10 );
+std::string Long::toString(long long value) {
+    return Long::toString(value, 10);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string Long::toString( long long value, int radix ) {
+std::string Long::toString(long long value, int radix) {
 
-    if( radix < Character::MIN_RADIX || radix > Character::MAX_RADIX ) {
+    if (radix < Character::MIN_RADIX || radix > Character::MAX_RADIX) {
         radix = 10;
     }
 
-    if( value == 0 ) {
+    if (value == 0) {
         return "0";
     }
 
@@ -335,12 +310,12 @@ std::string Long::toString( long long va
     long long j = value;
     bool negative = value < 0;
 
-    if( !negative ) {
+    if (!negative) {
         count = 1;
         j = -value;
     }
 
-    while( (value /= radix) != 0 ) {
+    while ((value /= radix) != 0) {
         count++;
     }
 
@@ -350,37 +325,37 @@ std::string Long::toString( long long va
     char* buffer = new char[length + 1];
 
     do {
-        int ch = (int)( 0 - ( j % radix ) );
-        if( ch > 9 ) {
+        int ch = (int) (0 - (j % radix));
+        if (ch > 9) {
             ch = ch - 10 + 'a';
         } else {
             ch += '0';
         }
-        buffer[--count] = (char)ch;
-    } while( (j /= radix) != 0 );
+        buffer[--count] = (char) ch;
+    } while ((j /= radix) != 0);
 
-    if( negative ) {
+    if (negative) {
         buffer[0] = '-';
     }
 
     // Ensure there's a null
     buffer[length] = 0;
-    std::string result( &buffer[0] );
-    delete [] buffer;
+    std::string result(&buffer[0]);
+    delete[] buffer;
 
     return result;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string Long::toBinaryString( long long value ) {
+std::string Long::toBinaryString(long long value) {
 
     int count = 1;
     long long j = value;
 
-    if( value < 0 ) {
-        count = 64;  // 8 * sizeof(long long);
+    if (value < 0) {
+        count = 64; // 8 * sizeof(long long);
     } else {
-        while ( (j >>= 1) != 0) {
+        while ((j >>= 1) != 0) {
             count++;
         }
     }
@@ -391,29 +366,29 @@ std::string Long::toBinaryString( long l
     char* buffer = new char[length + 1];
 
     do {
-        buffer[--count] = (char)( (value & 1) + '0' );
+        buffer[--count] = (char) ((value & 1) + '0');
         value >>= 1;
-    } while( count > 0 );
+    } while (count > 0);
 
     // Ensure there's a null
     buffer[length] = 0;
-    std::string result( &buffer[0] );
-    delete [] buffer;
+    std::string result(&buffer[0]);
+    delete[] buffer;
 
     return result;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string Long::toOctalString( long long value ) {
+std::string Long::toOctalString(long long value) {
 
     int count = 1;
     long long j = value;
     unsigned long long uvalue = (unsigned long long) value;
 
-    if( value < 0 ) {
+    if (value < 0) {
         count = 22; // (8 * sizeof(long long) + 2) / 3;
     } else {
-        while ( (j >>= 3) != 0 ) {
+        while ((j >>= 3) != 0) {
             count++;
         }
     }
@@ -424,28 +399,28 @@ std::string Long::toOctalString( long lo
     char* buffer = new char[length + 1];
 
     do {
-        buffer[--count] = (char)( (uvalue & 7) + '0' );
+        buffer[--count] = (char) ((uvalue & 7) + '0');
         uvalue >>= 3;
-    } while( count > 0 );
+    } while (count > 0);
 
     // Ensure there's a null
     buffer[length] = 0;
-    std::string result( &buffer[0] );
-    delete [] buffer;
+    std::string result(&buffer[0]);
+    delete[] buffer;
 
     return result;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-std::string Long::toHexString( long long value ) {
+std::string Long::toHexString(long long value) {
 
     int count = 1;
     long long j = value;
 
-    if( value < 0 ) {
+    if (value < 0) {
         count = 16; // 8 * sizeof(long long) / 4
     } else {
-        while( (j >>= 4) != 0 ) {
+        while ((j >>= 4) != 0) {
             count++;
         }
     }
@@ -456,32 +431,30 @@ std::string Long::toHexString( long long
     char* buffer = new char[length + 1];
 
     do {
-        int t = (int)( value & 15 );
-        if( t > 9 ) {
+        int t = (int) (value & 15);
+        if (t > 9) {
             t = t - 10 + 'a';
         } else {
             t += '0';
         }
-        buffer[--count] = (char)t;
+        buffer[--count] = (char) t;
         value >>= 4;
-    } while( count > 0 );
+    } while (count > 0);
 
     // Ensure there's a null
     buffer[length] = 0;
-    std::string result( &buffer[0] );
-    delete [] buffer;
+    std::string result(&buffer[0]);
+    delete[] buffer;
 
     return result;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Long Long::valueOf( const std::string& value ) {
-
-    return Long( Long::parseLong( value ) );
+Long Long::valueOf(const std::string& value) {
+    return Long(Long::parseLong(value));
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-Long Long::valueOf( const std::string& value, int radix ) {
-
-    return Long( Long::parseLong( value, radix ) );
+Long Long::valueOf(const std::string& value, int radix) {
+    return Long(Long::parseLong(value, radix));
 }



Mime
View raw message