Nebula
Loading...
Searching...
No Matches
osxguid.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
11#include "core/types.h"
12#include "util/string.h"
13#include "core/sysfunc.h"
14
15//------------------------------------------------------------------------------
16namespace OSX
17{
19{
20public:
22 void* operator new(size_t s);
24 void operator delete(void* ptr);
25
27 OSXGuid();
29 OSXGuid(const OSXGuid& rhs);
31 OSXGuid(const unsigned char* ptr, SizeT size);
33 void operator=(const OSXGuid& rhs);
35 void operator=(const Util::String& rhs);
37 bool operator==(const OSXGuid& rhs) const;
39 bool operator!=(const OSXGuid& rhs) const;
41 bool operator<(const OSXGuid& rhs) const;
43 bool operator<=(const OSXGuid& rhs) const;
45 bool operator>(const OSXGuid& rhs) const;
47 bool operator>=(const OSXGuid& rhs) const;
49 bool IsValid() const;
51 void Generate();
53 static OSXGuid FromString(const Util::String& str);
55 static OSXGuid FromBinary(const unsigned char* ptr, SizeT numBytes);
57 Util::String AsString() const;
59 SizeT AsBinary(const unsigned char*& outPtr) const;
61 static SizeT BinarySize();
63 IndexT HashCode() const;
64
65private:
66 uuid_t uuid;
67};
68
69//------------------------------------------------------------------------------
72__forceinline void*
73OSXGuid::operator new(size_t size)
74{
75 #if NEBULA_DEBUG
76 n_assert(size == sizeof(OSXGuid));
77 #endif
79}
80
81//------------------------------------------------------------------------------
84__forceinline void
85OSXGuid::operator delete(void* ptr)
86{
88}
89
90//------------------------------------------------------------------------------
93inline
95{
96 uuid_clear(this->uuid);
97}
98
99//------------------------------------------------------------------------------
102inline
104{
105 uuid_copy(this->uuid, rhs.uuid);
106}
107
108//------------------------------------------------------------------------------
111inline
112OSXGuid::OSXGuid(const unsigned char* ptr, SizeT size)
113{
114 n_assert((0 != ptr) && (size == sizeof(uuid_t)));
115 uuid_copy(this->uuid, *(uuid_t*)ptr);
116}
117
118//------------------------------------------------------------------------------
121inline SizeT
123{
124 return sizeof(uuid_t);
125}
126
127} // namespace Win32
128//------------------------------------------------------------------------------
OSX implementation of the Util::Guid class.
Definition osxguid.h:19
void Generate()
generate a new guid
Definition osxguid.cc:104
static SizeT BinarySize()
return the size of the binary representation in bytes
Definition osxguid.h:122
SizeT AsBinary(const unsigned char *&outPtr) const
get pointer to binary data
Definition osxguid.cc:128
Util::String AsString() const
get as string
Definition osxguid.cc:113
bool operator<(const OSXGuid &rhs) const
less-then operator
Definition osxguid.cc:59
IndexT HashCode() const
get a hash code (compatible with Util::HashTable)
Definition osxguid.cc:164
bool operator==(const OSXGuid &rhs) const
equality operator
Definition osxguid.cc:41
void operator=(const OSXGuid &rhs)
assignement operator
Definition osxguid.cc:17
bool IsValid() const
return true if the contained guid is valid (not NIL)
Definition osxguid.cc:95
bool operator<=(const OSXGuid &rhs) const
less-or-equal operator
Definition osxguid.cc:68
bool operator>(const OSXGuid &rhs) const
greater-then operator
Definition osxguid.cc:77
uuid_t uuid
Definition osxguid.h:66
bool operator>=(const OSXGuid &rhs) const
greater-or-equal operator
Definition osxguid.cc:86
static OSXGuid FromString(const Util::String &str)
construct from string representation
Definition osxguid.cc:138
bool operator!=(const OSXGuid &rhs) const
inequlality operator
Definition osxguid.cc:50
OSXGuid()
constructor
Definition osxguid.h:94
static OSXGuid FromBinary(const unsigned char *ptr, SizeT numBytes)
construct from binary representation
Definition osxguid.cc:150
#define n_assert(exp)
Definition debug.h:50
void * Alloc(HeapType heapType, size_t size, size_t alignment)
Allocate a block of memory from one of the global heaps.
Definition osxmemory.cc:56
void Free(HeapType heapType, void *ptr)
Free a block of memory.
Definition osxmemory.cc:136
@ ObjectHeap
Definition osxmemoryconfig.h:27
Definition osxsysfunc.h:21
Nebula's universal string class.
Definition string.h:50
int SizeT
Definition types.h:49
int IndexT
Definition types.h:48