Added UUID library

This commit is contained in:
Matt Hill
2014-06-03 16:33:10 -04:00
parent 801d68be02
commit 2638223c59
2 changed files with 42 additions and 0 deletions

31
src/uuid.cpp Normal file
View File

@@ -0,0 +1,31 @@
#include "uuid.h"
extern "C"
{
#ifdef WIN32
#include <Rpc.h>
#else
#include <uuid/uuid.h>
#endif
}
std::string newUUID()
{
#ifdef WIN32
UUID uuid;
UuidCreate ( &uuid );
unsigned char * str;
UuidToStringA ( &uuid, &str );
std::string s( ( char* ) str );
RpcStringFreeA ( &str );
#else
uuid_t uuid;
uuid_generate_random ( uuid );
char s[37];
uuid_unparse ( uuid, s );
#endif
return s;
}

11
src/uuid.h Normal file
View File

@@ -0,0 +1,11 @@
#ifndef OPENALPR_UUID_H
#define OPENALPR_UUID_H
#include <cstdio>
#include <iostream>
std::string newUUID();
#endif // OPENALPR_UUID_H