1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 11:19:10 +00:00

Get rid of GuidGenerate calls.

This commit is contained in:
Darryl Pogue
2012-11-18 16:41:33 -08:00
parent 2c055f91f5
commit fd8541e18d
11 changed files with 32 additions and 72 deletions

View File

@ -976,9 +976,9 @@ void NetVaultNodeFieldArray::GetFieldValueString_LCS (
case NetVaultNode::kUuid_2:
case NetVaultNode::kUuid_3:
case NetVaultNode::kUuid_4: {
wchar_t tmp[64];
GuidToHex(*(Uuid *)fieldAddr, tmp, arrsize(tmp));
StrPrintf(dst, dstChars, L"hextoraw('%s')", tmp);
plString tmp = plUUID(fieldAddr).AsString();
StrPrintf(dst, dstChars, L"hextoraw('%s')", tmp.c_str());
}
break;

View File

@ -47,44 +47,46 @@ plUUID::plUUID()
Clear();
}
plUUID::plUUID( const plString & s )
plUUID::plUUID(const plString & s)
{
FromString( s );
FromString(s);
}
plUUID::plUUID( const char * s )
plUUID::plUUID(const char * s)
{
FromString( s );
FromString(s.c_str());
}
plUUID::plUUID( const plUUID & other )
plUUID::plUUID(const plUUID& other)
{
CopyFrom( &other );
CopyFrom(&other);
}
plUUID::plUUID( const Uuid & uuid )
plUUID::plUUID(const Uuid& uuid)
{
memcpy(fData, uuid.data, sizeof(fData));
}
void plUUID::Read( hsStream * s)
void plUUID::Read(hsStream * s)
{
s->LogSubStreamPushDesc("plUUID");
s->Read( sizeof( fData ), (void*)fData );
s->Read(sizeof(fData), (void*)fData);
}
void plUUID::Write( hsStream * s)
void plUUID::Write(hsStream * s)
{
s->Write( sizeof( fData ), (const void*)fData );
s->Write(sizeof(fData), (const void*)fData);
}
plString plUUID::AsString() const {
plString plUUID::AsString() const
{
plString str;
ToString(str);
return str;
}
plUUID::operator Uuid () const {
plUUID::operator Uuid () const
{
Uuid uuid;
memcpy(uuid.data, fData, sizeof(uuid.data));
return uuid;

View File

@ -120,17 +120,7 @@ Uuid Uuid::Generate()
static_assert(sizeof(Uuid) >= sizeof(GUID), "pnUtils Uuid and Win32 GUID types differ in size");
//============================================================================
Uuid GuidGenerate () {
Uuid result;
UuidCreate( (GUID *)&result );
return result;
}
//============================================================================
void GuidClear (Uuid * uuid) {
UuidCreateNil((GUID *)uuid);
}
//============================================================================
bool GuidFromString (const wchar_t str[], Uuid * uuid) {

View File

@ -71,32 +71,6 @@ Uuid::Uuid (const uint8_t buf[], unsigned length) {
GuidFromHex(buf, length, this);
}
//============================================================================
unsigned GuidHash (const Uuid & uuid) {
CHashValue hash(&uuid.data, sizeof(uuid.data));
return hash.GetHash();
}
//============================================================================
static const wchar_t s_hexChars[] = L"0123456789ABCDEF";
const wchar_t * GuidToHex (const Uuid & uuid, wchar_t * dst, unsigned chars) {
wchar_t * str = (wchar_t*)malloc((sizeof(uuid.data) * 2 + 1) * sizeof(wchar_t));
wchar_t * cur = str;
for (unsigned i = 0; i < sizeof(uuid.data); ++i) {
*cur++ = s_hexChars[(uuid.data[i] >> 4) & 0x0f];
*cur++ = s_hexChars[uuid.data[i] & 0x0f];
}
*cur = 0;
StrCopy(dst, str, chars);
free(str);
return dst;
}
//============================================================================
bool GuidFromHex (const uint8_t buf[], unsigned length, Uuid * uuid) {

View File

@ -75,17 +75,13 @@ extern const Uuid kNilGuid;
// Using 'Guid' here instead of 'Uuid' to avoid name clash with windows API =(
Uuid GuidGenerate ();
void GuidClear (Uuid * uuid);
bool GuidFromString (const wchar_t str[], Uuid * uuid);
bool GuidFromString (const char str[], Uuid * uuid);
int GuidCompare (const Uuid & a, const Uuid & b);
inline bool GuidsAreEqual (const Uuid & a, const Uuid & b) { return 0 == GuidCompare(a, b); }
bool GuidIsNil (const Uuid & uuid);
unsigned GuidHash (const Uuid & uuid);
const wchar_t * GuidToString (const Uuid & uuid, wchar_t * dst, unsigned chars); // returns dst
const char * GuidToString (const Uuid & uuid, char * dst, unsigned chars); // returns dst
const wchar_t * GuidToHex (const Uuid & uuid, wchar_t * dst, unsigned chars); // returns dst
bool GuidFromHex (const uint8_t buf[], unsigned length, Uuid * uuid);