mirror of
https://onedev.site.tesses.net/tesses-framework
synced 2026-03-26 03:10:21 +00:00
Add Uuids
This commit is contained in:
32
include/TessesFramework/Uuid.hpp
Normal file
32
include/TessesFramework/Uuid.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
#include "Common.hpp"
|
||||
|
||||
namespace Tesses::Framework {
|
||||
enum class UuidStringifyConfig {
|
||||
IsUppercase=0b001,
|
||||
HasCurly=0b010,
|
||||
HasDashes=0b100,
|
||||
UppercaseCompact = IsUppercase,
|
||||
LowercaseCompact = 0,
|
||||
UppercaseNoCurly = IsUppercase | HasDashes,
|
||||
LowercaseNoCurly = HasDashes,
|
||||
UppercaseCurly = IsUppercase | HasDashes | HasCurly,
|
||||
LowercaseCurly = HasDashes | HasCurly
|
||||
};
|
||||
struct Uuid {
|
||||
Uuid() = default;
|
||||
uint32_t time_low = 0;
|
||||
uint16_t time_mid = 0;
|
||||
uint16_t time_hi_and_version = 0;
|
||||
uint8_t clock_seq_hi_and_reserved = 0;
|
||||
uint8_t clock_seq_low = 0;
|
||||
uint8_t node[6] = {0,0,0,0,0,0};
|
||||
|
||||
static Uuid Generate();
|
||||
static void Generate(Uuid& uuid);
|
||||
|
||||
static bool TryParse(std::string text, Uuid& uuid);
|
||||
|
||||
std::string ToString(UuidStringifyConfig cfg = UuidStringifyConfig::UppercaseCurly);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user