Browse Source

Updates to plUUID for Linux & Windows.

Includes linking against libuuid on Linux.
Darryl Pogue 13 years ago
parent
commit
7168174e52
  1. 4
      Sources/Plasma/PubUtilLib/plUUID/CMakeLists.txt
  2. 24
      Sources/Plasma/PubUtilLib/plUUID/plUUID.cpp
  3. 6
      Sources/Plasma/PubUtilLib/plUUID/plUUID.h
  4. 24
      Sources/Plasma/PubUtilLib/plUUID/plUUID_Win32.cpp

4
Sources/Plasma/PubUtilLib/plUUID/CMakeLists.txt

@ -17,6 +17,10 @@ set(plUUID_HEADERS
) )
add_library(plUUID STATIC ${plUUID_SOURCES} ${plUUID_HEADERS}) add_library(plUUID STATIC ${plUUID_SOURCES} ${plUUID_HEADERS})
target_link_libraries(plUUID pnFactory)
if(NOT WIN32)
target_link_libraries(plUUID uuid)
endif(NOT WIN32)
source_group("Source Files" FILES ${plUUID_SOURCES}) source_group("Source Files" FILES ${plUUID_SOURCES})
source_group("Header Files" FILES ${plUUID_HEADERS}) source_group("Header Files" FILES ${plUUID_HEADERS})

24
Sources/Plasma/PubUtilLib/plUUID/plUUID.cpp

@ -42,8 +42,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plUUID.h" #include "plUUID.h"
#include "hsStream.h" #include "hsStream.h"
COMPILER_ASSERT(msizeof(Uuid, data) == msizeof(plUUID, fData));
plUUID::plUUID() plUUID::plUUID()
{ {
Clear(); Clear();
@ -59,11 +57,6 @@ plUUID::plUUID( const plUUID & other )
CopyFrom( &other ); CopyFrom( &other );
} }
plUUID::plUUID( const Uuid & uuid )
{
MemCopy(fData, uuid.data, sizeof(fData));
}
void plUUID::Read( hsStream * s) void plUUID::Read( hsStream * s)
{ {
s->LogSubStreamPushDesc("plUUID"); s->LogSubStreamPushDesc("plUUID");
@ -75,29 +68,12 @@ void plUUID::Write( hsStream * s)
s->Write( sizeof( fData ), (const void*)fData ); s->Write( sizeof( fData ), (const void*)fData );
} }
plUUID::operator Uuid () const {
Uuid uuid;
MemCopy(uuid.data, fData, sizeof(uuid.data));
return uuid;
}
const char * plUUID::AsString() const { const char * plUUID::AsString() const {
static std::string str; static std::string str;
ToStdString(str); ToStdString(str);
return str.c_str(); return str.c_str();
} }
void plUUID::CopyFrom( const plUUID * v ) {
if (!v)
Clear();
else
CopyFrom(*v);
}
void plUUID::CopyFrom( const plUUID & v ) {
MemCopy(fData, v.fData, sizeof(fData));
}
/***************************************************************************** /*****************************************************************************
* *
* plCreatableUuid * plCreatableUuid

6
Sources/Plasma/PubUtilLib/plUUID/plUUID.h

@ -44,7 +44,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsTypes.h" #include "hsTypes.h"
#include "hsStlUtils.h" #include "hsStlUtils.h"
#ifdef HS_BUILD_FOR_WIN32
#include "pnUtils/pnUtils.h" #include "pnUtils/pnUtils.h"
#endif
#include "pnFactory/plCreatable.h" #include "pnFactory/plCreatable.h"
class hsStream; class hsStream;
@ -64,7 +66,9 @@ public:
plUUID(); plUUID();
plUUID( const char * s ); plUUID( const char * s );
plUUID( const plUUID & other ); plUUID( const plUUID & other );
#ifdef HS_BUILD_FOR_WIN32
plUUID( const Uuid & uuid ); plUUID( const Uuid & uuid );
#endif
void Clear(); void Clear();
bool IsNull() const; bool IsNull() const;
bool IsSet() const { return !IsNull(); } bool IsSet() const { return !IsNull(); }
@ -82,7 +86,9 @@ public:
bool operator==( const plUUID & other ) const { return IsEqualTo( &other ); } bool operator==( const plUUID & other ) const { return IsEqualTo( &other ); }
bool operator!=( const plUUID & other ) const { return !IsEqualTo( &other ); } bool operator!=( const plUUID & other ) const { return !IsEqualTo( &other ); }
int operator <( const plUUID & other ) const { return CompareTo( &other ); } int operator <( const plUUID & other ) const { return CompareTo( &other ); }
#ifdef HS_BUILD_FOR_WIN32
operator Uuid () const; operator Uuid () const;
#endif
static plUUID Generate(); static plUUID Generate();
}; };

24
Sources/Plasma/PubUtilLib/plUUID/plUUID_Win32.cpp

@ -47,6 +47,13 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsWindows.h" #include "hsWindows.h"
#include <rpc.h> #include <rpc.h>
COMPILER_ASSERT(msizeof(Uuid, data) == msizeof(plUUID, fData));
plUUID::plUUID( const Uuid & uuid )
{
MemCopy(fData, uuid.data, sizeof(fData));
}
void plUUID::Clear() void plUUID::Clear()
{ {
UuidCreateNil( (GUID *)this ); UuidCreateNil( (GUID *)this );
@ -69,6 +76,23 @@ bool plUUID::IsNull() const
return 1 == UuidIsNil( (GUID *)this, &s ); return 1 == UuidIsNil( (GUID *)this, &s );
} }
void plUUID::CopyFrom( const plUUID * v ) {
if (!v)
Clear();
else
CopyFrom(*v);
}
void plUUID::CopyFrom( const plUUID & v ) {
MemCopy(fData, v.fData, sizeof(fData));
}
plUUID::operator Uuid () const {
Uuid uuid;
MemCopy(uuid.data, fData, sizeof(uuid.data));
return uuid;
}
bool plUUID::FromString( const char * str ) bool plUUID::FromString( const char * str )
{ {
Clear(); Clear();

Loading…
Cancel
Save