blob: aec733e5256ce009450770b8ccd1134b8c120fb2 (
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
38
|
#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;
mutable std::size_t currentRow {static_cast<size_t>(-1)};
};
}
#endif
|