17#include "utils/uuid.h"
30 static const char hex_chars[] =
"0123456789abcdef";
35 if (i == 4 || i == 6 || i == 8 || i == 10)
38 int hi = uuid.
data[i] >> 4;
39 int lo = uuid.
data[i] & 0x0F;
41 result+=hex_chars[hi];
42 result+=hex_chars[lo];
56 const char *src = source.c_str();
71 if (src[0] ==
'\0' || src[1] ==
'\0')
73 memcpy(str_buf, src, 2);
74 if (!isxdigit((
unsigned char) str_buf[0]) ||
75 !isxdigit((
unsigned char) str_buf[1]))
79 uuid.
data[i] = (
unsigned char) strtoul(str_buf, NULL, 16);
81 if (src[0] ==
'-' && (i % 2) == 1 && i <
UUID_LEN - 1)
99 (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
100 errmsg(
"invalid input syntax for type %s: \"%s\"",
112 return *
reinterpret_cast<const std::size_t*
>(&u);
Generic directed-acyclic-graph circuit template and gate identifier.
Core types, constants, and utilities shared across ProvSQL.
#define UUID_LEN
Number of bytes in a UUID.
pg_uuid_t string2uuid(const string &source)
Parse a UUID string into a pg_uuid_t.
string uuid2string(pg_uuid_t uuid)
Format a pg_uuid_t as a std::string.
std::size_t hash_value(const pg_uuid_t &u)
Compute a hash value for a pg_uuid_t.
string UUIDDatum2string(Datum token)
Convert a PostgreSQL Datum holding a UUID to a std::string.
bool operator==(const pg_uuid_t &u, const pg_uuid_t &v)
Test two pg_uuid_t values for equality.
C++ utility functions for UUID manipulation.
unsigned char data[UUID_LEN]
Raw 16-byte UUID storage.