MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / moduleTypeEncodeId

Function moduleTypeEncodeId

src/module.cpp:4375–4391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4373 "0123456789-_";
4374
4375uint64_t moduleTypeEncodeId(const char *name, int encver) {
4376 /* We use 64 symbols so that we can map each character into 6 bits
4377 * of the final output. */
4378 const char *cset = ModuleTypeNameCharSet;
4379 if (strlen(name) != 9) return 0;
4380 if (encver < 0 || encver > 1023) return 0;
4381
4382 uint64_t id = 0;
4383 for (int j = 0; j < 9; j++) {
4384 const char *p = strchr(cset,name[j]);
4385 if (!p) return 0;
4386 unsigned long pos = p-cset;
4387 id = (id << 6) | pos;
4388 }
4389 id = (id << 10) | encver;
4390 return id;
4391}
4392
4393/* Search, in the list of exported data types of all the modules registered,
4394 * a type with the same name as the one given. Returns the moduleType

Callers 3

RM_CreateDataTypeFunction · 0.85
RM_SendClusterMessageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected