diff options
Diffstat (limited to 'source/core/StarUuid.hpp')
-rw-r--r-- | source/core/StarUuid.hpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/source/core/StarUuid.hpp b/source/core/StarUuid.hpp new file mode 100644 index 0000000..3b540fc --- /dev/null +++ b/source/core/StarUuid.hpp @@ -0,0 +1,44 @@ +#ifndef STAR_UUID_HPP +#define STAR_UUID_HPP + +#include "StarArray.hpp" +#include "StarDataStream.hpp" + +namespace Star { + +STAR_EXCEPTION(UuidException, StarException); + +size_t const UuidSize = 16; + +class Uuid { +public: + Uuid(); + explicit Uuid(ByteArray const& bytes); + explicit Uuid(String const& hex); + + char const* ptr() const; + ByteArray bytes() const; + String hex() const; + + bool operator==(Uuid const& u) const; + bool operator!=(Uuid const& u) const; + bool operator<(Uuid const& u) const; + bool operator<=(Uuid const& u) const; + bool operator>(Uuid const& u) const; + bool operator>=(Uuid const& u) const; + +private: + Array<char, UuidSize> m_data; +}; + +template <> +struct hash<Uuid> { + size_t operator()(Uuid const& u) const; +}; + +DataStream& operator>>(DataStream& ds, Uuid& uuid); +DataStream& operator<<(DataStream& ds, Uuid const& uuid); + +} + +#endif |