IgANet
IgANets - Isogeometric Analysis Networks
Loading...
Searching...
No Matches
uuid.hpp
Go to the documentation of this file.
1
15#pragma once
16
17#include <random>
18#include <sstream>
19
20namespace iganet {
21namespace utils {
22
23class uuid {
24public:
29 static std::string create() {
30 std::stringstream hexstream;
31 hexstream << uuid::random_hex(4) << "-" << uuid::random_hex(2) << "-"
32 << uuid::random_hex(2) << "-" << uuid::random_hex(2) << "-"
33 << uuid::random_hex(6);
34 return hexstream.str();
35 }
36
37private:
43 static std::string random_hex(const unsigned int len) {
44 std::stringstream ss;
45 for (auto i = 0; i < len; i++) {
46 const auto rc = random_char();
47 std::stringstream hexstream;
48 hexstream << std::hex << rc;
49 auto hex = hexstream.str();
50 ss << (hex.length() < 2 ? '0' + hex : hex);
51 }
52 return ss.str();
53 }
54
58 static unsigned int random_char() {
59 std::random_device rd;
60 std::mt19937 gen(rd());
61 std::uniform_int_distribution<> dis(0, 255);
62 return dis(gen);
63 }
64};
65
66} // namespace utils
67} // namespace iganet
Definition uuid.hpp:23
static unsigned int random_char()
Generates a safe pseudo-random character.
Definition uuid.hpp:58
static std::string create()
Generates a uuid string in the form b9317db-02a2-4882-9b94-d1e1defe8c56.
Definition uuid.hpp:29
static std::string random_hex(const unsigned int len)
Generates a string of random hex chars.
Definition uuid.hpp:43
Definition boundary.hpp:22
constexpr bool is_SplineType_v
Alias to the value of is_SplineType.
Definition bspline.hpp:3243