summaryrefslogtreecommitdiff
path: root/lib/input/mysqlRecordSet.h
blob: 849a653dffe48c548bee7a6d07e99713f643b5d0 (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
37
#ifndef MYGRATE_INPUT_MYSQLRECORDSET_H
#define MYGRATE_INPUT_MYSQLRECORDSET_H

#include "mysqlStmt.h"
#include <cstddef>
#include <dbRecordSet.h>
#include <dbTypes.h>
#include <memory>
#include <mysql.h>
#include <vector>

namespace MyGrate::Input {
	class ResultData;

	class MySQLRecordSet : public RecordSet {
	public:
		using ResPtr = std::unique_ptr<MYSQL_RES, decltype(&mysql_free_result)>;
		using StmtResPtr = std::unique_ptr<MYSQL_STMT, decltype(&mysql_stmt_free_result)>;
		using ResultDataPtr = std::unique_ptr<ResultData>;

		explicit MySQLRecordSet(StmtPtr s);

		std::size_t rows() const override;

		std::size_t columns() const override;

		DbValue at(std::size_t row, std::size_t col) const override;

	private:
		StmtPtr stmt;
		StmtResPtr stmtres;
		std::vector<MYSQL_BIND> fields;
		std::vector<ResultDataPtr> extras;
	};
}

#endif