uuid.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _UUID_H_
00023 #define _UUID_H_
00024
00025 #include <string>
00026
00027 namespace dbp {
00028
00030
00034 class uuid {
00036 friend std::istream& operator>>(std::istream&, uuid&);
00038 friend std::ostream& operator<<(std::ostream&, const uuid&);
00039 public:
00041 uuid();
00043 uuid(const std::string&);
00045 uuid(const char*);
00047 uuid(const uuid&);
00049 uuid& operator=(const uuid&);
00051 bool operator==(const uuid&) const;
00053 bool operator<(const uuid&) const;
00055 bool operator>(const uuid &rhs) const {
00056 return (rhs < *this);
00057 }
00059 bool operator<=(const uuid &rhs) const {
00060 return !(rhs < *this);
00061 }
00063 bool operator>=(const uuid& rhs) const {
00064 return !(*this < rhs);
00065 }
00067 bool operator!=(const uuid &rhs) const {
00068 return !(*this == rhs);
00069 }
00071 bool operator!() const {
00072 return empty();
00073 }
00075 typedef bool (uuid::*bool_type)() const;
00077 operator bool_type() const {
00078 return empty() ? NULL : &uuid::empty;
00079 }
00081 void generate();
00083 void clear();
00085 bool empty() const;
00087 std::string str() const;
00088 private:
00089 static const int size = 16;
00090 unsigned char _data[size];
00091 void assign(const std::string&);
00092 };
00093
00094 }
00095
00096 #endif
00097