From ec05778d5718a7912e506764d443a78d6a6179e3 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 5 Nov 2012 22:41:51 +0000 Subject: Converted tabs to spaces with tabconv. --- src/unstable/uuid.cpp | 150 +++++++++++++++++++++++++------------------------- 1 file changed, 75 insertions(+), 75 deletions(-) (limited to 'src/unstable/uuid.cpp') diff --git a/src/unstable/uuid.cpp b/src/unstable/uuid.cpp index aef8bc0..5400f8f 100644 --- a/src/unstable/uuid.cpp +++ b/src/unstable/uuid.cpp @@ -18,25 +18,25 @@ Bu::Uuid::Uuid() { - clear(); + clear(); } Bu::Uuid::Uuid( const Uuid &src ) { - memcpy( data, src.data, 16 ); + memcpy( data, src.data, 16 ); } Bu::Uuid::Uuid( const Bu::String &sSrc ) { - if( sSrc.getSize() == 16 ) - { - memcpy( data, sSrc.getStr(), 16 ); - } - else if( sSrc.getSize() == 36 ) - { - // Parse it - set( sSrc ); - } + if( sSrc.getSize() == 16 ) + { + memcpy( data, sSrc.getStr(), 16 ); + } + else if( sSrc.getSize() == 36 ) + { + // Parse it + set( sSrc ); + } } Bu::Uuid::~Uuid() @@ -45,130 +45,130 @@ Bu::Uuid::~Uuid() Bu::String Bu::Uuid::toRawString() const { - return Bu::String( (char *)data, 16 ); + return Bu::String( (char *)data, 16 ); } Bu::String Bu::Uuid::toString() const { - Bu::MemBuf mb; - Bu::Formatter f( mb ); + Bu::MemBuf mb; + Bu::Formatter f( mb ); - for( int j = 0; j < 16; j++ ) - { - if( j == 4 || j == 6 || j == 8 || j == 10 ) - f << '-'; - f << Bu::Fmt::hex(2).caps(false) << (unsigned int)data[j]; - } + for( int j = 0; j < 16; j++ ) + { + if( j == 4 || j == 6 || j == 8 || j == 10 ) + f << '-'; + f << Bu::Fmt::hex(2).caps(false) << (unsigned int)data[j]; + } - return mb.getString(); + return mb.getString(); } Bu::String Bu::Uuid::toUrn() const { - return "urn:uuid:" + toString(); + return "urn:uuid:" + toString(); } int Bu::Uuid::getVersion() { - return (data[6]&((8|4|2|1)<<4))>>4; + return (data[6]&((8|4|2|1)<<4))>>4; } #define msb( i ) (1<<(7-i)) void Bu::Uuid::clear() { - data[7] = msb(0); + data[7] = msb(0); } Bu::Uuid Bu::Uuid::generate( Bu::Uuid::Type eType ) { - switch( eType ) - { - case Version1: - case Version2: - case Version3: - case Version4: - case Version5: - default: - case System: + switch( eType ) + { + case Version1: + case Version2: + case Version3: + case Version4: + case Version5: + default: + case System: #if defined(linux) - Bu::File fIn( "/proc/sys/kernel/random/uuid", Bu::File::Read ); - char dat[36]; - fIn.read( dat, 36 ); - Uuid id; - id.set( dat ); - return id; + Bu::File fIn( "/proc/sys/kernel/random/uuid", Bu::File::Read ); + char dat[36]; + fIn.read( dat, 36 ); + Uuid id; + id.set( dat ); + return id; #elif defined(WIN32) - UUID uuid; - UuidCreate( &uuid ); - Uuid id; - id.data[0] = ((unsigned char *)&uuid.Data1)[3]; - id.data[1] = ((unsigned char *)&uuid.Data1)[2]; - id.data[2] = ((unsigned char *)&uuid.Data1)[1]; - id.data[3] = ((unsigned char *)&uuid.Data1)[0]; - id.data[4] = ((unsigned char *)&uuid.Data2)[1]; - id.data[5] = ((unsigned char *)&uuid.Data2)[0]; - id.data[6] = ((unsigned char *)&uuid.Data3)[1]; - id.data[7] = ((unsigned char *)&uuid.Data3)[0]; - memcpy( id.data+8, uuid.Data4, 8 ); - - return id; + UUID uuid; + UuidCreate( &uuid ); + Uuid id; + id.data[0] = ((unsigned char *)&uuid.Data1)[3]; + id.data[1] = ((unsigned char *)&uuid.Data1)[2]; + id.data[2] = ((unsigned char *)&uuid.Data1)[1]; + id.data[3] = ((unsigned char *)&uuid.Data1)[0]; + id.data[4] = ((unsigned char *)&uuid.Data2)[1]; + id.data[5] = ((unsigned char *)&uuid.Data2)[0]; + id.data[6] = ((unsigned char *)&uuid.Data3)[1]; + id.data[7] = ((unsigned char *)&uuid.Data3)[0]; + memcpy( id.data+8, uuid.Data4, 8 ); + + return id; #else # error We should be using one of the other fallbacks, but your platform is not supported yet. Sorry. #endif - } + } } void Bu::Uuid::set( const Bu::String &sSrc ) { - const char *dat = sSrc.getStr(); - int iNibble = 0; - memset( data, 0, 16 ); - for( int j = 0; j < 36; j++ ) - { - if( dat[j] == '-' ) - continue; - unsigned char c = (dat[j]>='0'&&dat[j]<='9')?(dat[j]-'0'):(dat[j]-'a'+10); - data[iNibble/2] |= (iNibble%2==0)?(c<<4):(c); - iNibble++; - } + const char *dat = sSrc.getStr(); + int iNibble = 0; + memset( data, 0, 16 ); + for( int j = 0; j < 36; j++ ) + { + if( dat[j] == '-' ) + continue; + unsigned char c = (dat[j]>='0'&&dat[j]<='9')?(dat[j]-'0'):(dat[j]-'a'+10); + data[iNibble/2] |= (iNibble%2==0)?(c<<4):(c); + iNibble++; + } } bool Bu::Uuid::operator==( const Uuid &rhs ) const { - return memcmp( data, rhs.data, 16 ) == 0; + return memcmp( data, rhs.data, 16 ) == 0; } bool Bu::Uuid::operator!=( const Uuid &rhs ) const { - return !(*this == rhs); + return !(*this == rhs); } Bu::Uuid &Bu::Uuid::operator=( const Uuid &rhs ) { - memcpy( data, rhs.data, 16 ); - return *this; + memcpy( data, rhs.data, 16 ); + return *this; } template<> uint32_t Bu::__calcHashCode( const Bu::Uuid &k ) { - return __calcHashCode( k.toRawString() ); + return __calcHashCode( k.toRawString() ); } template<> bool Bu::__cmpHashKeys( const Bu::Uuid &a, const Bu::Uuid &b ) { - return a == b; + return a == b; } Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, Uuid &u ) { - ar.read( u.data, 16 ); - return ar; + ar.read( u.data, 16 ); + return ar; } Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, const Uuid &u ) { - ar.write( u.data, 16 ); - return ar; + ar.write( u.data, 16 ); + return ar; } -- cgit v1.2.3