From e231a34727bcba53ac093fc8f3e4062322fb7fc4 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 25 Jun 2012 20:03:39 +0000 Subject: Bu::Uuid has some more features for niceness. It's easier to set them from strings and you can archive them. --- src/unstable/uuid.cpp | 12 ++++++++++++ src/unstable/uuid.h | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'src/unstable') diff --git a/src/unstable/uuid.cpp b/src/unstable/uuid.cpp index c76bb15..41a35c2 100644 --- a/src/unstable/uuid.cpp +++ b/src/unstable/uuid.cpp @@ -139,3 +139,15 @@ template<> bool Bu::__cmpHashKeys( const Bu::Uuid &a, const Bu::Uuid & return a == b; } +Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, Uuid &u ) +{ + ar.read( u.data, 16 ); + return ar; +} + +Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, const Uuid &u ) +{ + ar.write( u.data, 16 ); + return ar; +} + diff --git a/src/unstable/uuid.h b/src/unstable/uuid.h index db4c85b..73b34bc 100644 --- a/src/unstable/uuid.h +++ b/src/unstable/uuid.h @@ -14,6 +14,8 @@ namespace Bu { class Uuid { + friend Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, Uuid &u ); + friend Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const Uuid &u ); public: Uuid(); Uuid( const Uuid &src ); @@ -34,11 +36,12 @@ namespace Bu static Uuid genV5(); void clear(); + void set( const Bu::String &sSrc ); bool operator==( const Uuid &rhs ) const; + Uuid &operator=( const Bu::String &rhs ) { set( rhs ); return *this; } private: - void set( const Bu::String &sSrc ); unsigned char data[16]; }; @@ -51,6 +54,9 @@ namespace Bu template<> uint32_t __calcHashCode( const Uuid &k ); template<> bool __cmpHashKeys( const Uuid &a, const Uuid &b ); + + Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, Uuid &u ); + Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const Uuid &u ); }; #endif -- cgit v1.2.3