CoffeePi Coffee machine control for Raspberry Pi

- Main Page
- Data Structures
- Files

- File List
- Globals

database.h
Go to the documentation of this file.
1 /*
2 * database.h
3 *
4 * Created on: Dec 4, 2015
5 * Author: Philipp Hinz
6 */
7
8 #ifndef DATABASE_H_
9 #define DATABASE_H_
10 #include <string>
11 #include <stdexcept>
12 #include <cstdio>
13 #include <stdlib.h>
14 #include <inttypes.h>
15 #include <cstdarg>
16 #include "sqlite/sqlite3.h"
17
18 using namespace std;
19
20 // Config Keys
21 typedef enum {
22 CFGbrewcounter = 1,
23 CFGHeatingTime = 2,
24 CFGdisplaylang = 3
25 } config_key_t;
26
27 int sqlOpen();
28 void sqlClose();
29 int sqlSetup();
30 int sqlExecute(string query);
31 char *inttochar(uint8_t *guid);
32 uint8_t *chartoint(const unsigned char *guid);
33 uint8_t *int64to8bit(sqlite_int64 guid);
34 sqlite_int64 int8to64bit(uint8_t *guid);
35 void sqltest();
36 std::string string_sprintf(const char* format, ...);
37 uint64_t sqlGetConf(config_key_t id);
38 int sqlSetConf(config_key_t id, uint64_t value);
39
40 #endif /* DATABASE_H_ */
sqlSetConf
int sqlSetConf(config_key_t id, uint64_t value)
Saves a configuration key to the database.
Definition: database.cpp:198
string_sprintf
std::string string_sprintf(const char *format,...)
Allows the format of printf but returns a string Source: http://codereview.stackexchange.com/questions/52522/mimic-sprintf-with-stdstring-output.
Definition: database.cpp:54
config_key_t
config_key_t
Definition: database.h:21
std
chartoint
uint8_t * chartoint(const unsigned char *guid)
Converts the GUID from char to int array.
Definition: database.cpp:227
sqlOpen
int sqlOpen()
Opens and initializes a sqlite3 database connection.
Definition: database.cpp:76
sqlExecute
int sqlExecute(string query)
Executes a SQL statement.
Definition: database.cpp:103
sqlClose
void sqlClose()
Closes the database connection.
Definition: database.cpp:92
inttochar
char * inttochar(uint8_t *guid)
Converts the GUID from int to char array.
Definition: database.cpp:212
sqltest
void sqltest()
Definition: database.cpp:258
sqlSetup
int sqlSetup()
Sets up the database and creates the needed structure.
Definition: database.cpp:150
CFGdisplaylang
Definition: database.h:24
sqlGetConf
uint64_t sqlGetConf(config_key_t id)
Reads a configuration key from the database.
Definition: database.cpp:163
int8to64bit
sqlite_int64 int8to64bit(uint8_t *guid)
Definition: database.cpp:250
CFGbrewcounter
Definition: database.h:22
CFGHeatingTime
Definition: database.h:23
int64to8bit
uint8_t * int64to8bit(sqlite_int64 guid)
Converts the GUID from int64 to int8 array.
Definition: database.cpp:241