fbx_to_3dtiles/cpp_src/include/db_ops.h

36 lines
1.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <tools.h>
using namespace std;
/**
* @brief 创建并打开SQLite数据库连接
* @param db_path 数据库文件路径
* @param overwrite_file 若为true则删除已有文件后创建新数据库
* @return 成功返回sqlite3句柄失败返回NULL
*/
sqlite3* create_db(const char* db_path, bool overwrite_file);
/**
* @brief 在指定数据库中创建必要表结构
* @param db 已打开的SQLite数据库句柄
* @note 需确保db参数有效且已成功打开
*/
void create_tables(sqlite3* db);
///////////////////////////
//////// 数据保存 /////////
///////////////////////////
/**
* @brief 将网格数据元信息保存到数据库表
* @param ctx FTT上下文句柄包含日志/错误处理等公共资源
* @param db 已打开的SQLite数据库连接
* @param name 网格名称(唯一标识)
* @param vertex_count 顶点数量
* @param index_count 索引数量
* @param fbx_id 关联的FBX文件ID
* @return 成功返回SQLITE_OK失败返回SQLite错误码(<0)
* @note 1. 参数需确保有效ctx/db非NULLname/fbx_id非空
* 2. 内部自动处理事务重复name会触发唯一键冲突
*/
int save_mesh_to_table(FttContext *ctx, sqlite3 *db, uint id, const std::string &name, int vertex_count, int index_count, const std::string &fbx_id);