e31f4e26c8
- aggiunto EgtUUID e relativa gestione - aggiunte CopyFileEgt e RenameFile - aggiunt Writer per scrivere file di testo anche compressi.
58 lines
1.8 KiB
C++
58 lines
1.8 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : EgtUUID.cpp Data : 01.06.15 Versione : 1.6f1
|
|
// Contenuto : Funzioni per EgtUUID.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 01.06.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "/EgtDev/Include/EGnEgtUUID.h"
|
|
#include <Rpc.h>
|
|
#include <Rpcdce.h>
|
|
|
|
using namespace std ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
CreateEgtUUID( EgtUUID& uuId)
|
|
{
|
|
if ( UuidCreate( (UUID*)( &uuId)) != RPC_S_OK)
|
|
return false ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
string
|
|
ToString( const EgtUUID& uuId)
|
|
{
|
|
static const int order[16] = {3,2,1,0, 5,4, 7,6, 8,9, 10,11,12,13,14,15} ;
|
|
static const int dash[16] = {0,0,0,1, 0,1, 0,1, 0,1, 0, 0, 0, 0, 0, 0} ;
|
|
static const char x[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'} ;
|
|
const unsigned char* b = (const unsigned char*) &uuId ;
|
|
char szBuff[40] ;
|
|
char* p = szBuff ;
|
|
for ( int i = 0 ; i < 16 ; ++i) {
|
|
*p++ = x[b[order[i]]>>4] ;
|
|
*p++ = x[b[order[i]]&0x0f] ;
|
|
if ( dash[i] != 0)
|
|
*p++ = '-' ;
|
|
}
|
|
*p = '\0' ;
|
|
return szBuff ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
FromString( const string& sVal, EgtUUID& uuId)
|
|
{
|
|
if ( UuidFromStringA( (unsigned char*) sVal.c_str(), (UUID*)( &uuId)) != RPC_S_OK)
|
|
return false ;
|
|
return true ;
|
|
} |