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

Function node_string_field

src/cypher/cypher.c:2336–2358  ·  view source on GitHub ↗

Return a string field from a node by property name. NULL-safe. */

Source from the content-addressed store, hash-verified

2334
2335/* Return a string field from a node by property name. NULL-safe. */
2336static const char *node_string_field(const cbm_node_t *n, const char *prop) {
2337 static const struct {
2338 const char *key;
2339 size_t offset;
2340 } fields[] = {
2341 {"name", offsetof(cbm_node_t, name)},
2342 {"qualified_name", offsetof(cbm_node_t, qualified_name)},
2343 /* Aliases: field-eval agents reach for the short names, and a miss
2344 * used to return a silent empty column costing a round-trip. */
2345 {"qn", offsetof(cbm_node_t, qualified_name)},
2346 {"label", offsetof(cbm_node_t, label)},
2347 {"file_path", offsetof(cbm_node_t, file_path)},
2348 {"file", offsetof(cbm_node_t, file_path)},
2349 {"path", offsetof(cbm_node_t, file_path)},
2350 };
2351 for (size_t i = 0; i < sizeof(fields) / sizeof(fields[0]); i++) {
2352 if (strcmp(prop, fields[i].key) == 0) {
2353 const char *val = *(const char **)((const char *)n + fields[i].offset);
2354 return val ? val : "";
2355 }
2356 }
2357 return NULL;
2358}
2359
2360/* Get node property by name.
2361 * store may be NULL; only needed for virtual degree properties. */

Callers 1

node_propFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected