Files
Include/EGnEgtUUID.h
T
Dario Sassi 14bf26a40c Include :
- aggiornamenti.
2016-03-18 07:49:06 +00:00

60 lines
2.0 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2015-2015
//----------------------------------------------------------------------------
// File : EGnEgtUUID.h Data : 01.06.15 Versione : 1.6f1
// Contenuto : Dichiarazione struttura EgtUUID e sue funzioni.
//
//
//
// Modifiche : 01.06.15 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include <string>
//----------------------- Macro per import/export ----------------------------
#undef EGN_EXPORT
#if defined( I_AM_EGN) // da definirsi solo nella DLL
#define EGN_EXPORT __declspec( dllexport)
#else
#define EGN_EXPORT __declspec( dllimport)
#endif
//----------------------------------------------------------------------------
struct EgtUUID {
unsigned int Data1 ;
unsigned short Data2 ;
unsigned short Data3 ;
unsigned char Data4[8] ;
EgtUUID( void)
{ Clear() ; }
bool Clear( void)
{ Data1 = 0 ; Data2 = 0; Data3 = 0 ; memset( Data4, 0, 8) ; return true ; }
bool operator ==( const EgtUUID& other) const
{ return ( Data1 == other.Data1 && Data2 == other.Data2 && Data3 == other.Data3 &&
memcmp( Data4, other.Data4, 8) == 0) ; }
bool operator !=( const EgtUUID& other) const
{ return ! operator ==( other) ; }
} ;
//----------------------------------------------------------------------------
EGN_EXPORT bool CreateEgtUUID( EgtUUID& uuId) ;
EGN_EXPORT std::string ToString( const EgtUUID& uuId) ;
EGN_EXPORT bool FromString( const std::string& sVal, EgtUUID& uuId) ;
//----------------------------------------------------------------------------
namespace std {
template <>
struct hash<EgtUUID>
{
typedef EgtUUID argument_type ;
typedef std::size_t result_type ;
std::size_t operator()( EgtUUID key) const {
return ( key.Data1 + key.Data2 + key.Data3 + key.Data4[0] + key.Data4[7]) ;
}
};
}