a little lcean up
This commit is contained in:
35
lib/uuid.cpp
35
lib/uuid.cpp
@ -1,35 +0,0 @@
|
||||
#include "uuid.h"
|
||||
|
||||
namespace uuid {
|
||||
static std::random_device rd;
|
||||
static std::mt19937 gen(rd());
|
||||
static std::uniform_int_distribution<> dis(0, 15);
|
||||
static std::uniform_int_distribution<> dis2(8, 11);
|
||||
|
||||
std::string generate_uuid_v4() {
|
||||
std::stringstream ss;
|
||||
int i;
|
||||
ss << std::hex;
|
||||
for (i = 0; i < 8; i++) {
|
||||
ss << dis(gen);
|
||||
}
|
||||
ss << "-";
|
||||
for (i = 0; i < 4; i++) {
|
||||
ss << dis(gen);
|
||||
}
|
||||
ss << "-4";
|
||||
for (i = 0; i < 3; i++) {
|
||||
ss << dis(gen);
|
||||
}
|
||||
ss << "-";
|
||||
ss << dis2(gen);
|
||||
for (i = 0; i < 3; i++) {
|
||||
ss << dis(gen);
|
||||
}
|
||||
ss << "-";
|
||||
for (i = 0; i < 12; i++) {
|
||||
ss << dis(gen);
|
||||
};
|
||||
return ss.str();
|
||||
}
|
||||
} // namespace uuid
|
12
lib/uuid.h
12
lib/uuid.h
@ -1,12 +0,0 @@
|
||||
#ifndef UUID_H
|
||||
#define UUID_H
|
||||
|
||||
#include <random>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace uuid {
|
||||
std::string generate_uuid_v4();
|
||||
}
|
||||
|
||||
#endif // UUID_H
|
Reference in New Issue
Block a user