summaryrefslogtreecommitdiff
path: root/lib/output/pq/pqConn.h
blob: 856683de122e153ff4a3f0431b43bfd7eb6fd026 (plain)
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
#ifndef MYGRATE_OUTPUT_PQ_PQCONN_H
#define MYGRATE_OUTPUT_PQ_PQCONN_H

#include <cstddef>
#include <dbConn.h>
#include <dbTypes.h>
#include <functional>
#include <initializer_list>
#include <libpq-fe.h>
#include <map>
#include <memory>
#include <string>

namespace MyGrate::Output::Pq {
	class PqConn : public DbConn {
	public:
		explicit PqConn(const char * const str);
		virtual ~PqConn() = default;

		void query(const char * const) override;
		void query(const char * const, const std::initializer_list<DbValue> &) override;

		DbPrepStmtPtr prepare(const char * const, std::size_t nParams) override;

	private:
		static void notice_processor(void *, const char *);
		virtual void notice_processor(const char *) const;

		std::unique_ptr<PGconn, decltype(&PQfinish)> const conn;

		friend class PqPrepStmt;
		std::map<std::string, std::string, std::less<>> stmts;
	};
}

#endif