Skip to content

Commit

Permalink
Added helper function to create a UUID from binary data.
Browse files Browse the repository at this point in the history
  • Loading branch information
parnham committed Oct 31, 2024
1 parent b2cfee5 commit 500fe16
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/emergent/Uuid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <emergent/Emergent.hpp>
#include <random>
#include <span>



Expand Down Expand Up @@ -41,6 +42,15 @@ namespace emergent
}


#ifdef __cpp_lib_span
uuid(std::span<const byte, 128> data)
{
this->a = *reinterpret_cast<const uint64_t *>(data.first<64>().data());
this->b = *reinterpret_cast<const uint64_t *>(data.last<64>().data());
}
#endif


std::string to_string()
{
static const char *NIBBLE = "0123456789abcdef";
Expand Down

0 comments on commit 500fe16

Please sign in to comment.