10a39cfa9d8d146db4fa9c2f0f0ceb116204aa2f
[apps/native/sample/adventure.git] / inc / db.h
1 /*
2  * Samsung API
3  * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/license/
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an AS IS BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #ifndef __ADVENTURE_DB_H__
19 #define __ADVENTURE_DB_H__
20
21 #include <sqlite3.h>
22 #include "util.h"
23
24 extern sqlite3 *db_open(void);
25 extern void db_close(sqlite3 *db);
26
27 extern sqlite3_stmt *db_prepare(sqlite3 *db, const char *query);
28 extern int db_next(sqlite3 *db, sqlite3_stmt *stmt);
29 extern int db_reset(sqlite3 *db, sqlite3_stmt *stmt);
30
31 extern int db_bind_bool(sqlite3 *db, sqlite3_stmt *stmt, int idx, bool value);
32 extern int db_bind_int(sqlite3 *db, sqlite3_stmt *stmt, int idx, int value);
33 extern int db_bind_double(sqlite3 *db, sqlite3_stmt *stmt, int idx, double value);
34 extern int db_bind_str(sqlite3 *db, sqlite3_stmt *stmt, int idx, const char *str);
35
36 extern bool db_get_bool(sqlite3_stmt *stmt, int index);
37 extern int db_get_int(sqlite3_stmt *stmt, int index);
38 extern int db_get_double(sqlite3_stmt *stmt, int index);
39 extern const char *db_get_str(sqlite3_stmt *stmt, int index);
40
41 extern int db_finalize(sqlite3 *db, sqlite3_stmt *stmt);
42 extern int db_exec(sqlite3 *db, const char *query);
43
44 extern int db_begin_transaction(sqlite3 *db);
45 extern int db_end_transaction(sqlite3 *db);
46
47 extern int db_drop_table(sqlite3 *db);
48 extern int db_create_table(sqlite3 *db);
49
50 extern int db_insert_version(sqlite3 *db, int version);
51 extern int db_remove_version(sqlite3 *db, int version);
52 extern int db_update_version(sqlite3 *db, int version);
53 extern int db_count_version(sqlite3 *db);
54
55 #endif // __ADVENTURE_DB_H__