18#include "fb_gen/guid_generated.h"
19#include "functional_dag/error_codes.h"
43 GUID(
const GUID_vals &_values);
96 return _left.
m_id.bits1() == _right.
m_id.bits1() &&
97 _left.
m_id.bits2() == _right.
m_id.bits2();
111 return _left.
m_id.bits1() < _right.
m_id.bits1() ||
112 (_left.
m_id.bits1() == _right.
m_id.bits1() &&
113 _left.
m_id.bits2() < _right.
m_id.bits2());
119 uint32_t first_four_bytes = (
m_id.bits1() >> 4 * 8);
120 uint16_t second_two_bytes = (
m_id.bits1() << 4 * 8) >> 6 * 8;
121 uint16_t last_two_bytes = (
m_id.bits1() & ((255 << 8) + 255));
123 uint16_t first_two_bytes = (
m_id.bits2() >> 6 * 8);
124 uint64_t last_six_bytes = (
m_id.bits2() << 2 * 8 >> 2 * 8);
126 uuid << hex << first_four_bytes <<
"-" << hex << second_two_bytes <<
"-"
127 << hex << last_two_bytes <<
"-" << hex << first_two_bytes <<
"-" << hex
134 constexpr uint64_t expect_len[5] = {8, 4, 4, 4, 12};
135 uint64_t first_four_bytes;
136 uint64_t second_two_bytes;
137 uint64_t last_two_bytes;
138 uint64_t first_two_bytes;
139 uint64_t last_six_bytes;
140 uint64_t *
const dest_vals[5] = {&first_four_bytes, &second_two_bytes,
141 &last_two_bytes, &first_two_bytes,
145 constexpr char sep =
'-';
146 size_t end_pos = _uuid.find(sep, pos);
147 while (end_pos != string_view::npos || i == 4) {
148 const string_view next_hex = _uuid.substr(pos, end_pos - pos);
149 if (next_hex.size() != expect_len[i]) {
153 istringstream(
string(next_hex)) >> hex >> *dest_vals[i];
160 end_pos = _uuid.find(sep, pos);
165 uint64_t bits1 = (first_four_bytes << 4 * 8) + (second_two_bytes << 2 * 8) +
167 uint64_t bits2 = (first_two_bytes << 6 * 8) + last_six_bytes;
168 return GUID<T>(GUID_vals(bits1, bits2));
(Utility) For defining a globally unique UUIDv4 identifier.
Definition guid_impl.hpp:32
static expected< GUID< T >, error_codes > from_uuid(const string_view &_uuid)
Parse a UUIDv4 representation into an internal 128bit unsigned int.
Definition guid_impl.hpp:133
GUID_vals m_id
The internal UUID representation.
Definition guid_impl.hpp:35
string to_uuid() const
Get the UUIDv4 representation of the GUID.
Definition guid_impl.hpp:117
GUID(const GUID_vals &_values)
Wrapper of the 128 bit integer.
Definition guid_impl.hpp:76
GUID(const GUID< T > &_values)
Copy constructor of the GUID.
Definition guid_impl.hpp:81
Definition guid_generated.h:16
bool operator<(const GUID< T > &_left, const GUID< T > &_right)
Less than operator.
Definition guid_impl.hpp:110
error_codes
Error codes used by the functional dag.
Definition error_codes.h:19
@ NOT_ENOUGH_ELEMENTS
Not enough UUID elements to parse.
Definition error_codes.h:24
@ HEX_SIZE_INCORRECT
A section of the UUID isn't long enough.
Definition error_codes.h:26
bool operator==(const GUID< T > &_left, const GUID< T > &_right)
Equality operator.
Definition guid_impl.hpp:95