database.h 953 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * database.h
  3. *
  4. * Created on: Dec 4, 2015
  5. * Author: Philipp Hinz
  6. */
  7. #ifndef DATABASE_H_
  8. #define DATABASE_H_
  9. #include <string>
  10. #include <stdexcept>
  11. #include <cstdio>
  12. #include <stdlib.h>
  13. #include <inttypes.h>
  14. #include <cstdarg>
  15. #include "sqlite/sqlite3.h"
  16. using namespace std;
  17. // Config Keys
  18. typedef enum {
  19. CFGbrewcounter = 1,
  20. CFGHeatingTime = 2,
  21. CFGdisplaylang = 3,
  22. CFGDescTimestamp = 4,
  23. CFGDescBrewCount = 5,
  24. CFGSweepCounter = 6
  25. } config_key_t;
  26. int sqlOpen();
  27. void sqlClose();
  28. int sqlSetup();
  29. int sqlExecute(string query);
  30. char *inttochar(uint8_t *guid);
  31. uint8_t *chartoint(const unsigned char *guid);
  32. uint8_t *int64to8bit(sqlite_int64 guid);
  33. sqlite_int64 int8to64bit(uint8_t *guid);
  34. void sqltest();
  35. std::string string_sprintf(const char* format, ...);
  36. uint64_t sqlGetConf(config_key_t id);
  37. int sqlSetConf(config_key_t id, uint64_t value);
  38. int sqlLogFlow(uint64_t sweep, uint64_t flow, uint64_t deltaT);
  39. #endif /* DATABASE_H_ */