You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2012/11/05 21:55:41 UTC
svn commit: r1405952 - in
/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf: lang/Boolean.cpp
lang/Boolean.h lang/Byte.h lang/Runtime.h util/Random.cpp util/Random.h
util/StringTokenizer.cpp util/StringTokenizer.h util/UUID.cpp util/UUID.h
Author: tabish
Date: Mon Nov 5 20:55:40 2012
New Revision: 1405952
URL: http://svn.apache.org/viewvc?rev=1405952&view=rev
Log:
Clean up some code, hide copy and assignment when not allowed, and remove some includes not needed in headers.
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Boolean.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Boolean.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Byte.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Runtime.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Random.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Random.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StringTokenizer.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StringTokenizer.h
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.cpp
activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.h
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=1405952&r1=1405951&r2=1405952&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 Mon Nov 5 20:55:40 2012
@@ -24,23 +24,23 @@ using namespace decaf;
using namespace decaf::lang;
////////////////////////////////////////////////////////////////////////////////
-const Boolean Boolean::_FALSE( false );
-const Boolean Boolean::_TRUE( true );
+const Boolean Boolean::_FALSE(false);
+const Boolean Boolean::_TRUE(true);
////////////////////////////////////////////////////////////////////////////////
-Boolean::Boolean( bool value ) : value(value) {
+Boolean::Boolean(bool value) : value(value) {
}
////////////////////////////////////////////////////////////////////////////////
-Boolean::Boolean( const std::string& value ) : value(false) {
- this->value = parseBoolean( value );
+Boolean::Boolean(const std::string& value) : value(false) {
+ this->value = parseBoolean(value);
}
////////////////////////////////////////////////////////////////////////////////
-int Boolean::compareTo( const Boolean& b ) const {
- if( this->value == b.value ) {
+int Boolean::compareTo(const Boolean& b) const {
+ if (this->value == b.value) {
return 0;
- } else if( this->value && !b.value ) {
+ } else if (this->value && !b.value) {
return 1;
} else {
return -1;
@@ -48,20 +48,20 @@ int Boolean::compareTo( const Boolean& b
}
////////////////////////////////////////////////////////////////////////////////
-bool Boolean::operator==( const Boolean& b ) const {
+bool Boolean::operator==(const Boolean& b) const {
return this->value == b.value;
}
////////////////////////////////////////////////////////////////////////////////
-bool Boolean::operator<( const Boolean& b ) const {
+bool Boolean::operator<(const Boolean& b) const {
return this->value < b.value;
}
////////////////////////////////////////////////////////////////////////////////
-int Boolean::compareTo( const bool& b ) const {
- if( this->value == b ) {
+int Boolean::compareTo(const bool& b) const {
+ if (this->value == b) {
return 0;
- } else if( this->value && !b ) {
+ } else if (this->value && !b) {
return 1;
} else {
return -1;
@@ -69,12 +69,12 @@ int Boolean::compareTo( const bool& b )
}
////////////////////////////////////////////////////////////////////////////////
-bool Boolean::operator==( const bool& b ) const {
+bool Boolean::operator==(const bool& b) const {
return this->value == b;
}
////////////////////////////////////////////////////////////////////////////////
-bool Boolean::operator<( const bool& b ) const {
+bool Boolean::operator<(const bool& b) const {
return this->value < b;
}
@@ -84,21 +84,21 @@ std::string Boolean::toString() const {
}
////////////////////////////////////////////////////////////////////////////////
-Boolean Boolean::valueOf( const std::string& value ) {
- return Boolean( value );
+Boolean Boolean::valueOf(const std::string& value) {
+ return Boolean(value);
}
////////////////////////////////////////////////////////////////////////////////
-Boolean Boolean::valueOf( bool value ) {
- return Boolean( value );
+Boolean Boolean::valueOf(bool value) {
+ return Boolean(value);
}
////////////////////////////////////////////////////////////////////////////////
-bool Boolean::parseBoolean( const std::string& value ) {
- return apr_strnatcasecmp( value.c_str(), "true" ) == 0;
+bool Boolean::parseBoolean(const std::string& value) {
+ return apr_strnatcasecmp(value.c_str(), "true") == 0;
}
////////////////////////////////////////////////////////////////////////////////
-std::string Boolean::toString( bool value ) {
+std::string Boolean::toString(bool value) {
return value ? "true" : "false";
}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Boolean.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Boolean.h?rev=1405952&r1=1405951&r2=1405952&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Boolean.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Boolean.h Mon Nov 5 20:55:40 2012
@@ -49,12 +49,12 @@ namespace lang{
/**
* @param value - primitive boolean to wrap.
*/
- Boolean( bool value );
+ Boolean(bool value);
/**
* @param value - String value to convert to a boolean.
*/
- Boolean( const std::string& value );
+ Boolean(const std::string& value);
virtual ~Boolean() {}
@@ -78,14 +78,14 @@ namespace lang{
* argument represents false; and a negative value if this object
* represents false and the argument represents true
*/
- virtual int compareTo( const Boolean& b ) const;
+ virtual int compareTo(const Boolean& b) const;
/**
* Compares equality between this object and the one passed.
* @param value - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator==( const Boolean& value ) const;
+ virtual bool operator==(const Boolean& value) const;
/**
* Compares this object to another and returns true if this object
@@ -93,12 +93,12 @@ namespace lang{
* @param value - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator<( const Boolean& value ) const;
+ virtual bool operator<(const Boolean& value) const;
/**
* @returns true if the two Boolean Objects have the same value.
*/
- bool equals( const Boolean& b ) const {
+ bool equals(const Boolean& b) const {
return this->value == b.value;
}
@@ -110,14 +110,14 @@ namespace lang{
* argument represents false; and a negative value if this object
* represents false and the argument represents true
*/
- virtual int compareTo( const bool& b ) const;
+ virtual int compareTo(const bool& b) const;
/**
* Compares equality between this object and the one passed.
* @param value - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator==( const bool& value ) const;
+ virtual bool operator==(const bool& value) const;
/**
* Compares this object to another and returns true if this object
@@ -125,16 +125,17 @@ namespace lang{
* @param value - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator<( const bool& value ) const;
+ virtual bool operator<(const bool& value) const;
/**
* @returns true if the two Boolean Objects have the same value.
*/
- bool equals( const bool& b ) const {
+ bool equals(const bool& b) const {
return this->value == b;
}
- public: // Statics
+ public:
+ // Statics
/**
* @param value
@@ -142,7 +143,7 @@ namespace lang{
*
* @returns a Boolean instance of the primitive boolean value
*/
- static Boolean valueOf( bool value );
+ static Boolean valueOf(bool value);
/**
* @param value
@@ -150,7 +151,7 @@ namespace lang{
*
* @returns a Boolean instance of the string value
*/
- static Boolean valueOf( const std::string& value );
+ static Boolean valueOf(const std::string& value);
/**
* Parses the String passed and extracts an bool.
@@ -159,7 +160,7 @@ namespace lang{
* The std::string value to parse
* @return bool value
*/
- static bool parseBoolean( const std::string& value );
+ static bool parseBoolean(const std::string& value);
/**
* Converts the bool to a String representation.
@@ -168,7 +169,7 @@ namespace lang{
*
* @return std::string representation of the bool value passed.
*/
- static std::string toString( bool value );
+ static std::string toString(bool 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=1405952&r1=1405951&r2=1405952&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 Mon Nov 5 20:55:40 2012
@@ -50,7 +50,7 @@ namespace lang{
/**
* @param value - the primitive value to wrap
*/
- Byte( unsigned char value );
+ Byte(unsigned char value);
/**
* Creates a new Byte instance from the given string.
@@ -60,7 +60,7 @@ namespace lang{
*
* @throws NumberFormatException if the string is not a valid byte.
*/
- Byte( const std::string& value );
+ Byte(const std::string& value);
virtual ~Byte() {}
@@ -72,7 +72,7 @@ namespace lang{
* than the passed in value, and -1 if this object repesents a value
* less than the passed in value.
*/
- virtual int compareTo( const Byte& c ) const {
+ virtual int compareTo(const Byte& c) const {
return this->value < c.value ? -1 : (this->value > c.value) ? 1 : 0;
}
@@ -81,7 +81,7 @@ namespace lang{
* @param c - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator==( const Byte& c ) const {
+ virtual bool operator==(const Byte& c) const {
return this->value == c.value;
}
@@ -91,7 +91,7 @@ namespace lang{
* @param c - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator<( const Byte& c ) const {
+ virtual bool operator<(const Byte& c) const {
return this->value < c.value;
}
@@ -103,7 +103,7 @@ namespace lang{
* than the passed in value, and -1 if this object repesents a value
* less than the passed in value.
*/
- virtual int compareTo( const unsigned char& c ) const {
+ virtual int compareTo(const unsigned char& c) const {
return this->value < c ? -1 : (this->value > c) ? 1 : 0;
}
@@ -112,7 +112,7 @@ namespace lang{
* @param c - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator==( const unsigned char& c ) const {
+ virtual bool operator==(const unsigned char& c) const {
return this->value == c;
}
@@ -122,21 +122,21 @@ namespace lang{
* @param c - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator<( const unsigned char& c ) const {
+ virtual bool operator<(const unsigned char& c) const {
return this->value < c;
}
/**
* @returns true if the two Byte Objects have the same value.
*/
- bool equals( const Byte& c ) const {
+ bool equals(const Byte& c) const {
return this->value == c.value;
}
/**
* @returns true if the two Bytes have the same value.
*/
- bool equals( const unsigned char& c ) const {
+ bool equals(const unsigned char& c) const {
return this->value == c;
}
@@ -150,7 +150,7 @@ namespace lang{
* @return double the value of the receiver.
*/
virtual double doubleValue() const {
- return (double)this->value;
+ return (double) this->value;
}
/**
@@ -158,7 +158,7 @@ namespace lang{
* @return float the value of the receiver.
*/
virtual float floatValue() const {
- return (float)this->value;
+ return (float) this->value;
}
/**
@@ -174,7 +174,7 @@ namespace lang{
* @return short the value of the receiver.
*/
virtual short shortValue() const {
- return (short)this->value;
+ return (short) this->value;
}
/**
@@ -182,7 +182,7 @@ namespace lang{
* @return int the value of the receiver.
*/
virtual int intValue() const {
- return (int)this->value;
+ return (int) this->value;
}
/**
@@ -190,15 +190,15 @@ namespace lang{
* @return long 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
/**
* @returns a string representing the primitive value as Base 10
*/
- static std::string toString( unsigned char value );
+ static std::string toString(unsigned char value);
/**
* Decodes a String into a Byte. Accepts decimal, hexadecimal, and octal
@@ -215,7 +215,7 @@ namespace lang{
* @returns a Byte object containing the decoded value
* @throws NumberFomatException if the string is not formatted correctly.
*/
- static Byte decode( const std::string& value );
+ static Byte decode(const std::string& value);
/**
* Parses the string argument as a signed unsigned char in the radix specified by
@@ -242,7 +242,7 @@ namespace lang{
* @throws NumberFormatException - If String does not contain a parsable
* unsigned char.
*/
- static unsigned char parseByte( const std::string& s, int radix );
+ static unsigned char parseByte(const std::string& s, int radix);
/**
* Parses the string argument as a signed decimal unsigned char. The
@@ -255,15 +255,15 @@ namespace lang{
* @returns the converted unsigned char value
* @throws NumberFormatException if the string is not a unsigned char.
*/
- static unsigned char parseByte( const std::string& s );
+ static unsigned char parseByte(const std::string& s);
/**
* Returns a Character instance representing the specified char value.
* @param value - the primitive char to wrap.
* @returns a new Character instance that wraps this value.
*/
- static Byte valueOf( unsigned char value ) {
- return Byte( value );
+ static Byte valueOf(unsigned char value) {
+ return Byte(value);
}
/**
@@ -276,7 +276,7 @@ namespace lang{
* @return new Byte Object wrapping the primitive
* @throws NumberFormatException if the string is not a decimal unsigned char.
*/
- static Byte valueOf( const std::string& value );
+ static Byte valueOf(const std::string& value);
/**
* Returns a Byte object holding the value extracted from the specified
@@ -291,7 +291,7 @@ namespace lang{
* @return new Byte Object wrapping the primitive
* @throws NumberFormatException if the string is not a valid unsigned char.
*/
- static Byte valueOf( const std::string& value, int radix );
+ static Byte valueOf(const std::string& value, int radix);
};
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Runtime.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Runtime.h?rev=1405952&r1=1405951&r2=1405952&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Runtime.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Runtime.h Mon Nov 5 20:55:40 2012
@@ -24,6 +24,15 @@ namespace decaf {
namespace lang {
class DECAF_API Runtime {
+ private:
+
+ Runtime(const Runtime&);
+ Runtime& operator= (const Runtime&);
+
+ protected:
+
+ Runtime() {}
+
public:
virtual ~Runtime() {}
@@ -46,7 +55,7 @@ namespace lang {
* @throws runtime_error if the library is already initialized or an
* error occurs during initialization.
*/
- static void initializeRuntime( int argc, char **argv );
+ static void initializeRuntime(int argc, char **argv);
/**
* Initialize the Decaf Library
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Random.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Random.cpp?rev=1405952&r1=1405951&r2=1405952&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Random.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Random.cpp Mon Nov 5 20:55:40 2012
@@ -35,8 +35,8 @@ Random::Random() : haveNextNextGaussian(
}
////////////////////////////////////////////////////////////////////////////////
-Random::Random( unsigned long long seed ) : haveNextNextGaussian(false), seed(0), nextNextGaussian(0) {
- setSeed( seed );
+Random::Random(unsigned long long seed) : haveNextNextGaussian(false), seed(0), nextNextGaussian(0) {
+ setSeed(seed);
}
////////////////////////////////////////////////////////////////////////////////
@@ -45,46 +45,46 @@ Random::~Random() {
////////////////////////////////////////////////////////////////////////////////
bool Random::nextBoolean() {
- return next( 1 ) != 0;
+ return next(1) != 0;
}
////////////////////////////////////////////////////////////////////////////////
-void Random::nextBytes( std::vector<unsigned char>& buf ) {
+void Random::nextBytes(std::vector<unsigned char>& buf) {
- try{
+ try {
- if( buf.empty() ) {
+ if (buf.empty()) {
return;
}
- this->nextBytes( &buf[0], (int)buf.size() );
+ this->nextBytes(&buf[0], (int) buf.size());
}
- DECAF_CATCH_RETHROW( NullPointerException )
- DECAF_CATCH_RETHROW( IllegalArgumentException )
- DECAF_CATCHALL_THROW( Exception )
+ DECAF_CATCH_RETHROW(NullPointerException)
+ DECAF_CATCH_RETHROW(IllegalArgumentException)
+ DECAF_CATCHALL_THROW(Exception)
}
////////////////////////////////////////////////////////////////////////////////
-void Random::nextBytes( unsigned char* buf, int size ) {
+void Random::nextBytes(unsigned char* buf, int size) {
- if( buf == NULL ) {
- throw NullPointerException( __FILE__, __LINE__, "Buffer passed cannot be NULL." );
+ if (buf == NULL) {
+ throw NullPointerException(__FILE__, __LINE__, "Buffer passed cannot be NULL.");
}
- if( size < 0 ) {
- throw IllegalArgumentException( __FILE__, __LINE__, "Specified buffer size was negative." );
+ if (size < 0) {
+ throw IllegalArgumentException(__FILE__, __LINE__, "Specified buffer size was negative.");
}
int rand = 0;
int count = 0, loop = 0;
- while( count < size ) {
- if( loop == 0 ) {
+ while (count < size) {
+ if (loop == 0) {
rand = nextInt();
loop = 3;
} else {
loop--;
}
- buf[count++] = (unsigned char)rand;
+ buf[count++] = (unsigned char) rand;
rand >>= 8;
}
}
@@ -94,18 +94,18 @@ double Random::nextDouble() {
long long divisor = 1LL;
divisor <<= 31;
divisor <<= 22;
- return ( (double)( ( (long long) next(26) << 27) + next(27)) / (double) divisor);
+ return ((double) (((long long) next(26) << 27) + next(27)) / (double) divisor);
}
////////////////////////////////////////////////////////////////////////////////
float Random::nextFloat() {
- return ( next(24) / 16777216.0f );
+ return (next(24) / 16777216.0f);
}
////////////////////////////////////////////////////////////////////////////////
double Random::nextGaussian() {
- if( haveNextNextGaussian ) {
+ if (haveNextNextGaussian) {
// if X1 has been returned, return the second Gaussian
haveNextNextGaussian = false;
return nextNextGaussian;
@@ -117,8 +117,8 @@ double Random::nextGaussian() {
v1 = 2 * nextDouble() - 1;
v2 = 2 * nextDouble() - 1;
s = v1 * v1 + v2 * v2;
- } while( s >= 1 );
- double norm = std::sqrt( -2 * std::log(s) / s );
+ } while (s >= 1);
+ double norm = std::sqrt(-2 * std::log(s) / s);
// should that not be norm instead of multiplier ?
nextNextGaussian = v2 * norm;
haveNextNextGaussian = true;
@@ -128,53 +128,52 @@ double Random::nextGaussian() {
////////////////////////////////////////////////////////////////////////////////
int Random::nextInt() {
- return next( 32 );
+ return next(32);
}
////////////////////////////////////////////////////////////////////////////////
-int Random::nextInt( int n ) {
+int Random::nextInt(int n) {
- if( n > 0 ) {
+ if (n > 0) {
- if( ( n & -n ) == n ) {
- return (int)( ( n * (long long)next( 31 ) ) >> 31 );
+ if ((n & -n) == n) {
+ return (int) ((n * (long long) next(31)) >> 31);
}
int bits, val;
do {
- bits = next( 31 );
+ bits = next(31);
val = bits % n;
- } while( bits - val + ( n - 1 ) < 0 );
+ } while (bits - val + (n - 1) < 0);
return val;
}
throw exceptions::IllegalArgumentException(
- __FILE__, __LINE__,
- "Value passed cannot be less than or equal to zero." );
+ __FILE__, __LINE__, "Value passed cannot be less than or equal to zero.");
}
////////////////////////////////////////////////////////////////////////////////
long long Random::nextLong() {
- return ( (long long) next(32) << 32 ) + next(32);
+ return ((long long) next(32) << 32) + next(32);
}
////////////////////////////////////////////////////////////////////////////////
-void Random::setSeed( unsigned long long seed ) {
+void Random::setSeed(unsigned long long seed) {
unsigned long long mask = 1ULL;
mask <<= 31;
mask <<= 17;
- this->seed = ( seed ^ multiplier ) & ( mask - 1 );
+ this->seed = (seed ^ multiplier) & (mask - 1);
haveNextNextGaussian = false;
}
////////////////////////////////////////////////////////////////////////////////
-int Random::next( int bits ) {
+int Random::next(int bits) {
long long mask = 1L;
mask <<= 31;
mask <<= 17;
- seed = ( seed * multiplier + 0xbL ) & ( mask - 1 );
+ seed = (seed * multiplier + 0xbL) & (mask - 1);
// was: return (int) (seed >>> (48 - bits));
- return (int)( seed >> (48 - bits) );
+ return (int) (seed >> (48 - bits));
}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Random.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Random.h?rev=1405952&r1=1405951&r2=1405952&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Random.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/Random.h Mon Nov 5 20:55:40 2012
@@ -73,7 +73,7 @@ namespace util{
*
* @see #setSeed
*/
- Random( unsigned long long seed );
+ Random(unsigned long long seed);
virtual ~Random();
@@ -146,7 +146,7 @@ namespace util{
*
* @throws IllegalArgumentException if n is less than or equal to zero.
*/
- int nextInt( int n );
+ int nextInt(int n);
/**
* Generates a uniformly distributed 64-bit <code>int</code> value
@@ -160,7 +160,7 @@ namespace util{
*/
long long nextLong();
- public: // Virtual Methods
+ public: // Virtual Methods
/**
* Modifies the byte array by a random sequence of bytes generated
@@ -170,7 +170,7 @@ namespace util{
*
* @see #next
*/
- virtual void nextBytes( std::vector<unsigned char>& buf );
+ virtual void nextBytes(std::vector<unsigned char>& buf);
/**
* Modifies the byte array by a random sequence of bytes generated
@@ -183,7 +183,7 @@ namespace util{
* @throw NullPointerException if buff is NULL
* @throw IllegalArgumentException if size is negative
*/
- virtual void nextBytes( unsigned char* buf, int size );
+ virtual void nextBytes(unsigned char* buf, int size);
/**
* Modifies the seed using linear congruential formula presented
@@ -197,9 +197,9 @@ namespace util{
* @see #Random()
* @see #Random(long)
*/
- virtual void setSeed( unsigned long long seed );
+ virtual void setSeed(unsigned long long seed);
- protected: // Virtual method used by all non-virtual methods in Random.
+ protected: // Virtual method used by all non-virtual methods in Random.
/**
* Answers a pseudo-random uniformly distributed <code>int</code>
@@ -219,7 +219,7 @@ namespace util{
* @see #nextGaussian
* @see #nextLong
*/
- virtual int next( int bits );
+ virtual int next(int bits);
};
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StringTokenizer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StringTokenizer.cpp?rev=1405952&r1=1405951&r2=1405952&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StringTokenizer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StringTokenizer.cpp Mon Nov 5 20:55:40 2012
@@ -16,6 +16,8 @@
*/
#include "StringTokenizer.h"
+#include <decaf/util/NoSuchElementException.h>
+
using namespace std;
using namespace decaf;
using namespace decaf::util;
@@ -23,12 +25,12 @@ using namespace decaf::lang;
using namespace decaf::lang::exceptions;
////////////////////////////////////////////////////////////////////////////////
-StringTokenizer::StringTokenizer( const std::string& str, const std::string& delim, bool returnDelims ) :
+StringTokenizer::StringTokenizer(const std::string& str, const std::string& delim, bool returnDelims) :
str(str), delim(delim), pos(0), returnDelims(returnDelims) {
}
////////////////////////////////////////////////////////////////////////////////
-StringTokenizer::~StringTokenizer(){
+StringTokenizer::~StringTokenizer() {
}
////////////////////////////////////////////////////////////////////////////////
@@ -38,9 +40,9 @@ int StringTokenizer::countTokens() const
string::size_type localPos = pos;
string::size_type lastPos = pos;
- while( localPos != string::npos ) {
+ while (localPos != string::npos) {
- if( returnDelims && str.find_first_of( delim, localPos ) == localPos ) {
+ if (returnDelims && str.find_first_of(delim, localPos) == localPos) {
count += 1;
localPos += 1;
continue;
@@ -49,10 +51,10 @@ int StringTokenizer::countTokens() const
// Find first token by spanning the fist non-delimiter, to the
// next delimiter, skipping any delimiters that are at the curret
// location.
- lastPos = str.find_first_not_of( delim, localPos );
- localPos = str.find_first_of( delim, lastPos );
+ lastPos = str.find_first_not_of(delim, localPos);
+ localPos = str.find_first_of(delim, lastPos);
- if( lastPos != string::npos ) {
+ if (lastPos != string::npos) {
count++;
}
}
@@ -62,64 +64,57 @@ int StringTokenizer::countTokens() const
////////////////////////////////////////////////////////////////////////////////
bool StringTokenizer::hasMoreTokens() const {
- string::size_type nextpos =
- returnDelims ? str.find_first_of( delim, pos ) :
- str.find_first_not_of( delim, pos );
+ string::size_type nextpos = returnDelims ? str.find_first_of(delim, pos) : str.find_first_not_of(delim, pos);
- return ( nextpos != string::npos );
+ return (nextpos != string::npos);
}
////////////////////////////////////////////////////////////////////////////////
std::string StringTokenizer::nextToken() {
- if( pos == string::npos ) {
- throw NoSuchElementException(
- __FILE__, __LINE__,
- "StringTokenizer::nextToken - No more Tokens available");
+ if (pos == string::npos) {
+ throw NoSuchElementException(__FILE__, __LINE__, "StringTokenizer::nextToken - No more Tokens available");
}
- if( returnDelims ) {
+ if (returnDelims) {
// if char at current pos is a delim return it and advance pos
- if( str.find_first_of( delim, pos ) == pos ) {
- return str.substr( pos++, 1 );
+ if (str.find_first_of(delim, pos) == pos) {
+ return str.substr(pos++, 1);
}
}
// Skip delimiters at beginning.
- string::size_type lastPos = str.find_first_not_of( delim, pos );
+ string::size_type lastPos = str.find_first_not_of(delim, pos);
// Find the next delimiter in the string, the charactors in between
// will be the token to return. If this returns string::npos then
// there are no more delimiters in the string.
- pos = str.find_first_of( delim, lastPos );
+ pos = str.find_first_of(delim, lastPos);
- if( string::npos != lastPos ) {
+ if (string::npos != lastPos) {
// Found a token, count it, if the pos of the next delim is npos
// then we set length to copy to npos so that all the remianing
// portion of the string is copied, otherwise we set it to the
- return str.substr( lastPos,
- pos == string::npos ? pos : pos-lastPos );
+ return str.substr(lastPos, pos == string::npos ? pos : pos - lastPos);
} else {
- throw NoSuchElementException(
- __FILE__, __LINE__,
- "StringTokenizer::nextToken - No more Tokens available" );
+ throw NoSuchElementException(__FILE__, __LINE__, "StringTokenizer::nextToken - No more Tokens available");
}
}
////////////////////////////////////////////////////////////////////////////////
-std::string StringTokenizer::nextToken( const std::string& delim ) {
+std::string StringTokenizer::nextToken(const std::string& delim) {
this->delim = delim;
return nextToken();
}
////////////////////////////////////////////////////////////////////////////////
-unsigned int StringTokenizer::toArray( std::vector<std::string>& array ) {
+unsigned int StringTokenizer::toArray(std::vector<std::string>& array) {
int count = 0;
- while( hasMoreTokens() ) {
- array.push_back( nextToken() );
+ while (hasMoreTokens()) {
+ array.push_back(nextToken());
count++;
}
@@ -127,13 +122,13 @@ unsigned int StringTokenizer::toArray( s
}
////////////////////////////////////////////////////////////////////////////////
-void StringTokenizer::reset( const std::string& str, const std::string& delim, bool returnDelims ) {
+void StringTokenizer::reset(const std::string& str, const std::string& delim, bool returnDelims) {
- if( str != "" ) {
+ if (str != "") {
this->str = str;
}
- if( delim != "" ) {
+ if (delim != "") {
this->delim = delim;
}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StringTokenizer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StringTokenizer.h?rev=1405952&r1=1405951&r2=1405952&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StringTokenizer.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/StringTokenizer.h Mon Nov 5 20:55:40 2012
@@ -17,9 +17,10 @@
#ifndef _DECAF_UTIL_STRINGTOKENIZER_H_
#define _DECAF_UTIL_STRINGTOKENIZER_H_
-#include <decaf/util/NoSuchElementException.h>
#include <decaf/util/Config.h>
+#include <decaf/util/NoSuchElementException.h>
#include <string>
+#include <vector>
namespace decaf{
namespace util{
@@ -63,9 +64,7 @@ namespace util{
* @param delim - String containing the delimiters
* @param returnDelims - boolean indicating if the delimiters are returned as tokens
*/
- StringTokenizer( const std::string& str,
- const std::string& delim = " \t\n\r\f",
- bool returnDelims = false);
+ StringTokenizer(const std::string& str, const std::string& delim = " \t\n\r\f", bool returnDelims = false);
virtual ~StringTokenizer();
@@ -109,7 +108,7 @@ namespace util{
*
* @throws NoSuchElementException if there are no more tokens in this string.
*/
- virtual std::string nextToken( const std::string& delim );
+ virtual std::string nextToken(const std::string& delim);
/**
* Grab all remaining tokens in the String and return them
@@ -117,7 +116,7 @@ namespace util{
* @param array - vector to place token strings in
* @return number of string placed into the vector
*/
- virtual unsigned int toArray( std::vector< std::string >& array );
+ virtual unsigned int toArray(std::vector<std::string>& array);
/**
* Resets the Tokenizer's position in the String to the Beginning
@@ -139,9 +138,7 @@ namespace util{
* @param returnDelims
* Should the Tokenizer return delimiters as Tokens, default false
*/
- virtual void reset( const std::string& str = "",
- const std::string& delim = "",
- bool returnDelims = false );
+ virtual void reset(const std::string& str = "", const std::string& delim = "", bool returnDelims = false);
};
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=1405952&r1=1405951&r2=1405952&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 Mon Nov 5 20:55:40 2012
@@ -19,6 +19,8 @@
#include <apr_strings.h>
#include <apr_md5.h>
#include <decaf/lang/exceptions/RuntimeException.h>
+#include <decaf/lang/exceptions/UnsupportedOperationException.h>
+#include <decaf/lang/exceptions/IllegalArgumentException.h>
using namespace std;
using namespace decaf;
@@ -26,45 +28,44 @@ using namespace decaf::util;
using namespace decaf::lang;
////////////////////////////////////////////////////////////////////////////////
-UUID::UUID( long long mostSigBits, long long leastSigBits ) :
- apr_uuid(), mostSigBits(mostSigBits), leastSigBits(leastSigBits), uuidVersion(0) {
+UUID::UUID(long long mostSigBits, long long leastSigBits) :
+ apr_uuid(), mostSigBits(mostSigBits), leastSigBits(leastSigBits), uuidVersion(0) {
- memcpy( &apr_uuid.data[0], &mostSigBits, sizeof( long long ) );
- memcpy( &apr_uuid.data[sizeof(long long)], &leastSigBits, sizeof(long long ) );
+ memcpy(&apr_uuid.data[0], &mostSigBits, sizeof(long long));
+ memcpy(&apr_uuid.data[sizeof(long long)], &leastSigBits, sizeof(long long));
// Version indicator, set when a UUID is generated
- this->uuidVersion = (int)( mostSigBits & 0x000000000000F000LL ) >> 12;
+ this->uuidVersion = (int) (mostSigBits & 0x000000000000F000LL) >> 12;
}
////////////////////////////////////////////////////////////////////////////////
-UUID::~UUID() {
-}
+UUID::~UUID() {}
////////////////////////////////////////////////////////////////////////////////
-int UUID::compareTo( const UUID& value ) const {
- return apr_strnatcmp( this->toString().c_str(), value.toString().c_str() );
+int UUID::compareTo(const UUID& value) const {
+ return apr_strnatcmp(this->toString().c_str(), value.toString().c_str());
}
////////////////////////////////////////////////////////////////////////////////
-bool UUID::equals( const UUID& value ) const {
+bool UUID::equals(const UUID& value) const {
return this->getMostSignificantBits() == value.getMostSignificantBits() &&
this->getLeastSignificantBits() == value.getLeastSignificantBits();
}
////////////////////////////////////////////////////////////////////////////////
-bool UUID::operator==( const UUID& value ) const {
- return this->equals( value );
+bool UUID::operator==(const UUID& value) const {
+ return this->equals(value);
}
////////////////////////////////////////////////////////////////////////////////
-bool UUID::operator<( const UUID& value ) const {
- return this->compareTo( value ) == -1 ? true : false;
+bool UUID::operator<(const UUID& value) const {
+ return this->compareTo(value) == -1 ? true : false;
}
////////////////////////////////////////////////////////////////////////////////
std::string UUID::toString() const {
- char buffer[APR_UUID_FORMATTED_LENGTH+1] = {0};
- apr_uuid_format( &buffer[0], &apr_uuid );
+ char buffer[APR_UUID_FORMATTED_LENGTH + 1] = { 0 };
+ apr_uuid_format(&buffer[0], &apr_uuid);
return &buffer[0];
}
@@ -76,35 +77,33 @@ long long UUID::getLeastSignificantBits(
////////////////////////////////////////////////////////////////////////////////
long long UUID::getMostSignificantBits() const {
long long result = 0;
- memcpy( &result, &this->apr_uuid.data[sizeof(long long)], sizeof(long long) );
+ memcpy(&result, &this->apr_uuid.data[sizeof(long long)], sizeof(long long));
return this->mostSigBits;
}
////////////////////////////////////////////////////////////////////////////////
long long UUID::node() {
- if( this->version() != 1 ) {
+ if (this->version() != 1) {
throw exceptions::UnsupportedOperationException(
- __FILE__, __LINE__,
- "UUID::node - Only a Version 1 UUID supports this operation." );
+ __FILE__, __LINE__, "UUID::node - Only a Version 1 UUID supports this operation.");
}
- return ( this->leastSigBits & 0x0000FFFFFFFFFFFFULL );
+ return (this->leastSigBits & 0x0000FFFFFFFFFFFFULL);
}
////////////////////////////////////////////////////////////////////////////////
long long UUID::timestamp() {
- if( this->version() != 1 ) {
+ if (this->version() != 1) {
throw exceptions::UnsupportedOperationException(
- __FILE__, __LINE__,
- "UUID::node - Only a Version 1 UUID supports this operation." );
+ __FILE__, __LINE__, "UUID::node - Only a Version 1 UUID supports this operation.");
}
// Mask out the version and shift values around to make time.
- long long timeLow = ( mostSigBits & 0xFFFFFFFF00000000ULL) >> 32;
- long long timeMid = ( mostSigBits & 0x00000000FFFF0000ULL) << 16;
- long long timeHigh = ( mostSigBits & 0x0000000000000FFFULL) << 48;
+ long long timeLow = (mostSigBits & 0xFFFFFFFF00000000ULL) >> 32;
+ long long timeMid = (mostSigBits & 0x00000000FFFF0000ULL) << 16;
+ long long timeHigh = (mostSigBits & 0x0000000000000FFFULL) << 48;
return timeLow | timeMid | timeHigh;
}
@@ -112,25 +111,24 @@ long long UUID::timestamp() {
////////////////////////////////////////////////////////////////////////////////
int UUID::clockSequence() {
- if( this->version() != 1 ) {
+ if (this->version() != 1) {
throw exceptions::UnsupportedOperationException(
- __FILE__, __LINE__,
- "UUID::node - Only a Version 1 UUID supports this operation." );
+ __FILE__, __LINE__, "UUID::node - Only a Version 1 UUID supports this operation.");
}
- return (int)( ( this->leastSigBits & 0x3FFF000000000000ULL ) >> 48 );
+ return (int) ((this->leastSigBits & 0x3FFF000000000000ULL) >> 48);
}
////////////////////////////////////////////////////////////////////////////////
int UUID::variant() {
// determine variant field
- if( ( this->leastSigBits & 0x8000000000000000ULL ) == 0 ) {
+ if ((this->leastSigBits & 0x8000000000000000ULL) == 0) {
// MSB0 not set, NCS backwards compatibility variant
return 0;
- } else if( ( this->leastSigBits & 0x4000000000000000ULL ) != 0 ) {
+ } else if ((this->leastSigBits & 0x4000000000000000ULL) != 0) {
// MSB1 set, either MS reserved or future reserved
- return (int)( ( this->leastSigBits & 0xE000000000000000ULL ) >> 61 );
+ return (int) ((this->leastSigBits & 0xE000000000000000ULL) >> 61);
}
// MSB1 not set, RFC 4122 variant
@@ -147,7 +145,7 @@ UUID UUID::randomUUID() {
apr_uuid_t temp;
// Generate some random bytes.
- apr_uuid_get( &temp );
+ apr_uuid_get(&temp);
long long msb = 0;
long long lsb = 0;
@@ -172,23 +170,22 @@ UUID UUID::randomUUID() {
lsb |= (temp.data[14] & 0xFFLL) << 8;
lsb |= (temp.data[15] & 0xFFLL);
- return UUID( msb, lsb );
+ return UUID(msb, lsb);
}
////////////////////////////////////////////////////////////////////////////////
-UUID UUID::nameUUIDFromBytes( const std::vector<char>& name ) {
- return UUID::nameUUIDFromBytes( &name[0], name.size() );
+UUID UUID::nameUUIDFromBytes(const std::vector<char>& name) {
+ return UUID::nameUUIDFromBytes(&name[0], name.size());
}
////////////////////////////////////////////////////////////////////////////////
-UUID UUID::nameUUIDFromBytes( const char* name, std::size_t size ) {
+UUID UUID::nameUUIDFromBytes(const char* name, std::size_t size) {
apr_uuid_t temp;
- if( apr_md5( &temp.data[0], name, size ) != APR_SUCCESS ) {
+ if (apr_md5(&temp.data[0], name, size) != APR_SUCCESS) {
throw exceptions::RuntimeException(
- __FILE__, __LINE__,
- "UUID::nameUUIDFromBytes - Failed to run MD5 encoder." );
+ __FILE__, __LINE__, "UUID::nameUUIDFromBytes - Failed to run MD5 encoder.");
}
long long msb = 0;
@@ -214,27 +211,25 @@ UUID UUID::nameUUIDFromBytes( const char
lsb |= (temp.data[14] & 0xFFLL) << 8;
lsb |= (temp.data[15] & 0xFFLL);
- return UUID( msb, lsb );
+ return UUID(msb, lsb);
}
////////////////////////////////////////////////////////////////////////////////
-UUID UUID::fromString( const std::string& name ) {
+UUID UUID::fromString(const std::string& name) {
apr_uuid_t temp;
- if( apr_uuid_parse( &temp, name.c_str() ) != APR_SUCCESS ) {
+ if (apr_uuid_parse(&temp, name.c_str()) != APR_SUCCESS) {
throw lang::exceptions::IllegalArgumentException(
- __FILE__, __LINE__,
- "UUID::fromString - Invalid UUID String: ",
- name.c_str() );
+ __FILE__, __LINE__, "UUID::fromString - Invalid UUID String: ", name.c_str());
}
long long mostSigBits = 0;
long long leastSigBits = 0;
// Extract to data from the uuid data
- memcpy( &mostSigBits, &temp.data[0], sizeof(long long) );
- memcpy( &leastSigBits, &temp.data[sizeof(long long)], sizeof(long long) );
+ memcpy(&mostSigBits, &temp.data[0], sizeof(long long));
+ memcpy(&leastSigBits, &temp.data[sizeof(long long)], sizeof(long long));
- return UUID( mostSigBits, leastSigBits );
+ return UUID(mostSigBits, leastSigBits);
}
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.h?rev=1405952&r1=1405951&r2=1405952&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/UUID.h Mon Nov 5 20:55:40 2012
@@ -20,10 +20,9 @@
#include <decaf/util/Config.h>
#include <decaf/lang/Comparable.h>
-#include <decaf/lang/exceptions/UnsupportedOperationException.h>
-#include <decaf/lang/exceptions/IllegalArgumentException.h>
#include <apr_uuid.h>
#include <string>
+#include <vector>
namespace decaf{
namespace util{
@@ -98,7 +97,7 @@ namespace util{
*
* @return type 3 UUID
*/
- static UUID nameUUIDFromBytes( const std::vector<char>& name );
+ static UUID nameUUIDFromBytes(const std::vector<char>& name);
/**
* Static factory to retrieve a type 3 (name based) UUID based on the
@@ -111,7 +110,7 @@ namespace util{
*
* @return type 3 UUID
*/
- static UUID nameUUIDFromBytes( const char* name, std::size_t size );
+ static UUID nameUUIDFromBytes(const char* name, std::size_t size);
/**
* Creates a UUID from the string standard representation as described
@@ -124,7 +123,7 @@ namespace util{
*
* @throws IllegalArgumentException if the UUID string given is invalid.
*/
- static UUID fromString( const std::string& name );
+ static UUID fromString(const std::string& name);
public:
@@ -136,7 +135,7 @@ namespace util{
* @param mostSigBits
* @param leastSigBits
*/
- UUID( long long mostSigBits, long long leastSigBits );
+ UUID(long long mostSigBits, long long leastSigBits);
virtual ~UUID();
@@ -144,7 +143,7 @@ namespace util{
* Compare the given UUID to this one
* @param value - the UUID to compare to
*/
- virtual int compareTo( const UUID& value ) const;
+ virtual int compareTo(const UUID& value) const;
/**
* Compares this UUID to the one given, returns true if they are equal.
@@ -154,14 +153,14 @@ namespace util{
*
* @return true if UUIDs are the same.
*/
- virtual bool equals( const UUID& value ) const;
+ virtual bool equals(const UUID& value) const;
/**
* Compares equality between this object and the one passed.
* @param value - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator==( const UUID& value ) const;
+ virtual bool operator==(const UUID& value) const;
/**
* Compares this object to another and returns true if this object
@@ -169,7 +168,7 @@ namespace util{
* @param value - the value to be compared to this one.
* @return true if this object is equal to the one passed.
*/
- virtual bool operator<( const UUID& value ) const;
+ virtual bool operator<(const UUID& value) const;
/**
* Returns a String object representing this UUID. UUID's are formatted