VAE - Virtual Audio Engine 1
Small Data Driven Audio Engine
tklb::uuid Namespace Reference

Functions

void generate (char(&uuid)[UUIDLength])
 
bool isValid (const char *uuid, bool checkLength=true)
 
bool isValid (const char(&uuid)[UUIDLength])
 

Variables

constexpr int UUIDLength = 36
 
constexpr int DashPos [] = { 9, 14, 19, 24 }
 
constexpr char CharacterSet [] = "abcdefghijklmnopqrstuvwxyz0123456789"
 

Function Documentation

◆ generate()

void tklb::uuid::generate ( char(&)  uuid[UUIDLength])

Definition at line 13 of file TUUID.h.

13 {
14 std::srand(std::time(nullptr));
15 for (int i = 0; i < UUIDLength; i++) {
16 uuid[i] = CharacterSet[std::rand() % (sizeof(CharacterSet) - 1)];
17 }
18 for (int i : DashPos) { uuid[i] = '-'; }
19 }
constexpr int DashPos[]
Definition: TUUID.h:10
constexpr char CharacterSet[]
Definition: TUUID.h:11
constexpr int UUIDLength
Definition: TUUID.h:9

◆ isValid() [1/2]

bool tklb::uuid::isValid ( const char *  uuid,
bool  checkLength = true 
)

Definition at line 21 of file TUUID.h.

21 {
22 if (checkLength && uuid[UUIDLength] != '\0') { return false; } // too long
23 for (int i : DashPos) { if (uuid[i] != '-') { return false; } }
24
25 for (int i = 0; i < UUIDLength; i++) {
26 const char c = uuid[i];
27 if ((('a' <= c) && (c <= 'z')) || (('0' <= c) && (c <= '9')) || (c == '-')) {
28 // valid character
29 } else { return false; } // invalid character
30 }
31 return true;
32 }
Here is the caller graph for this function:

◆ isValid() [2/2]

bool tklb::uuid::isValid ( const char(&)  uuid[UUIDLength])

Definition at line 34 of file TUUID.h.

34 {
35 // skips length check if the length is matched
36 return isValid(reinterpret_cast<const char*>(uuid), false);
37 }
bool isValid(const char(&uuid)[UUIDLength])
Definition: TUUID.h:34
Here is the call graph for this function:

Variable Documentation

◆ CharacterSet

constexpr char tklb::uuid::CharacterSet[] = "abcdefghijklmnopqrstuvwxyz0123456789"
constexpr

Definition at line 11 of file TUUID.h.

◆ DashPos

constexpr int tklb::uuid::DashPos[] = { 9, 14, 19, 24 }
constexpr

Definition at line 10 of file TUUID.h.

◆ UUIDLength

constexpr int tklb::uuid::UUIDLength = 36
constexpr

Definition at line 9 of file TUUID.h.