Skip to content

Commit 4a44bf8

Browse files
Create query.h
1 parent d0f8cde commit 4a44bf8

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

code/logic/fossil/crabdb/query.h

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#ifndef FOSSIL_BLUECRAB_QUERY_H
2+
#define FOSSIL_BLUECRAB_QUERY_H
3+
4+
#include <stdbool.h>
5+
#include <stddef.h>
6+
#include <stdint.h>
7+
8+
// Include all backends
9+
#include "cacheshell.h"
10+
#include "fileshell.h"
11+
#include "timeshell.h"
12+
#include "myshell.h"
13+
#include "noshell.h"
14+
15+
#ifdef __cplusplus
16+
extern "C" {
17+
#endif
18+
19+
// -----------------------------------------------------------------------------
20+
// Forward Declarations
21+
// -----------------------------------------------------------------------------
22+
23+
typedef struct crabql_context crabql_context_t;
24+
25+
// -----------------------------------------------------------------------------
26+
// Context Management
27+
// -----------------------------------------------------------------------------
28+
29+
/**
30+
* @brief Create a new CrabQL context.
31+
*/
32+
crabql_context_t* fossil_bluecrab_query_create(void);
33+
34+
/**
35+
* @brief Destroy a CrabQL context.
36+
*/
37+
void fossil_bluecrab_query_destroy(crabql_context_t* ctx);
38+
39+
// -----------------------------------------------------------------------------
40+
// Script Execution
41+
// -----------------------------------------------------------------------------
42+
43+
/**
44+
* @brief Execute a CrabQL script from a string buffer.
45+
*
46+
* @param ctx CrabQL context
47+
* @param code CrabQL source code (UTF-8)
48+
* @return true if script ran successfully, false otherwise
49+
*/
50+
bool fossil_bluecrab_query_exec(crabql_context_t* ctx, const char* code);
51+
52+
/**
53+
* @brief Execute a CrabQL script from a file (.crabql).
54+
*
55+
* @param ctx CrabQL context
56+
* @param path Path to script file
57+
* @return true if successful
58+
*/
59+
bool fossil_bluecrab_query_exec_file(crabql_context_t* ctx, const char* path);
60+
61+
// -----------------------------------------------------------------------------
62+
// Database Utilities (Backend Agnostic)
63+
// -----------------------------------------------------------------------------
64+
65+
bool fossil_bluecrab_query_open(crabql_context_t* ctx, const char* dbfile);
66+
bool fossil_bluecrab_query_close(crabql_context_t* ctx);
67+
68+
bool fossil_bluecrab_query_insert(crabql_context_t* ctx,
69+
const char* key,
70+
const char* json_value);
71+
72+
bool fossil_bluecrab_query_update(crabql_context_t* ctx,
73+
const char* key,
74+
const char* json_value);
75+
76+
bool fossil_bluecrab_query_remove(crabql_context_t* ctx, const char* key);
77+
78+
char* fossil_bluecrab_query_get(crabql_context_t* ctx, const char* key);
79+
80+
size_t fossil_bluecrab_query_count(crabql_context_t* ctx);
81+
82+
// -----------------------------------------------------------------------------
83+
// Module Import API
84+
// -----------------------------------------------------------------------------
85+
86+
/**
87+
* @brief Import a backend-specific module into CrabQL runtime.
88+
*
89+
* Example: fossil_bluecrab_query_import(ctx, "timeshell");
90+
*/
91+
bool fossil_bluecrab_query_import(crabql_context_t* ctx, const char* module);
92+
93+
#ifdef __cplusplus
94+
}
95+
#endif
96+
97+
#endif // FOSSIL_BLUECRAB_QUERY_H

0 commit comments

Comments
 (0)