00001 #ifndef CLASSLIB_UUID_H
00002 # define CLASSLIB_UUID_H
00003
00004
00005
00006 # include "classlib/utils/Error.h"
00007 # include "classlib/utils/iosfwd.h"
00008
00009 namespace lat {
00010
00011
00012 # define CONST_UUID(a,b,c,d,e,f,g,h,i,j,k) \
00013 {0x##a,0x##b,0x##c,0x##d,0x##e,0x##f,0x##g,0x##h,0x##i,0x##j,0x##k}
00014
00015
00016
00017
00018
00019 class UUID;
00020 class Time;
00021
00022
00023
00024
00025 std::ostream &operator<< (std::ostream &out, const UUID &id);
00026
00027
00028
00029 class UUID
00030 {
00031 public:
00032 typedef unsigned char Binary [16];
00033
00034 UUID (void);
00035 UUID (const char *text);
00036 UUID (const std::string &text);
00037 UUID (Binary raw);
00038 UUID (const UUID &x);
00039 UUID &operator= (const UUID &x);
00040
00041 bool operator== (const UUID &x) const;
00042 bool operator!= (const UUID &x) const;
00043 bool operator< (const UUID &x) const;
00044
00045 bool isNull (void) const;
00046 Time time (void) const;
00047 int type (void) const;
00048 int variant (void) const;
00049
00050 void format (char *buf) const;
00051
00052 void clear (void);
00053
00054 static UUID generate (void);
00055 static UUID generateRandom (void);
00056 static UUID generateTime (void);
00057
00058 private:
00059 Binary m_uuid;
00060 };
00061
00062
00063
00064
00065 }
00066 #endif // CLASSLIB_UUID_H