66 lines
1.7 KiB
C
66 lines
1.7 KiB
C
#ifndef VTX_CLIENT_H
|
||
#define VTX_CLIENT_H
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
/**
|
||
* VTXClient 结构体的前向声明。
|
||
*
|
||
* 在 .h 中仅提供前向声明,以隐藏其内部实现细节。
|
||
* 在 .c 文件中再进行完整定义。
|
||
*/
|
||
typedef struct VTXClient VTXClient;
|
||
|
||
/**
|
||
* 初始化 VTXClient。
|
||
*
|
||
* @return 如果成功,返回指向 VTXClient 的指针;否则返回 NULL。
|
||
*/
|
||
VTXClient* vtx_client_init(void);
|
||
|
||
/**
|
||
* 向指定的表(table)中设置 key-value 对。
|
||
*
|
||
* @param client 已初始化的 VTXClient 指针。
|
||
* @param table 目标表(如 "robot_config")。
|
||
* @param key 键名。
|
||
* @param value 值。
|
||
*/
|
||
void vtx_client_set(VTXClient* client, const char* table, const char* key, const char* value);
|
||
|
||
/**
|
||
* 从指定的表(table)中获取 key 对应的 value。
|
||
* 如果 key 为空字符串,则返回表中所有内容的 JSON 字符串。
|
||
*
|
||
* @param client 已初始化的 VTXClient 指针。
|
||
* @param table 目标表。
|
||
* @param key 要查询的键名(可为空字符串 "")。
|
||
*
|
||
* @return 成功时返回一个动态分配的字符串指针,使用完后需自行 free 释放;失败时返回 NULL。
|
||
*/
|
||
char* vtx_client_get(VTXClient* client, const char* table, const char* key);
|
||
|
||
/**
|
||
* 从指定的表(table)中删除 key。
|
||
*
|
||
* @param client 已初始化的 VTXClient 指针。
|
||
* @param table 目标表。
|
||
* @param key 要删除的键名。
|
||
*/
|
||
void vtx_client_delete(VTXClient* client, const char* table, const char* key);
|
||
|
||
/**
|
||
* 关闭并释放 VTXClient 所占用的资源。
|
||
*
|
||
* @param client 要关闭的 VTXClient 指针。
|
||
*/
|
||
void vtx_client_close(VTXClient* client);
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
|
||
#endif // VTX_CLIENT_H
|