refactor(cdclient): FdbToSqlite can convert into a connection of its own

So a worker can make a new CDServer.sqlite without touching the shared
CDClient connection or the logger.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-29 22:42:40 -05:00
parent 1a8e4e387c
commit 1e0fc92f2e
2 changed files with 34 additions and 8 deletions

View File

@@ -11,6 +11,8 @@
enum class eSqliteDataType : int32_t;
#include "CppSQLite3.h"
namespace FdbToSqlite {
class Convert {
public:
@@ -22,12 +24,21 @@ namespace FdbToSqlite {
*/
Convert(std::string binaryOutPath);
/**
* Converts into a connection of the caller's own instead of the shared CDClient one, so it can run on a
* worker thread. Nothing is logged; GetError says what went wrong.
*/
explicit Convert(CppSQLite3DB& db);
// Why the last ConvertDatabase failed
[[nodiscard]] const std::string& GetError() const { return m_Error; }
/**
* Converts the input file to sqlite. Calling multiple times is safe.
*
* @return true if the database was converted properly, false otherwise.
*/
bool ConvertDatabase(AssetStream& buffer);
bool ConvertDatabase(std::istream& buffer);
/**
* @brief Reads a 32 bit int from the fdb file.
@@ -139,6 +150,13 @@ namespace FdbToSqlite {
* The path where the CDServer will be stored
*/
std::string m_BinaryOutPath{};
// The caller's own connection, or nullptr for the shared CDClient one
CppSQLite3DB* m_Db{};
std::string m_Error{};
void ExecDML(const std::string& sql);
}; //! class FdbToSqlite
}; //! namespace FdbToSqlite