summaryrefslogtreecommitdiff
path: root/lib/dbRecordSet.cpp
blob: d5e55f0e652cf1f6eaaacb8a2f7adcc26e419dfb (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
#include "dbRecordSet.h"
#include "helpers.h"

namespace MyGrate {
	RowView::RowView(const RecordSet * rs, std::size_t rw) : recordSet {rs}, row {rw} { }

	DbValue
	RowView::operator[](std::size_t col) const
	{
		return recordSet->at(row, col);
	}

	bool
	RowView::operator==(const RowView & that) const
	{
		verify<std::logic_error>(this->recordSet == that.recordSet, "Cannot iterator between RecordSets");
		return this->row == that.row;
	}

	RowView &
	RowView::operator++()
	{
		row++;
		return *this;
	}

	const RowView &
	RowView::operator*() const
	{
		return *this;
	}

	std::size_t
	RowView::currentRow() const
	{
		return row;
	}

	RowView
	RecordSet::operator[](std::size_t row) const
	{
		return {this, row};
	}

	DbValue
	RecordSet::operator*() const
	{
		return at(0, 0);
	}

	RowView
	RecordSet::begin() const
	{
		return {this, 0};
	}

	RowView
	RecordSet::end() const
	{
		return {this, rows()};
	}
}