Abstract IResult interface for Result

This is to allow faking the result for testing the CrudModel.
This commit is contained in:
eelke 2022-02-06 12:19:43 +01:00
parent 06504ecc1f
commit c346430b25
6 changed files with 103 additions and 67 deletions

View file

@ -0,0 +1,51 @@
#pragma once
#include "Pgsql_Row.h"
namespace Pgsql {
class IResult;
class ResultConstIterator {
public:
ResultConstIterator(const IResult &r, int rw)
: m_row(r, rw)
{}
ResultConstIterator operator++()
{
ResultConstIterator t(*this);
m_row.next();
return t;
}
ResultConstIterator& operator++(int)
{
m_row.next();
return *this;
}
bool operator==(const ResultConstIterator &rhs)
{
return m_row == rhs.m_row;
}
bool operator!=(const ResultConstIterator &rhs)
{
return !operator==(rhs);
}
const Row& operator*()
{
return m_row;
}
const Row& operator->()
{
return m_row;
}
private:
Row m_row;
};
}