summaryrefslogtreecommitdiff
path: root/libopie2/opiedb/osqlitedriver.h
blob: d5ab2246a6de0730d7891c033f916cf46b4b2834 (plain)
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
#ifndef OSQL_LITE_DRIVER_H
#define OSQL_LITE_DRIVER_H

#include <sqlite.h>
#if defined (__GNUC__) && (__GNUC__ < 3)
#include <sys/types.h>
#endif
#include <regex.h>

#include "osqldriver.h"
#include "osqlerror.h"
#include "osqlresult.h"

namespace Opie {
namespace DB {
namespace Internal {

struct sqregex {
	char *regex_raw;
	regex_t regex_c;
};

class OSQLiteDriver : public OSQLDriver {
    Q_OBJECT
public:
    OSQLiteDriver( QLibrary *lib = 0l );
    ~OSQLiteDriver();
    QString id()const;
    void setUserName( const QString& );
    void setPassword( const QString& );
    void setUrl( const QString& url );
    void setOptions( const QStringList& );
    bool open();
    bool close();
    OSQLError lastError();
    OSQLResult query( OSQLQuery* );
    OSQLTable::ValueList tables()const;

private:
    OSQLError m_lastE;
    OSQLResult m_result;
    OSQLResultItem m_items;
    int handleCallBack( int, char**, char** );
    static int call_back( void*, int, char**, char** );
    QString m_url;
    sqlite *m_sqlite;
    sqregex sqreg;
};
}
}
}

#endif