ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
provsql_utils_cpp.cpp File Reference

C++ UUID utility function implementations. More...

#include "postgres.h"
#include "utils/uuid.h"
#include "provsql_utils.h"
#include "provsql_utils_cpp.h"
#include <cassert>
#include "Circuit.h"
Include dependency graph for provsql_utils_cpp.cpp:

Go to the source code of this file.

Functions

string uuid2string (pg_uuid_t uuid)
 Format a pg_uuid_t as a std::string.
 
pg_uuid_t string2uuid (const string &source)
 Parse a UUID string into a pg_uuid_t.
 
string UUIDDatum2string (Datum token)
 Convert a PostgreSQL Datum holding a UUID to a std::string.
 
std::size_t hash_value (const pg_uuid_t &u)
 Compute a hash value for a pg_uuid_t.
 
bool operator== (const pg_uuid_t &u, const pg_uuid_t &v)
 Test two pg_uuid_t values for equality.
 

Detailed Description

C++ UUID utility function implementations.

Implements the C++ helper functions declared in provsql_utils_cpp.h:

The uuid2string and string2uuid functions are adapted from PostgreSQL's own uuid.c, which is not exposed as a public API.

Definition in file provsql_utils_cpp.cpp.

Function Documentation

◆ hash_value()

std::size_t hash_value ( const pg_uuid_t u)

Compute a hash value for a pg_uuid_t.

Reinterprets the 16-byte UUID as two 64-bit integers and XOR-combines their standard hashes. Used by Boost's hash infrastructure so that pg_uuid_t can be used as a key in Boost multi-index containers.

Parameters
uThe UUID to hash.
Returns
A std::size_t hash value.

Definition at line 110 of file provsql_utils_cpp.cpp.

◆ operator==()

bool operator== ( const pg_uuid_t u,
const pg_uuid_t v 
)

Test two pg_uuid_t values for equality.

Compares all 16 bytes of the UUID data.

Parameters
uFirst UUID.
vSecond UUID.
Returns
true if u and v represent the same UUID.

Definition at line 115 of file provsql_utils_cpp.cpp.

◆ string2uuid()

pg_uuid_t string2uuid ( const string &  source)

Parse a UUID string into a pg_uuid_t.

Parameters
sourceUUID string in standard hyphenated hex format.
Returns
The parsed pg_uuid_t value.

Definition at line 53 of file provsql_utils_cpp.cpp.

Here is the caller graph for this function:

◆ uuid2string()

string uuid2string ( pg_uuid_t  uuid)

Format a pg_uuid_t as a std::string.

Parameters
uuidThe UUID to format.
Returns
The UUID as a 36-character hyphenated hex std::string.

Definition at line 28 of file provsql_utils_cpp.cpp.

Here is the caller graph for this function:

◆ UUIDDatum2string()

string UUIDDatum2string ( Datum  token)

Convert a PostgreSQL Datum holding a UUID to a std::string.

Detoasts and formats the UUID value as the standard 36-character hyphenated hex string (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

Parameters
tokenA Datum containing a pg_uuid_t value.
Returns
The UUID as a std::string.

Definition at line 104 of file provsql_utils_cpp.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: