mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
CDClientSnapshot converts a copy of the client's fdb into its own CDServer-<hash>.sqlite with the cdserver migrations applied, on its own connection. CDClientDatabase::Reconnect opens the new file before letting go of the old one; CDClientManager::Reload empties every table (old entries kept alive so references from spawned objects stay valid), retires the old fdb view and loads again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
1.4 KiB
C++
57 lines
1.4 KiB
C++
#pragma once
|
|
|
|
// C++
|
|
#include <string>
|
|
|
|
// SQLite
|
|
#include "CppSQLite3.h"
|
|
|
|
/*
|
|
* Optimization settings
|
|
*/
|
|
|
|
#include <sstream>
|
|
#include <iostream>
|
|
|
|
//! The CDClient Database namespace
|
|
namespace CDClientDatabase {
|
|
/**
|
|
* Boolean defining the connection status of CDClient
|
|
*/
|
|
extern bool isConnected;
|
|
|
|
//! Opens a connection with the CDClient
|
|
/*!
|
|
\param filename The filename
|
|
*/
|
|
void Connect(const std::string& filename);
|
|
|
|
/**
|
|
* Switches to another CDServer.sqlite (a CDClient reload, see FdbSnapshot.h). The new file is opened before the
|
|
* old connection is let go; throws CppSQLite3Exception and keeps the old one if it can't be opened.
|
|
*/
|
|
void Reconnect(const std::string& filename);
|
|
|
|
//! Queries the CDClient
|
|
/*!
|
|
\param query The query
|
|
\return The results of the query
|
|
*/
|
|
CppSQLite3Query ExecuteQuery(const std::string& query);
|
|
|
|
//! Updates the CDClient file with Data Manipulation Language (DML) commands.
|
|
/*!
|
|
\param query The DML command to run. DML command can be multiple queries in one string but only
|
|
the last one will return its number of updated rows.
|
|
\return The number of updated rows.
|
|
*/
|
|
int ExecuteDML(const std::string& query);
|
|
|
|
//! Queries the CDClient and parses arguments
|
|
/*!
|
|
\param query The query with formatted arguments
|
|
\return prepared SQLite Statement
|
|
*/
|
|
CppSQLite3Statement CreatePreppedStmt(const std::string& query);
|
|
};
|