From 74a0003fea4087de8e9f03b6f828c45d255bcd4a Mon Sep 17 00:00:00 2001 From: MDC Service Date: Mon, 23 May 2022 11:17:34 +0200 Subject: initial check in firmware files --- software/michi_funcs/db_funcs.h | 66 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 software/michi_funcs/db_funcs.h (limited to 'software/michi_funcs/db_funcs.h') diff --git a/software/michi_funcs/db_funcs.h b/software/michi_funcs/db_funcs.h new file mode 100644 index 0000000..cf26c84 --- /dev/null +++ b/software/michi_funcs/db_funcs.h @@ -0,0 +1,66 @@ +/* + * db_funcs.h + * + * Created on: 11.01.2022 + * Author: michi + */ + +#ifndef DB_FUNCS_H_ +#define DB_FUNCS_H_ +//#include "schrank_ant_pcb.h" +#include +#include +#include +#include "SimplePgSQL.h" + +class TpgConnection { // rows + public: + TpgConnection(); + ~TpgConnection(); + int db_connect(const char *pg_server_ip, int pg_port, const char *s_db_name, const char *s_db_user, const char *s_db_passwd, const char *s_db_charset); + int db_disconnect(void); + void db_loop(void); + PGconnection *PGconn; + int last_pgError; + }; + + +//int db_query(const char *sql); + +class TResSetRows { // 1 entry is a collection of string fields + public: + TResSetRows(); //constructor + ~TResSetRows(); //destructor + std::vector Spalte; + int numCols; + int CurrCol; + + }; + +class TResultSet { // rows + public: + TResultSet(PGconnection *PGconnFromCon); + ~TResultSet(); + std::vector Zeile; + int CurrentRow; + int db_query(const char *sql); + int db_exec(const char *sql); + int NumRows; + int NumCols; + + private: + PGconnection *PGconn; + void process_db_row(void); + void process_db_col(void); + + void process_db_summary(void); + void process_db_haveMsg(void); + void process_db_ready(void); + void process_db_cmd_send(void); + void process_db_have_error(void); + void process_db_have_notice(void); + }; + + + +#endif /* DB_FUNCS_H_ */ -- cgit v1.2.3