17 #ifndef COM_BORA_SOFTWARE__BALAU_TYPE__UUID 18 #define COM_BORA_SOFTWARE__BALAU_TYPE__UUID 22 #include <boost/uuid/uuid.hpp> 23 #include <boost/uuid/uuid_generators.hpp> 24 #include <boost/uuid/uuid_io.hpp> 37 public:
UUID() : uuid(
boost::uuids::random_generator()()) {}
42 public:
UUID(
const UUID & copy) =
default;
49 public: std::array<unsigned char, 16>
asArray()
const {
50 std::array<unsigned char, 16> a {};
51 memcpy(a.data(), uuid.data, 16);
60 public:
const unsigned char *
asBytes()
const {
81 std::ostringstream stream;
91 public:
const boost::uuids::uuid &
asUUID()
const {
99 return uuid == rhs.uuid;
106 return uuid != rhs.uuid;
113 return uuid < rhs.uuid;
120 return uuid > rhs.uuid;
127 return uuid <= rhs.uuid;
134 return uuid >= rhs.uuid;
139 private:
const boost::uuids::uuid uuid;
147 template <
typename AllocatorT>
163 #endif // COM_BORA_SOFTWARE__BALAU_TYPE__UUID std::string asString() const
Get the UUID as a UTF-8 string.
Definition: UUID.hpp:80
Pre-defined universal to-string functions.
Definition: NetworkTypes.hpp:39
UUID()
Construct a new UUID with a random value.
Definition: UUID.hpp:37
bool operator==(const UUID &rhs) const
Are the two UUIDs equal?
Definition: UUID.hpp:98
The root Balau namespace.
Definition: ApplicationConfiguration.hpp:23
bool operator<(const UUID &rhs) const
Is this UUID less than the supplied UUID?
Definition: UUID.hpp:112
bool operator>(const UUID &rhs) const
Is this UUID greater than the supplied UUID?
Definition: UUID.hpp:119
std::basic_ostringstream< char, std::char_traits< char >, AllocatorT > U8OStringStream
UTF-8 output string stream type with selectable allocator.
Definition: ToStringA.hpp:59
bool operator<=(const UUID &rhs) const
Is this UUID less or equal to the supplied UUID?
Definition: UUID.hpp:126
const unsigned char * asBytes() const
Get the UUID as raw bytes.
Definition: UUID.hpp:60
bool operator>=(const UUID &rhs) const
Is this UUID greater or equal to the supplied UUID?
Definition: UUID.hpp:133
std::basic_string< char, std::char_traits< char >, AllocatorT > U8String
UTF-8 string type with selectable allocator.
Definition: ToStringA.hpp:41
const boost::uuids::uuid & asUUID() const
Get the UUID as the underlying Boost UUID.
Definition: UUID.hpp:91
std::array< unsigned char, 16 > asArray() const
Get the UUID as a std::array of bytes.
Definition: UUID.hpp:49
bool operator!=(const UUID &rhs) const
Are the two UUIDs not equal?
Definition: UUID.hpp:105
UUID class, using the Boost uuid implementation.
Definition: UUID.hpp:33
Balau::U8String< AllocatorT > toString(LoggingLevel level)
Print the logging level as a UTF-8 string.
Definition: LoggingLevel.hpp:73
Balau::U8String< AllocatorT > asString() const
Get the UUID as a UTF-8 string.
Definition: UUID.hpp:69