1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-31 08:58:43 +01:00

Various unitary fixes (#622)

* some comments

* No intermediate arrays (of arrays) of strings for query results...

... instead, let any query pass its own lambda to collect row data directly
however it needs to, for a bit of efficiency.  Also the precautions of a new
GuardedCall
This commit is contained in:
Paul Licameli
2020-07-20 18:11:43 -04:00
committed by GitHub
parent af23a14bdb
commit 9ffd169aa7
2 changed files with 70 additions and 79 deletions

View File

@@ -120,6 +120,10 @@ public:
bool TransactionCommit(const wxString &name);
bool TransactionRollback(const wxString &name);
// Type of function that is given the fields of one row and returns
// 0 for success or non-zero to stop the query
using ExecCB = std::function<int(int cols, char **vals, char **names)>;
private:
void WriteXMLHeader(XMLWriter &xmlFile) const;
void WriteXML(XMLWriter &xmlFile, bool recording = false, const std::shared_ptr<TrackList> &tracks = nullptr) /* not override */;
@@ -130,15 +134,7 @@ private:
void UpdatePrefs() override;
using ExecResult = std::vector<std::vector<wxString>>;
using ExecCB = std::function<int(ExecResult &result, int cols, char **vals, char **names)>;
struct ExecParm
{
ExecCB func;
ExecResult &result;
};
static int ExecCallback(void *data, int cols, char **vals, char **names);
int Exec(const char *query, ExecCB callback, ExecResult &result);
int Exec(const char *query, const ExecCB &callback);
// The opening of the database may be delayed until demanded.
// Returns a non-null pointer to an open database, or throws an exception
@@ -165,7 +161,7 @@ private:
bool CloseDB();
bool DeleteDB();
bool Query(const char *sql, ExecResult &result);
bool Query(const char *sql, const ExecCB &callback);
bool GetValue(const char *sql, wxString &value);
bool GetBlob(const char *sql, wxMemoryBuffer &buffer);