blob: 80919dc8a7c2b64af7b87c04e923000372e7c91b (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#ifndef MYGRATE_DBRECORDSET_H
#define MYGRATE_DBRECORDSET_H
#include <dbTypes.h>
#include <memory>
namespace MyGrate {
class RecordSet;
class RowView {
public:
explicit RowView(const RecordSet * rs, std::size_t rw = 0);
DbValue operator[](std::size_t col) const;
template<typename S, std::size_t N, std::size_t O = 0>
auto
create() const
{
return create<S, O>(std::make_index_sequence<N> {});
}
template<typename S, std::size_t O, std::size_t... I> auto create(std::index_sequence<I...>) const
{
return std::make_unique<S>((*this)[I + O]...);
}
bool operator==(const RowView &) const;
RowView & operator++();
const RowView & operator*() const;
std::size_t currentRow() const;
private:
const RecordSet * recordSet;
std::size_t row;
};
class RecordSet {
public:
virtual ~RecordSet() = default;
virtual std::size_t rows() const = 0;
virtual std::size_t columns() const = 0;
virtual DbValue at(std::size_t, std::size_t) const = 0;
RowView operator[](std::size_t row) const;
DbValue operator*() const;
RowView begin() const;
RowView end() const;
};
using RecordSetPtr = std::unique_ptr<RecordSet>;
class Cursor {
public:
virtual ~Cursor() = default;
virtual bool fetch() = 0;
virtual std::size_t columns() const = 0;
virtual DbValue at(std::size_t) const = 0;
};
using CursorPtr = std::unique_ptr<Cursor>;
}
#endif
|