diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-06-25 20:03:39 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-06-25 20:03:39 +0000 |
commit | e231a34727bcba53ac093fc8f3e4062322fb7fc4 (patch) | |
tree | df4ea1979a2fa78410f9375ad4eb56a4ca22216b /src | |
parent | 2d6f5f0903bd97a38056a65431b07bb7baf5039a (diff) | |
download | libbu++-e231a34727bcba53ac093fc8f3e4062322fb7fc4.tar.gz libbu++-e231a34727bcba53ac093fc8f3e4062322fb7fc4.tar.bz2 libbu++-e231a34727bcba53ac093fc8f3e4062322fb7fc4.tar.xz libbu++-e231a34727bcba53ac093fc8f3e4062322fb7fc4.zip |
Bu::Uuid has some more features for niceness. It's easier to set them from
strings and you can archive them.
Diffstat (limited to '')
-rw-r--r-- | src/unstable/uuid.cpp | 12 | ||||
-rw-r--r-- | src/unstable/uuid.h | 8 |
2 files changed, 19 insertions, 1 deletions
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<Bu::Uuid>( const Bu::Uuid &a, const Bu::Uuid & | |||
139 | return a == b; | 139 | return a == b; |
140 | } | 140 | } |
141 | 141 | ||
142 | Bu::ArchiveBase &Bu::operator>>( Bu::ArchiveBase &ar, Uuid &u ) | ||
143 | { | ||
144 | ar.read( u.data, 16 ); | ||
145 | return ar; | ||
146 | } | ||
147 | |||
148 | Bu::ArchiveBase &Bu::operator<<( Bu::ArchiveBase &ar, const Uuid &u ) | ||
149 | { | ||
150 | ar.write( u.data, 16 ); | ||
151 | return ar; | ||
152 | } | ||
153 | |||
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 | |||
14 | { | 14 | { |
15 | class Uuid | 15 | class Uuid |
16 | { | 16 | { |
17 | friend Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, Uuid &u ); | ||
18 | friend Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const Uuid &u ); | ||
17 | public: | 19 | public: |
18 | Uuid(); | 20 | Uuid(); |
19 | Uuid( const Uuid &src ); | 21 | Uuid( const Uuid &src ); |
@@ -34,11 +36,12 @@ namespace Bu | |||
34 | static Uuid genV5(); | 36 | static Uuid genV5(); |
35 | 37 | ||
36 | void clear(); | 38 | void clear(); |
39 | void set( const Bu::String &sSrc ); | ||
37 | 40 | ||
38 | bool operator==( const Uuid &rhs ) const; | 41 | bool operator==( const Uuid &rhs ) const; |
42 | Uuid &operator=( const Bu::String &rhs ) { set( rhs ); return *this; } | ||
39 | 43 | ||
40 | private: | 44 | private: |
41 | void set( const Bu::String &sSrc ); | ||
42 | unsigned char data[16]; | 45 | unsigned char data[16]; |
43 | }; | 46 | }; |
44 | 47 | ||
@@ -51,6 +54,9 @@ namespace Bu | |||
51 | template<> uint32_t __calcHashCode<Uuid>( const Uuid &k ); | 54 | template<> uint32_t __calcHashCode<Uuid>( const Uuid &k ); |
52 | template<> bool __cmpHashKeys<Uuid>( | 55 | template<> bool __cmpHashKeys<Uuid>( |
53 | const Uuid &a, const Uuid &b ); | 56 | const Uuid &a, const Uuid &b ); |
57 | |||
58 | Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, Uuid &u ); | ||
59 | Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const Uuid &u ); | ||
54 | }; | 60 | }; |
55 | 61 | ||
56 | #endif | 62 | #endif |