summaryrefslogtreecommitdiff
path: root/pkuuid.h
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-03-26 10:30:07 -0400
committerJonathan Bradley <jcb@pikum.xyz>2025-03-26 10:30:07 -0400
commit190596500eaf3f353fb2d6432c5b48a39cdf9282 (patch)
tree60148d6e1c59ec886ead142368e5abbceb979932 /pkuuid.h
parent8bab21d24ece666a9af89efbd461b722a4a7f1b2 (diff)
pkuuid: add == and !=
Diffstat (limited to 'pkuuid.h')
-rw-r--r--pkuuid.h12
1 files changed, 12 insertions, 0 deletions
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 <ostream>
#include <iomanip>
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&