20#ifndef KICAD_SQLITE_BACKEND_H
21#define KICAD_SQLITE_BACKEND_H
60 bool ListTables( std::vector<std::string>& aTables )
override;
62 std::optional<DB_TABLE_INFO>
DescribeTable(
const std::string& aTable )
override;
66 std::vector<std::string>& aLabels,
const DB_ROW_SINK& aSink )
override;
79 static std::string
FileUri(
const std::string& aPath,
bool aWindowsPath );
82 static bool IsUncPath(
const std::string& aPath );
92 static bool IsRemoteFuseMount(
const std::string& aMountInfo,
const std::string& aPath );
116 std::shared_ptr<SQLITE_DB>
m_db;
A read-only source of tables.
What a job running on a DB_WORKER_THREAD uses to hand rows to the caller.
static bool IsUncPath(const std::string &aPath)
std::unique_ptr< DB_WORKER_THREAD > m_worker
void failCall(DB_FAILURE aFailure, std::string aMessage)
Records a failure of a call that ran, and drops the connection if the failure means it cannot be trus...
bool ListTables(std::vector< std::string > &aTables) override
Lists the tables and views, sorted by name.
void fail(DB_FAILURE aFailure, std::string aError)
SQLITE_BACKEND(std::string aPath, int aTimeoutSeconds)
~SQLITE_BACKEND() override
bool ReadTable(const DB_TABLE_INFO &aTable, const std::vector< std::string > &aColumns, size_t aMaxRows, std::vector< std::string > &aLabels, const DB_ROW_SINK &aSink) override
Reads rows of a table, handing each to aSink.
static std::string FileUri(const std::string &aPath, bool aWindowsPath)
Builds the read-only SQLite URI for a file.
DB_FAILURE GetLastFailure() const override
std::string GetLastError() const override
void Disconnect() override
bool requireConnection()
Fails with a message and returns false unless a connection is open.
std::chrono::milliseconds callerBound() const
std::atomic< bool > m_connected
std::shared_ptr< SQLITE_DB > m_db
bool IsConnected() const override
void dropConnection()
Forgets the connection and closes it on a worker thread, never on the caller.
static bool IsNetworkPath(const std::string &aPath)
std::optional< R > runOnWorker(std::function< R(DB_JOB_CONTEXT &)> aJob, const DB_ROW_SINK *aSink)
Runs aJob on the worker, recording why it did not finish as the failure.
static bool IsRemoteFuseMount(const std::string &aMountInfo, const std::string &aPath)
Decides from the text of /proc/self/mountinfo whether aPath lies on a FUSE mount that reaches a remot...
std::optional< DB_TABLE_INFO > DescribeTable(const std::string &aTable) override
std::function< void(std::vector< DB_VALUE > &&)> DB_ROW_SINK
Receives one row at a time, in the order of the labels the read produced.
DB_FAILURE
Why a connection attempt failed, as far as the backend's report tells.
Owns one connection, which a worker thread opens and uses.