aboutsummaryrefslogtreecommitdiff
path: root/include/kpl/identifier.h
diff options
context:
space:
mode:
authornodist <kevin.comas.git@gmail.com>2026-11-13 16:28:13 -0500
committernodist <kevin.comas.git@gmail.com>2026-11-13 16:28:13 -0500
commitc3d23d3091c23978b12c140e6cfd964eff1d3986 (patch)
tree3342a73aea427fa19d2b0936a98e37fbe479c85d /include/kpl/identifier.h
parent75c8828d804f45cf8f44af73bfe87e0f3eaf9a9e (diff)
rewriteHEADmain
Diffstat (limited to 'include/kpl/identifier.h')
-rw-r--r--include/kpl/identifier.h58
1 files changed, 0 insertions, 58 deletions
diff --git a/include/kpl/identifier.h b/include/kpl/identifier.h
deleted file mode 100644
index 9bb42b0..0000000
--- a/include/kpl/identifier.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Thread safe identifiers, at the cost of space remove the need for hash/tree lookups
- * Keep 50 [A-Za-z0-9_] Characters in 40 bytes
- */
-
-#pragma once
-
-#define KPL_IDENTIFIER_PARTS 5
-
-#define KPL_IDENTIFIER_BITS_PER_PART 64
-
-#define KPL_IDENTIFIER_BITS_PER_VALUE 6
-
-#define KPL_IDENTIFIER_VALUES_PER_PART (KPL_IDENTIFIER_BITS_PER_PART / KPL_IDENTIFIER_BITS_PER_VALUE)
-
-#define KPL_IDENTIFIER_MAX_LENGTH (KPL_IDENTIFIER_VALUES_PER_PART * KPL_IDENTIFIER_PARTS)
-
-#define KPL_IDENTIFIER_C_STRING_SIZE (KPL_IDENTIFIER_MAX_LENGTH + sizeof(char))
-
-/*
- * Each character takes 6 bits from bit 0 to bit 59
- * The upper 4 bits represent the number of characters in the part
- */
-typedef struct {
- uint64_t parts[KPL_IDENTIFIER_PARTS];
-} kpl_identifier;
-
-/*
- * Converts a c string into an identifier
- * Checks if the c_string_length <= KPL_IDENTIFIER_MAX_LENGTH
- */
-bool kpl_identifier_encode(kpl_identifier *identifier, const char *c_string, size_t c_string_length);
-
-/*
- * Converts an identifier into a c string
- * Does not clear the c_string buffer
- * Does not check the c_string buffer size assumes the buffer is at least KPL_IDENTIFIER_C_STRING_SIZE
- */
-void kpl_identifier_decode(kpl_identifier *identifier, char c_string[KPL_IDENTIFIER_C_STRING_SIZE]);
-
-/*
- * Compares identifiers like strings
- * 0 - equal, negative - left < right, positive - left > right
- */
-int32_t kpl_identifier_compare(const kpl_identifier *identifier_left, const kpl_identifier *identifier_right);
-
-/*
- * Check if two identifiers are equal
- * Faster then comparing when equality check is needed
- */
-inline bool kpl_identifier_equal(const kpl_identifier *identifier_a, const kpl_identifier *identifier_b) {
- for (int32_t part_index = 0; part_index < KPL_IDENTIFIER_PARTS; part_index++)
- if (!identifier_a->parts[part_index] && !identifier_b->parts[part_index])
- break;
- else if (identifier_a->parts[part_index] != identifier_b->parts[part_index])
- return false;
- return true;
-}