From 51ac5d2007f1caf6bc6e65b485ba896357696654 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 6 Jun 2021 00:59:03 +0100 Subject: Add RecordSet RowView This represents a view into a recordset by row number and provides easy access to values in a column by index and the ability to create a new object instance by N columns which are passed to the object's constructor. --- lib/dbRecordSet.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lib/dbRecordSet.cpp (limited to 'lib/dbRecordSet.cpp') diff --git a/lib/dbRecordSet.cpp b/lib/dbRecordSet.cpp new file mode 100644 index 0000000..66ade0e --- /dev/null +++ b/lib/dbRecordSet.cpp @@ -0,0 +1,17 @@ +#include "dbRecordSet.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); + } + + RowView + RecordSet::operator[](std::size_t row) const + { + return {this, row}; + } +} -- cgit v1.2.3