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

Function node_string_field

src/cypher/cypher.c:2218–2240  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2216
2217/* Return a string field from a node by property name. NULL-safe. */
2218static const char *node_string_field(const cbm_node_t *n, const char *prop) {
2219 static const struct {
2220 const char *key;
2221 size_t offset;
2222 } fields[] = {
2223 {"name", offsetof(cbm_node_t, name)},
2224 {"qualified_name", offsetof(cbm_node_t, qualified_name)},
2225 /* Aliases: field-eval agents reach for the short names, and a miss
2226 * used to return a silent empty column costing a round-trip. */
2227 {"qn", offsetof(cbm_node_t, qualified_name)},
2228 {"label", offsetof(cbm_node_t, label)},
2229 {"file_path", offsetof(cbm_node_t, file_path)},
2230 {"file", offsetof(cbm_node_t, file_path)},
2231 {"path", offsetof(cbm_node_t, file_path)},
2232 };
2233 for (size_t i = 0; i < sizeof(fields) / sizeof(fields[0]); i++) {
2234 if (strcmp(prop, fields[i].key) == 0) {
2235 const char *val = *(const char **)((const char *)n + fields[i].offset);
2236 return val ? val : "";
2237 }
2238 }
2239 return NULL;
2240}
2241
2242/* Get node property by name.
2243 * 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