Skip to content

Commit

Permalink
fix typos and uploading miss files
Browse files Browse the repository at this point in the history
Change-Id: I8c9a2717688959de2ec6855bb79b367ffc07f0f5
  • Loading branch information
zhangyuanlong committed Apr 1, 2020
1 parent 941d3ab commit aca7036
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 62 deletions.
43 changes: 43 additions & 0 deletions flamingoclient/Source/UUIDGenerator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 1,43 @@
/**
* 全局唯一的UUID生成工具类,Windows上实际使用的是GUID, UUIDGenerator.cpp
* zhangyl 20190710
*/

#include "UUIDGenerator.h"


#ifdef WIN32

#include <combaseapi.h>

std::string UUIDGenerator::generate()
{
GUID guid;
CoCreateGuid(&guid);
char cBuffer[64] = { 0 };
sprintf_s(cBuffer, sizeof(cBuffer),
"X-X-X-XX-XXXXXX",
guid.Data1, guid.Data2,
guid.Data3, guid.Data4[0],
guid.Data4[1], guid.Data4[2],
guid.Data4[3], guid.Data4[4],
guid.Data4[5], guid.Data4[6],
guid.Data4[7]);
return std::string(cBuffer, 36);
}

#else

#include <uuid.h>

std::string UUIDGenerator::generate()
{
uuid_t uuid;
char str[40] = { 0 };

uuid_generate(uuid);
uuid_unparse(uuid, str);
return std::string(str, 36);
}

#endif
26 changes: 26 additions & 0 deletions flamingoclient/Source/UUIDGenerator.h
Original file line number Diff line number Diff line change
@@ -0,0 1,26 @@
/**
* 全局唯一的UUID生成工具类,Windows上实际使用的是GUID, UUIDGenerator.h
* zhangyl 20190710
*/

#ifndef __UUID_GENERATOR_H__
#define __UUID_GENERATOR_H__

#include <string>

class UUIDGenerator final
{
private:
UUIDGenerator() = delete;
~UUIDGenerator() = delete;

UUIDGenerator(const UUIDGenerator& rhs) = delete;
UUIDGenerator& operator =(const UUIDGenerator& rhs) = delete;

public:
static std::string generate();

};

#endif //!__UUID_GENERATOR_H__

Loading

0 comments on commit aca7036

Please sign in to comment.