Files
codebase-memory-mcp/internal/cbm/sqlite_writer.h
T
Martin Vogel 94a9a92f83 Add C-native pipeline with blocking clang-tidy, cppcheck, clang-format linting
Complete C implementation of the indexing pipeline (src/), parallel worker
pool, graph buffer with merge support, SQLite writer, and 1893-test suite.

Linter setup: zero warnings from clang-tidy (all checks enabled, no NOLINT
suppressions), cppcheck, and clang-format. All issues fixed at source —
proper headers for external linkage, GROW_ARRAY macro restructured to
eliminate type parameter, null-deref paths guarded, named intermediates
for suspicious-argument checks.
2026-03-15 19:26:12 +01:00

40 lines
1.2 KiB
C

#ifndef CBM_SQLITE_WRITER_H
#define CBM_SQLITE_WRITER_H
#include <stdint.h>
// --- Input structs (flat, borrowed strings) ---
typedef struct {
int64_t id; // sequential ID (1..N), assigned by Go
const char *project;
const char *label;
const char *name;
const char *qualified_name;
const char *file_path;
int start_line;
int end_line;
const char *properties; // JSON string
} CBMDumpNode;
typedef struct {
int64_t id; // sequential ID (1..M), assigned by Go
const char *project;
int64_t source_id; // final sequential ID (1..N)
int64_t target_id; // final sequential ID (1..N)
const char *type;
const char *properties; // JSON string
const char *url_path; // extracted from properties by Go (for idx_edges_url_path)
} CBMDumpEdge;
// --- Public API ---
// Write a complete SQLite .db file from sorted in-memory data.
// Constructs B-tree pages directly — no SQL parser, no INSERTs.
// Returns 0 on success, non-zero on error.
int cbm_write_db(const char *path, const char *project, const char *root_path,
const char *indexed_at, CBMDumpNode *nodes, int node_count, CBMDumpEdge *edges,
int edge_count);
#endif // CBM_SQLITE_WRITER_H