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
18//------------------------------------------------------------------------------
19namespace Posix
20{
22{
23public:
25 PosixGuid();
27 PosixGuid(const unsigned char* ptr, SizeT size);
29 void operator=(const Util::String& rhs);
31 bool operator==(const PosixGuid& rhs) const;
33 bool operator!=(const PosixGuid& rhs) const;
35 bool operator<(const PosixGuid& rhs) const;
37 bool operator<=(const PosixGuid& rhs) const;
39 bool operator>(const PosixGuid& rhs) const;
41 bool operator>=(const PosixGuid& rhs) const;
43 bool IsValid() const;
45 void Generate();
47 static PosixGuid FromString(const Util::String& str);
49 static PosixGuid FromBinary(const unsigned char* ptr, SizeT numBytes);
51 Util::String AsString() const;
53 SizeT AsBinary(const unsigned char*& outPtr) const;
55 uint32_t HashCode() const;
56
57//private:
58 uint64_t hi;
59 uint64_t lo;
60};
61
62//------------------------------------------------------------------------------
65inline
67{
68 hi = 0UL;
69 lo = 0UL;
70}
71
72//------------------------------------------------------------------------------
75inline
76PosixGuid::PosixGuid(const unsigned char* ptr, SizeT size)
77{
78 n_assert((0 != ptr) && (size == sizeof(uint64_t) * 2));
79 Memory::Copy(ptr, &this->hi, sizeof(uint64_t) * 2);
80}
81
82}; // namespace Posix
83//------------------------------------------------------------------------------
84#endif
85
SizeT AsBinary(const unsigned char *&outPtr) const
get pointer to binary data
Definition posixguid.cc:137
bool operator>(const PosixGuid &rhs) const
greater-then operator
Definition posixguid.cc:76
uint64_t lo
Definition posixguid.h:59
void Generate()
generate a new guid
Definition posixguid.cc:111
static PosixGuid FromString(const Util::String &str)
construct from string representation
Definition posixguid.cc:147
bool operator==(const PosixGuid &rhs) const
equality operator
Definition posixguid.cc:32
bool operator!=(const PosixGuid &rhs) const
inequlality operator
Definition posixguid.cc:41
bool operator>=(const PosixGuid &rhs) const
greater-or-equal operator
Definition posixguid.cc:93
static PosixGuid FromBinary(const unsigned char *ptr, SizeT numBytes)
construct from binary representation
Definition posixguid.cc:162
PosixGuid()
constructor
Definition posixguid.h:66
uint32_t HashCode() const
get a hash code (compatible with Util::HashTable)
Definition posixguid.cc:176
bool operator<=(const PosixGuid &rhs) const
less-or-equal operator
Definition posixguid.cc:67
Util::String AsString() const
get as string
Definition posixguid.cc:122
uint64_t hi
Definition posixguid.h:58
bool operator<(const PosixGuid &rhs) const
less-then operator
Definition posixguid.cc:50
void operator=(const Util::String &rhs)
assignment operator from string
Definition posixguid.cc:19
bool IsValid() const
return true if the contained guid is valid (not NIL)
Definition posixguid.cc:102
#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.cs:8
int SizeT
Definition types.h:42