MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / node_keys_list

Function node_keys_list

src/cypher/cypher.c:4123–4156  ·  view source on GitHub ↗

Build a JSON list of a node's non-null property keys: keys(n). */

Source from the content-addressed store, hash-verified

4121
4122/* Build a JSON list of a node's non-null property keys: keys(n). */
4123static const char *node_keys_list(const cbm_node_t *n, char *buf, size_t buf_sz) {
4124 const struct {
4125 const char *k;
4126 bool present;
4127 } ks[] = {
4128 {"name", n->name && n->name[0]},
4129 {"qualified_name", n->qualified_name && n->qualified_name[0]},
4130 {"label", n->label && n->label[0]},
4131 {"file_path", n->file_path && n->file_path[0]},
4132 {"start_line", n->start_line > 0},
4133 {"end_line", n->end_line > 0},
4134 };
4135 size_t pos = 0;
4136 bool first = true;
4137 if (pos < buf_sz - SKIP_ONE) {
4138 buf[pos++] = '[';
4139 }
4140 for (size_t i = 0; i < sizeof(ks) / sizeof(ks[0]) && pos < buf_sz - SKIP_ONE; i++) {
4141 if (!ks[i].present) {
4142 continue;
4143 }
4144 int w = snprintf(buf + pos, buf_sz - pos, "%s\"%s\"", first ? "" : ",", ks[i].k);
4145 if (w < 0 || (size_t)w >= buf_sz - pos) {
4146 break;
4147 }
4148 pos += (size_t)w;
4149 first = false;
4150 }
4151 if (pos < buf_sz - SKIP_ONE) {
4152 buf[pos++] = ']';
4153 }
4154 buf[pos] = '\0';
4155 return buf;
4156}
4157
4158/* Resolve a function argument to its string value (literal or var.prop). */
4159static const char *eval_func_arg(binding_t *b, const cbm_func_arg_t *a) {

Callers 1

project_itemFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected