//---------------------------------------------------------------------------- // EgalTech 2015-2019 //---------------------------------------------------------------------------- // File : EGnEgtUUID.h Data : 16.05.19 Versione : 2.1e3 // Contenuto : Dichiarazione struttura EgtUUID e sue funzioni. // // // // Modifiche : 01.06.15 DS Creazione modulo. // 16.05.19 DS Aggiunta funzione IsUUID. // //---------------------------------------------------------------------------- #pragma once #include #include //----------------------- 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) ; inline bool IsUUID( const std::string& sVal) { EgtUUID Tmp ; return FromString( sVal, Tmp) ; } //---------------------------------------------------------------------------- namespace std { template <> struct hash { 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]) ; } }; } //---------------------------------------------------------------------------- typedef std::vector UUIDVECTOR ;