ODBC generic nulls, added Row and RowIterator

This commit is contained in:
Aleksandar Fabijanic
2007-06-22 02:07:48 +00:00
parent 366ac99f7d
commit c9b65928db
11 changed files with 844 additions and 25 deletions

View File

@@ -44,20 +44,31 @@ namespace Data {
RecordSet::RecordSet(const Statement& rStatement):
Statement(rStatement),
_currentRow(0)
_currentRow(0),
_pBegin(0),
_pEnd(0)
{
}
RecordSet::RecordSet(Session& rSession, const std::string& query):
Statement((rSession << query, now)),
_currentRow(0)
_currentRow(0),
_pBegin(0),
_pEnd(0)
{
}
RecordSet::~RecordSet()
{
delete _pBegin;
delete _pEnd;
RowMap::iterator it = _rowMap.begin();
RowMap::iterator end = _rowMap.end();
for (; it != end; ++it)
delete it->second;
}
@@ -107,6 +118,36 @@ DynamicAny RecordSet::value(const std::string& name, std::size_t row) const
}
const RowIterator& RecordSet::begin()
{
if (!_pBegin)
_pBegin = new RowIterator(*this, 0 == extractions().size());
return *_pBegin;
}
const Row& RecordSet::row(std::size_t pos) const
{
if (pos > rowCount() - 1)
throw RangeException("Invalid recordset row requested.");
RowMap::iterator it = _rowMap.find(pos);
Row* pRow = 0;
if (it == _rowMap.end())
{
pRow = new Row;
for (std::size_t i = 0; i < columnCount(); ++i)
pRow->append(metaColumn(static_cast<UInt32>(pos)).name(), value(i, pos));
_rowMap.insert(RowMap::value_type(pos, pRow));
}
poco_check_ptr (pRow);
return *pRow;
}
bool RecordSet::moveFirst()
{
if (rowCount() > 0)