CoffeePi
Coffee machine control for Raspberry Pi
Enumerations | Functions
database.h File Reference
#include <string>
#include <stdexcept>
#include <cstdio>
#include <stdlib.h>
#include <inttypes.h>
#include <cstdarg>
#include "sqlite/sqlite3.h"

Go to the source code of this file.

Enumerations

enum  config_key_t { CFGbrewcounter = 1, CFGHeatingTime = 2, CFGdisplaylang = 3 }
 

Functions

int sqlOpen ()
 Opens and initializes a sqlite3 database connection. More...
 
void sqlClose ()
 Closes the database connection. More...
 
int sqlSetup ()
 Sets up the database and creates the needed structure. More...
 
int sqlExecute (string query)
 Executes a SQL statement. More...
 
char * inttochar (uint8_t *guid)
 Converts the GUID from int to char array. More...
 
uint8_t * chartoint (const unsigned char *guid)
 Converts the GUID from char to int array. More...
 
uint8_t * int64to8bit (sqlite_int64 guid)
 Converts the GUID from int64 to int8 array. More...
 
sqlite_int64 int8to64bit (uint8_t *guid)
 
void sqltest ()
 
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. More...
 
uint64_t sqlGetConf (config_key_t id)
 Reads a configuration key from the database. More...
 
int sqlSetConf (config_key_t id, uint64_t value)
 Saves a configuration key to the database. More...
 

Enumeration Type Documentation

Enumerator
CFGbrewcounter 
CFGHeatingTime 
CFGdisplaylang 

Function Documentation

uint8_t* chartoint ( const unsigned char *  guid)

Converts the GUID from char to int array.

Parameters
*guidPointer to the char GUID
Returns
pointer to the converted int array
uint8_t* int64to8bit ( sqlite_int64  guid)

Converts the GUID from int64 to int8 array.

Parameters
guid64bit GUID
Returns
pointer to the converted int array
sqlite_int64 int8to64bit ( uint8_t *  guid)
char* inttochar ( uint8_t *  guid)

Converts the GUID from int to char array.

Parameters
*guidPointer to the uint8_t GUID
Returns
pointer to the converted string
void sqlClose ( )

Closes the database connection.

int sqlExecute ( string  query)

Executes a SQL statement.

Parameters
*querySQL query string
Returns
0 on success
uint64_t sqlGetConf ( config_key_t  id)

Reads a configuration key from the database.

Parameters
idConfig ID key
Returns
value as integer (up to 64bit), 0 for not found
int sqlOpen ( )

Opens and initializes a sqlite3 database connection.

Returns
0 on success
int sqlSetConf ( config_key_t  id,
uint64_t  value 
)

Saves a configuration key to the database.

Parameters
idConfig ID key
valueInteger value
Returns
0 on success
int sqlSetup ( )

Sets up the database and creates the needed structure.

Returns
0 on success
void sqltest ( )
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.

Returns
printf formatted string
Parameters
formatinput string as char array