mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-poco.git
synced 2025-11-05 13:07:55 +00:00
* remove leftover progen files * remove Data sources and turn headers into forwards * add SQL files #2059 * Data2sql: adjust Travis, AppVeyor & Makefiles (#2069) * Replace Data by SQL * Replace Data by SQL * Replace Data by SQL * Replace Data by SQL * fix header forwarding * Data2sql: Fixes for complete Travis CI success (#2071) * Replace Data by SQL * Replace Data by SQL * Replace Data by SQL * Replace Data by SQL * Replace Data by SQL * Restore DataFormatException * Replace Data by SQL * Replace Data by SQL * Replace Data by SQL * Replace Data by SQL * construct RowFilter from RecordSet reference instead of pointer * pass Container ref instead of ptr to Column * elimitate g++ warnings * SQL: remove raw pointers from interfaces #2094; add constness and move ops where appropriate * tidy up Postgres * ODBC fixes
157 lines
3.8 KiB
C++
157 lines
3.8 KiB
C++
//
|
|
// RowIterator.h
|
|
//
|
|
// Library: Data
|
|
// Package: DataCore
|
|
// Module: RowIterator
|
|
//
|
|
// Definition of the RowIterator class.
|
|
//
|
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
|
// and Contributors.
|
|
//
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
//
|
|
|
|
|
|
#ifndef SQL_RowIterator_INCLUDED
|
|
#define SQL_RowIterator_INCLUDED
|
|
|
|
|
|
#include "Poco/SQL/SQL.h"
|
|
#include "Poco/SQL/Row.h"
|
|
#include "Poco/Dynamic/Var.h"
|
|
#include <iterator>
|
|
#include <algorithm>
|
|
|
|
|
|
namespace Poco {
|
|
namespace SQL {
|
|
|
|
|
|
class RecordSet;
|
|
|
|
|
|
class Poco_SQL_API RowIterator
|
|
/// RowIterator class.
|
|
{
|
|
public:
|
|
typedef std::bidirectional_iterator_tag iterator_category;
|
|
typedef Row value_type;
|
|
typedef std::ptrdiff_t difference_type;
|
|
typedef Row* pointer;
|
|
typedef Row& reference;
|
|
|
|
static const std::size_t POSITION_END;
|
|
/// End position indicator.
|
|
|
|
//@ deprecated
|
|
RowIterator(RecordSet* pRecordSet, bool positionEnd);
|
|
/// Creates the RowIterator and positions it at the end of
|
|
/// the recordset if positionEnd is true. Otherwise, it is
|
|
/// positioned at the beginning.
|
|
|
|
RowIterator(RecordSet& recordSet, bool positionEnd = false);
|
|
/// Creates the RowIterator and positions it at the end of
|
|
/// the recordset if positionEnd is true. Otherwise, it is
|
|
/// positioned at the beginning.
|
|
|
|
RowIterator(const RowIterator& other);
|
|
/// Creates a copy of other RowIterator.
|
|
|
|
~RowIterator();
|
|
/// Destroys the RowIterator.
|
|
|
|
RowIterator& operator = (const RowIterator& other);
|
|
/// Assigns the other RowIterator.
|
|
|
|
bool operator == (const RowIterator& other) const;
|
|
/// Equality operator.
|
|
|
|
bool operator != (const RowIterator& other) const;
|
|
/// Inequality operator.
|
|
|
|
Row& operator * () const;
|
|
/// Returns reference to the current row.
|
|
|
|
Row* operator -> () const;
|
|
/// Returns pointer to the current row.
|
|
|
|
const RowIterator& operator ++ () const;
|
|
/// Advances by one position and returns current position.
|
|
|
|
RowIterator operator ++ (int) const;
|
|
/// Advances by one position and returns copy of the iterator with
|
|
/// previous current position.
|
|
|
|
const RowIterator& operator -- () const;
|
|
/// Goes back by one position and returns copy of the iterator with
|
|
/// previous current position.
|
|
|
|
RowIterator operator -- (int) const;
|
|
/// Goes back by one position and returns previous current position.
|
|
|
|
RowIterator operator + (std::size_t diff) const;
|
|
/// Returns a copy the RowIterator advanced by diff positions.
|
|
|
|
RowIterator operator - (std::size_t diff) const;
|
|
/// Returns a copy the RowIterator backed by diff positions.
|
|
/// Throws RangeException if diff is larger than current position.
|
|
|
|
void swap(RowIterator& other);
|
|
/// Swaps the RowIterator with another one.
|
|
|
|
private:
|
|
RowIterator();
|
|
|
|
void increment() const;
|
|
/// Increments the iterator position by one.
|
|
/// Throws RangeException if position is out of range.
|
|
|
|
void decrement() const;
|
|
/// Decrements the iterator position by one.
|
|
/// Throws RangeException if position is out of range.
|
|
|
|
void setPosition(std::size_t pos) const;
|
|
/// Sets the iterator position.
|
|
/// Throws RangeException if position is out of range.
|
|
|
|
RecordSet* _pRecordSet;
|
|
mutable std::size_t _position;
|
|
};
|
|
|
|
|
|
///
|
|
/// inlines
|
|
///
|
|
|
|
|
|
inline bool RowIterator::operator == (const RowIterator& other) const
|
|
{
|
|
return _pRecordSet == other._pRecordSet && _position == other._position;
|
|
}
|
|
|
|
|
|
inline bool RowIterator::operator != (const RowIterator& other) const
|
|
{
|
|
return _pRecordSet != other._pRecordSet || _position != other._position;
|
|
}
|
|
|
|
|
|
} } // namespace Poco::SQL
|
|
|
|
|
|
namespace std
|
|
{
|
|
template<>
|
|
inline void swap<Poco::SQL::RowIterator>(Poco::SQL::RowIterator& s1,
|
|
Poco::SQL::RowIterator& s2)
|
|
/// Full template specialization of std:::swap for RowIterator
|
|
{
|
|
s1.swap(s2);
|
|
}
|
|
}
|
|
|
|
|
|
#endif // Data_RowIterator_INCLUDED
|