00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __libutilxx__sella__util__UUID_H__
00010 #define __libutilxx__sella__util__UUID_H__
00011
00012 #include "../../common.h"
00013 #include "UUIDException.h"
00014
00015 #include <uuid/uuid.h>
00016
00017 #include <string>
00018 #include <memory>
00019
00020 namespace sella {
00021 namespace util {
00022 class UUID;
00023 }
00024 }
00025
00026 class sella::util::UUID {
00027 public:
00028 typedef std::shared_ptr<UUID> shared;
00029 typedef UUID *ptr;
00030
00031 public:
00032 UUID() throw ();
00033 UUID(uuid_t &uuid) throw ();
00034 UUID(const std::string &uuid) throw (UUIDException);
00035 UUID(const char *uuid) throw (UUIDException);
00036 UUID(const UUID &other);
00037 UUID(const UUID &&other);
00038 virtual ~UUID();
00039
00040 UUID& operator=(const UUID &other) throw ();
00041 UUID& operator=(const UUID &&other) throw ();
00042 UUID& operator=(const std::string &uuid) throw (UUIDException);
00043 UUID& operator=(const char *uuid) throw (UUIDException);
00044 bool operator==(const UUID &other) const throw ();
00045 bool operator!=(const UUID &other) const throw ();
00046 bool operator>=(const UUID &other) const throw ();
00047 bool operator<=(const UUID &other) const throw ();
00048 bool operator<(const UUID &other) const throw ();
00049 bool operator>(const UUID &other) const throw ();
00050
00051 void set(uuid_t &uuid) throw ();
00052 const uuid_t& get(void) const throw ();
00053
00054 void generate(void) throw ();
00055 void clear(void) throw ();
00056 bool isNull(void) const throw ();
00057
00058 void shrink_to_fit(void) throw ();
00059 const std::string& str(void) const throw ();
00060 const char* c_str(void) const throw ();
00061 static const UUID::shared shared_ptr(void) throw ();
00062 static const UUID::shared shared_ptr(uuid_t &uuid) throw ();
00063
00064 uint32_t getU32(void) const throw ();
00065 uint32_t getHash(void) const throw ();
00066
00067 private:
00068 uuid_t uuid;
00069
00070 mutable std::string scache;
00071 mutable uint32_t hcache;
00072 };
00073
00074 #endif
00075
00076
00077
00078