mirror of
https://github.com/open-goal/jak-project
synced 2026-06-02 10:10:44 -04:00
LSP: OpenGOAL Feature Support - Part 1 (#2668)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "string_util.h"
|
||||
|
||||
#include <random>
|
||||
#include <regex>
|
||||
|
||||
#include "common/util/diff.h"
|
||||
@@ -101,4 +102,23 @@ bool replace(std::string& str, const std::string& from, const std::string& to) {
|
||||
str.replace(start_pos, from.length(), to);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string uuid() {
|
||||
static std::random_device dev;
|
||||
static std::mt19937 rng(dev());
|
||||
|
||||
std::uniform_int_distribution<int> dist(0, 15);
|
||||
|
||||
const char* v = "0123456789abcdef";
|
||||
const bool dash[] = {0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0};
|
||||
|
||||
std::string res;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (dash[i])
|
||||
res += "-";
|
||||
res += v[dist(rng)];
|
||||
res += v[dist(rng)];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
} // namespace str_util
|
||||
|
||||
Reference in New Issue
Block a user