File: sqlite_inter.h

package info (click to toggle)
kaya 0.4.2-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,448 kB
  • ctags: 1,694
  • sloc: cpp: 9,536; haskell: 7,461; sh: 3,013; yacc: 910; makefile: 816; perl: 90
file content (59 lines) | stat: -rw-r--r-- 1,303 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef _SQLITE_INTER_H // -*-C++-*-
#define _SQLITE_INTER_H

// Glue functions for talking to libsqlite3

#include <stdfuns.h>
#include <KayaAPI.h>
#include <sqlite3.h>

using namespace std;

class SQLiteConnection : public gc {
public:
    sqlite3* db;
    int ok;
};

class SQLiteStatement : public gc_cleanup {
public:
    sqlite3_stmt* stmt;
    SQLiteStatement(sqlite3_stmt* s):stmt(s) {}
    ~SQLiteStatement() {
      if (stmt != NULL) {
        sqlite3_finalize(stmt);
      }
    }
};

class SQLiteResult : public gc {
public:
    KArray res_table;
    KArray col_names;
    int rows;
    int cols;
    int res;
    sqlite3_stmt* resptr;
};

extern "C" {
    void* sqlite_connect(wchar_t* info);
    int sqlite_ok(void* con);
    wchar_t* sqlite_getError(void* con);
    void sqlite_close(void* con);
    void* sqlite_exec(void* con, wchar_t* query);
    void* sqlite_incexec(void* con, wchar_t* query);
    KArray sqlite_getrow(void* vmptr, void* con);
    void sqlite_discard(void* sptr);

    void* sqlite_execp(void* stptr, KArray params);
    void* sqlite_prepare(void* vmptr, void* con, wchar_t* query);

    KArray sql_getcolnames(void* res);
    KArray sql_getrestable(void* res);
    int sql_numrows(void* res);
    int sql_numcols(void* res);
    int sql_resrc(void* res);
}

#endif