Nebula
Loading...
Searching...
No Matches
win32guid.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
14#include "core/types.h"
15#include "util/string.h"
16#include "core/sysfunc.h"
17
18//------------------------------------------------------------------------------
19namespace Win32
20{
22{
23public:
25 Win32Guid();
27 Win32Guid(const Win32Guid& rhs);
29 Win32Guid(const unsigned char* ptr, SizeT size);
31 void operator=(const Win32Guid& rhs);
33 void operator=(const Util::String& rhs);
35 bool operator==(const Win32Guid& rhs) const;
37 bool operator!=(const Win32Guid& rhs) const;
39 bool operator<(const Win32Guid& rhs) const;
41 bool operator<=(const Win32Guid& rhs) const;
43 bool operator>(const Win32Guid& rhs) const;
45 bool operator>=(const Win32Guid& rhs) const;
47 bool IsValid() const;
49 void Generate();
51 static Win32Guid FromString(const Util::String& str);
53 static Win32Guid FromBinary(const unsigned char* ptr, SizeT numBytes);
55 Util::String AsString() const;
57 SizeT AsBinary(const unsigned char*& outPtr) const;
59 static SizeT BinarySize();
61 uint32_t HashCode() const;
62
63private:
64 UUID uuid;
65};
66
67//------------------------------------------------------------------------------
70inline
72{
73 Memory::Clear(&(this->uuid), sizeof(this->uuid));
74}
75
76//------------------------------------------------------------------------------
79inline
81{
82 this->uuid = rhs.uuid;
83}
84
85//------------------------------------------------------------------------------
88inline
89Win32Guid::Win32Guid(const unsigned char* ptr, SizeT size)
90{
91 n_assert((0 != ptr) && (size == sizeof(UUID)));
92 Memory::Copy(ptr, &this->uuid, sizeof(UUID));
93}
94
95//------------------------------------------------------------------------------
98inline SizeT
100{
101 return sizeof(UUID);
102}
103
104} // namespace Win32
105//------------------------------------------------------------------------------
Win32 implementation of the Util::Guid class.
Definition win32guid.h:22
bool IsValid() const
return true if the contained guid is valid (not NIL)
Definition win32guid.cc:106
Win32Guid()
constructor
Definition win32guid.h:71
static Win32Guid FromBinary(const unsigned char *ptr, SizeT numBytes)
construct from binary representation
Definition win32guid.cc:167
bool operator!=(const Win32Guid &rhs) const
inequlality operator
Definition win32guid.cc:51
static SizeT BinarySize()
return the size of the binary representation in bytes
Definition win32guid.h:99
bool operator<=(const Win32Guid &rhs) const
less-or-equal operator
Definition win32guid.cc:73
void operator=(const Win32Guid &rhs)
assignement operator
Definition win32guid.cc:17
uint32_t HashCode() const
get a hash code (compatible with Util::HashTable)
Definition win32guid.cc:181
bool operator==(const Win32Guid &rhs) const
equality operator
Definition win32guid.cc:40
bool operator>(const Win32Guid &rhs) const
greater-then operator
Definition win32guid.cc:84
bool operator<(const Win32Guid &rhs) const
less-then operator
Definition win32guid.cc:62
SizeT AsBinary(const unsigned char *&outPtr) const
get pointer to binary data
Definition win32guid.cc:144
static Win32Guid FromString(const Util::String &str)
construct from string representation
Definition win32guid.cc:154
bool operator>=(const Win32Guid &rhs) const
greater-or-equal operator
Definition win32guid.cc:95
void Generate()
generate a new guid
Definition win32guid.cc:117
Util::String AsString() const
get as string
Definition win32guid.cc:127
UUID uuid
Definition win32guid.h:64
#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
void Clear(void *ptr, size_t numBytes)
Overwrite a chunk of memory with 0's.
Definition osxmemory.cc:229
[TODO: Describe Win32 subsystem]
Nebula's universal string class.
Definition string.h:50
int SizeT
Definition types.h:49