![]() |
![]() |
![]() |
GNOME Video Arcade Reference Manual | ![]() |
---|---|---|---|---|
gboolean gva_db_init (GError **error); GvaProcess* gva_db_build (GError **error); gboolean gva_db_reset (GError **error); gboolean gva_db_execute (const gchar *sql, GError **error); gboolean gva_db_get_table (const gchar *sql, gchar ***result, gint *rows, gint *columns, GError **error); gboolean gva_db_transaction_begin (GError **error); gboolean gva_db_transaction_commit (GError **error); gboolean gva_db_transaction_rollback (GError **error); gboolean gva_db_prepare (const gchar *sql, sqlite3_stmt **stmt, GError **error); gboolean gva_db_get_build (gchar **build, GError **error); const gchar* gva_db_get_filename (void); gboolean gva_db_is_older_than (const gchar *filename); gboolean gva_db_needs_rebuilt (void); void gva_db_set_error (GError **error, gint code, const gchar *message);
gboolean gva_db_init (GError **error);
Opens the games database and creates the tables if they do not already
exist. If an error occurs, it returns FALSE
and sets error
.
This function should be called once when the application starts.
|
return location for a GError, or NULL
|
Returns : |
TRUE on success, FALSE if an error occurred
|
GvaProcess* gva_db_build (GError **error);
Begins the lengthy process of populating the games database and returns a
GvaProcess to track it. The database is populated by parsing detailed
game information generated by MAME. If an error occurs while starting the
parsing process, it returns NULL
and sets error
.
|
return location for a GError, or NULL
|
Returns : |
a new GvaProcess, or NULL
|
gboolean gva_db_reset (GError **error);
Removes all game information from the database and restores the tables
to their initial state. If an error occurs, it returns FALSE
and sets
error
.
|
return location for a GError, or NULL
|
Returns : |
TRUE on success, FALSE if an error occurred
|
gboolean gva_db_execute (const gchar *sql, GError **error);
Executes the given SQL statement without returning any results. This
function is appropriate for one-off operations like "CREATE TABLE" or
"BEGIN TRANSACTION". If an error occurs, it returns FALSE
and sets
error
.
|
an SQL statement |
|
return location for a GError, or NULL
|
Returns : |
TRUE on success, FALSE if an error occurred
|
gboolean gva_db_get_table (const gchar *sql, gchar ***result, gint *rows, gint *columns, GError **error);
Executes the given SQL statement and returns the results as a string
array (see sqlite3_get_table()
for the array layout). This function
is appropriate for SELECT statements that return a small result set.
If an error occurs, it returns FALSE
and sets error
.
Use g_strfreev()
to free result
.
|
an SQL statement |
|
return location for the result, or NULL
|
|
return location for the number of rows in the result, or NULL
|
|
return location for the number of columns in the result, or NULL
|
|
return location for a GError, or NULL
|
Returns : |
TRUE on success, FALSE if an error occurred
|
gboolean gva_db_transaction_begin (GError **error);
Convenience function begins a database transaction. If an error occurs,
it returns FALSE
and sets error
.
|
return location for a GError, or NULL
|
Returns : |
TRUE on success, FALSE if an error occurred
|
gboolean gva_db_transaction_commit (GError **error);
Convenience function commits a database transaction. If an error occurs,
it returns FALSE
and sets error
.
|
return location for a GError, or NULL
|
Returns : |
TRUE on success, FALSE if an error occurred
|
gboolean gva_db_transaction_rollback (GError **error);
Convenience function rolls back a database transaction. If an error
occurs, it returns FALSE
and sets error
.
|
return location for a GError, or NULL
|
Returns : |
TRUE on success, FALSE if an error occurred
|
gboolean gva_db_prepare (const gchar *sql, sqlite3_stmt **stmt, GError **error);
Compiles the given SQL statement and assigns the resulting statement
handle to *stmt
. If an error occurs, it returns FALSE
and sets error
.
|
an SQL statement |
|
return location for a compiled statement handle |
|
return location for a GError, or NULL
|
Returns : |
TRUE on success, FALSE if an error occurred
|
gboolean gva_db_get_build (gchar **build, GError **error);
Returns the build ID of the MAME executable from which the contents of the
database was generated. If an error occurs, it returns FALSE
and sets
error
.
|
return location for the build ID |
|
return location for a GError, or NULL
|
Returns : |
TRUE on success, FALSE if an error occurred
|
const gchar* gva_db_get_filename (void);
Returns the abolute path of the games database.
Returns : |
filename for the games database |
gboolean gva_db_is_older_than (const gchar *filename);
Returns TRUE
if filename
's creation or modification timestamp is
more recent than the games database's modification timestamp. The
games database relies in part on external data files that might
have been updated since the database was last rebuilt. This
function can detect that.
If filename
does not exist or if the function has trouble comparing
timestamps, it returns FALSE
as a safe fallback.
|
a file or directory name |
Returns : |
TRUE if filename is newer than the games database
|
gboolean gva_db_needs_rebuilt (void);
Runs a series of tests to determine whether the game database is out-of-date and needs to be rebuilt. Examples of conditions that would cause a database rebuild are a new version of GNOME Video Arcade, a new version of MAME, database corruption, or if the user explicitly asked us to rebuild.
Returns : |
TRUE if a rebuild is needed, FALSE if the database
seems okay
|
void gva_db_set_error (GError **error, gint code, const gchar *message);
Does nothing if error
is NULL
; if error
is non-NULL
, then *error
must
be NULL
. Converts an SQLite error code and error message to a GError
and assigns it to *error
with a domain of GVA_SQLITE_ERROR
. If message
is NULL
, the function calls sqlite3_errcode()
to obtain the error code and
sqlite3_errmsg()
to obtain the error message.
|
return location for a GError, or NULL
|
|
SQLite error code |
|
SQLite error message, or NULL
|