Nebula
Loading...
Searching...
No Matches
posixguid.h
Go to the documentation of this file.
1#pragma once
2#ifndef POSIX_POSIXGUID_H
3#define POSIX_POSIXGUID_H
4//------------------------------------------------------------------------------
15#include "core/types.h"
16#include "util/string.h"
17#include <uuid/uuid.h>
18
19//------------------------------------------------------------------------------
20namespace Posix
21{
23{
24public:
26 PosixGuid();
28 PosixGuid(const PosixGuid& rhs);
30 PosixGuid(const unsigned char* ptr, SizeT size);
32 void operator=(const PosixGuid& rhs);
34 void operator=(const Util::String& rhs);
36 bool operator==(const PosixGuid& rhs) const;
38 bool operator!=(const PosixGuid& rhs) const;
40 bool operator<(const PosixGuid& rhs) const;
42 bool operator<=(const PosixGuid& rhs) const;
44 bool operator>(const PosixGuid& rhs) const;
46 bool operator>=(const PosixGuid& rhs) const;
48 bool IsValid() const;
50 void Generate();
52 static PosixGuid FromString(const Util::String& str);
54 static PosixGuid FromBinary(const unsigned char* ptr, SizeT numBytes);
56 Util::String AsString() const;
58 SizeT AsBinary(const unsigned char*& outPtr) const;
60 IndexT HashCode() const;
61
62private:
63 uuid_t uuid;
64};
65
66//------------------------------------------------------------------------------
69inline
71{
72 uuid_clear(this->uuid);
73}
74
75//------------------------------------------------------------------------------
78inline
80{
81 uuid_copy(this->uuid, rhs.uuid);
82}
83
84//------------------------------------------------------------------------------
87inline
88PosixGuid::PosixGuid(const unsigned char* ptr, SizeT size)
89{
90 n_assert((0 != ptr) && (size == sizeof(uuid_t)));
91 Memory::Copy(ptr, &this->uuid, sizeof(uuid_t));
92}
93
94}; // namespace Posix
95//------------------------------------------------------------------------------
96#endif
97
Posix implementation of the Util::Guid class.
Definition posixguid.h:23
SizeT AsBinary(const unsigned char *&outPtr) const
get pointer to binary data
Definition posixguid.cc:134
bool operator>(const PosixGuid &rhs) const
greater-then operator
Definition posixguid.cc:80
void Generate()
generate a new guid
Definition posixguid.cc:110
static PosixGuid FromString(const Util::String &str)
construct from string representation
Definition posixguid.cc:144
bool operator==(const PosixGuid &rhs) const
equality operator
Definition posixguid.cc:40
bool operator!=(const PosixGuid &rhs) const
inequlality operator
Definition posixguid.cc:50
bool operator>=(const PosixGuid &rhs) const
greater-or-equal operator
Definition posixguid.cc:90
static PosixGuid FromBinary(const unsigned char *ptr, SizeT numBytes)
construct from binary representation
Definition posixguid.cc:157
void operator=(const PosixGuid &rhs)
assignement operator
Definition posixguid.cc:17
PosixGuid()
constructor
Definition posixguid.h:70
uuid_t uuid
Definition posixguid.h:63
IndexT HashCode() const
get a hash code (compatible with Util::HashTable)
Definition posixguid.cc:171
bool operator<=(const PosixGuid &rhs) const
less-or-equal operator
Definition posixguid.cc:70
Util::String AsString() const
get as string
Definition posixguid.cc:119
bool operator<(const PosixGuid &rhs) const
less-then operator
Definition posixguid.cc:60
bool IsValid() const
return true if the contained guid is valid (not NIL)
Definition posixguid.cc:100
#define n_assert(exp)
Definition debug.h:50
void Copy(const void *from, void *to, size_t numBytes)
Copy a chunk of memory (note the argument order is different from memcpy()!!!)
Definition osxmemory.cc:213
Posix implemention of a read-many write-few lock.
Definition posixsysfunc.cc:21
Nebula's universal string class.
Definition string.h:50
int SizeT
Definition types.h:49
int IndexT
Definition types.h:48