From 190596500eaf3f353fb2d6432c5b48a39cdf9282 Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Wed, 26 Mar 2025 10:30:07 -0400 Subject: pkuuid: add == and != --- pkuuid.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'pkuuid.h') diff --git a/pkuuid.h b/pkuuid.h index 7426f79..30d4a24 100644 --- a/pkuuid.h +++ b/pkuuid.h @@ -18,12 +18,15 @@ void pk_uuid_init(time_t srand_seed); void pk_uuid_teardown(); struct pk_uuid pk_uuid_new_v7(); +bool pk_uuid_equals(struct pk_uuid lhs, struct pk_uuid rhs); #if defined(__cplusplus) #include #include std::ostream& operator<<(std::ostream &o, const struct pk_uuid& uuid); std::istream& operator>>(std::istream &i, struct pk_uuid& uuid); +bool operator==(const pk_uuid &lhs, const pk_uuid &rhs) { return pk_uuid_equals(lhs, rhs); } +bool operator!=(const pk_uuid &lhs, const pk_uuid &rhs) { return !pk_uuid_equals(lhs, rhs); } #endif #endif /* PK_UUID_H */ @@ -135,6 +138,15 @@ pk_uuid_new_v7() return ret; } +bool pk_uuid_equals(struct pk_uuid lhs, struct pk_uuid rhs) +{ + int i; + for (i = 0; i < 16; ++i) { + if (lhs.uuid[i] != rhs.uuid[i]) return false; + } + return true; +} + #if defined(__cplusplus) #include "./pkstn.h" /* deleteme */ std::ostream& -- cgit v1.2.3