-
Notifications
You must be signed in to change notification settings - Fork 0
/
Database.h
38 lines (31 loc) · 908 Bytes
/
Database.h
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
#ifndef __DATABASE_H__
#define __DATABASE_H__
#include <sqlite3.h>
#include <string>
#include <map>
#include "Debug.h"
#include <stdio.h>
#include <stdlib.h>
class dbRow
{
public:
std::string &operator[] ( std::string column ) { return m[column]; };
double asDouble( std::string column ) { return atof(m[column].c_str()); };
int asInteger( std::string column ) { return atoi(m[column].c_str()); };
const char *asCString( std::string column ) { return m[column].c_str(); };
private:
std::map< std::string, std::string > m;
};
typedef std::map< int, dbRow > dbResult;
class Database
{
public:
Database( const char *filename = "/usr/local/var/wxhistory.db" );
dbResult query( const char *format, ... )
__attribute__((format(printf,2,3)));
private:
sqlite3 *db;
const char *filename;
Debug dbg;
};
#endif // __DATABASE_H__