mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 22:22:50 +08:00
Added UUID library
This commit is contained in:
31
src/uuid.cpp
Normal file
31
src/uuid.cpp
Normal 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
11
src/uuid.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#ifndef OPENALPR_UUID_H
|
||||||
|
#define OPENALPR_UUID_H
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
std::string newUUID();
|
||||||
|
|
||||||
|
|
||||||
|
#endif // OPENALPR_UUID_H
|
Reference in New Issue
Block a user