Debian Codegraph @

src/stats/db.h

raw symbols SCIP
1 /**
2 * \file stats/db.h
3 * Purpose: interface to SQLite3 database manipulation
4 *
5 * Copyright (c) 2011 Robert Au
6 *
7 * This work is free software; you can redistribute it and/or modify it
8 * under the terms of either:
9 *
10 * a) the GNU General Public License as published by the Free Software
11 * Foundation, version 2, or
12 *
13 * b) the "Angband licence":
14 * This software may be copied and distributed for educational,
15 * research,
16 * and not for profit purposes provided that this copyright and
17 * statement
18 * are included in all such copies. Other copyrights may also apply.
19 */
20
21 #ifndef STATS_DB_H
22 #define STATS_DB_H
23
24 #include <sqlite3.h>
25
26 /**
27 * Utility macro for executing and resetting a statement; assumes existence
28 * of an integer err variable
29 */
30 #define STATS_DB_STEP_RESET(s) \
31 err = sqlite3_step(s);\
32 if (err && err != SQLITE_DONE) return err;\
33 err = sqlite3_reset(s);\
34 if (err) return err;
35
36 /**
37 * Utility macro for finalizing a statement; assumes existence
38 * of an integer err variable
39 */
40 #define STATS_DB_FINALIZE(s) \
41 err = sqlite3_finalize(s);\
42 if (err) return err;
43
44 extern bool stats_db_open(void);
45 extern bool stats_db_close(void);
46 extern int stats_db_exec(const char *sql_str);
47 extern int stats_db_stmt_prep(sqlite3_stmt **sql_stmt, const char *sql_str);
48 extern int stats_db_bind_ints(sqlite3_stmt *sql_stmt, int num_cols,
49 int offset, ...);
50 extern int stats_db_bind_rv(sqlite3_stmt *sql_stmt, int col,
51 random_value rv);
52
53 #endif /* STATS_DB_H */