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 2007/08/06 20:36:24 UTC
svn commit: r563220 - in /activemq/activemq-cpp/trunk/src/decaf/src:
main/decaf/util/UUID.cpp main/decaf/util/UUID.h test/decaf/util/UUIDTest.cpp
Author: tabish
Date: Mon Aug 6 11:36:23 2007
New Revision: 563220
URL: http://svn.apache.org/viewvc?view=rev&rev=563220
Log:
http://issues.apache.org/activemq/browse/AMQCPP-103
Implementing the UUID object
Modified:
activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.cpp
activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.h
activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/UUIDTest.cpp
Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.cpp?view=diff&rev=563220&r1=563219&r2=563220
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.cpp Mon Aug 6 11:36:23 2007
@@ -179,11 +179,16 @@
}
////////////////////////////////////////////////////////////////////////////////
-UUID UUID::nameUUIDFromBytes( const std::string& name DECAF_UNUSED ) {
+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 ) {
apr_uuid_t temp;
- if( apr_md5( &temp.data[0], name.c_str(), 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." );
Modified: activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.h?view=diff&rev=563220&r1=563219&r2=563220
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.h (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/main/decaf/util/UUID.h Mon Aug 6 11:36:23 2007
@@ -94,7 +94,16 @@
* @param name - a byte array to be used to construct a UUID.
* @return type 3 UUID
*/
- static UUID nameUUIDFromBytes( const std::string& name );
+ static UUID nameUUIDFromBytes( const std::vector<char>& name );
+
+ /**
+ * Static factory to retrieve a type 3 (name based) UUID based on the
+ * specified byte array.
+ * @param name - a byte array to be used to construct a UUID.
+ * @param size - the size of the byte array, or number of bytes to use.
+ * @return type 3 UUID
+ */
+ static UUID nameUUIDFromBytes( const char* name, std::size_t size );
/**
* Creates a UUID from the string standard representation as described
Modified: activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/UUIDTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/UUIDTest.cpp?view=diff&rev=563220&r1=563219&r2=563220
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/UUIDTest.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/test/decaf/util/UUIDTest.cpp Mon Aug 6 11:36:23 2007
@@ -29,8 +29,10 @@
////////////////////////////////////////////////////////////////////////////////
void UUIDTest::test() {
+ std::string bytes = "ASDASFSADGSDGSDASFA";
+
UUID randId = UUID::randomUUID();
- UUID bytesId = UUID::nameUUIDFromBytes( "ASDASFSADGSDGSDASFA" );
+ UUID bytesId = UUID::nameUUIDFromBytes( bytes.c_str(), bytes.size() );
CPPUNIT_ASSERT( !( randId == bytesId ) );
CPPUNIT_ASSERT( !( randId.equals( bytesId ) ) );
@@ -44,4 +46,8 @@
CPPUNIT_ASSERT( randId.variant() == 2 );
+ UUID fromBits( randId.getMostSignificantBits(),
+ randId.getLeastSignificantBits() );
+
+ CPPUNIT_ASSERT( randId.compareTo( fromBits) == 0 );
}