00001 /* 00002 * Copyright (C) 2005 Tommi Maekitalo 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * As a special exception, you may use this file as part of a free 00010 * software library without restriction. Specifically, if other files 00011 * instantiate templates or use macros or inline functions from this 00012 * file, or you compile this file and link it with other files to 00013 * produce an executable, this file does not by itself cause the 00014 * resulting executable to be covered by the GNU General Public 00015 * License. This exception does not however invalidate any other 00016 * reasons why the executable file might be covered by the GNU Library 00017 * General Public License. 00018 * 00019 * This library is distributed in the hope that it will be useful, 00020 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00022 * Lesser General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU Lesser General Public 00025 * License along with this library; if not, write to the Free Software 00026 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00027 */ 00028 00029 #ifndef TNTDB_BITS_STATEMENT_ITERATOR_H 00030 #define TNTDB_BITS_STATEMENT_ITERATOR_H 00031 00032 #include <tntdb/iface/icursor.h> 00033 #include <tntdb/bits/row.h> 00034 #include <tntdb/bits/statement.h> 00035 #include <iterator> 00036 00037 namespace tntdb 00038 { 00042 class Statement::const_iterator 00043 : public std::iterator<std::forward_iterator_tag, Row> 00044 { 00045 Row current; 00046 cxxtools::SmartPtr<ICursor> cursor; 00047 00048 public: 00049 const_iterator(ICursor* cursor_ = 0); 00050 00055 bool operator== (const const_iterator& c) const 00056 { return cursor == c.cursor; } 00061 bool operator!= (const const_iterator& c) const 00062 { return cursor != c.cursor; } 00063 00068 const_iterator& operator++(); 00069 const_iterator operator++(int); 00070 00074 const Row& operator* () const { return current; } 00078 const Row* operator-> () const { return ¤t; } 00079 00083 const ICursor* getImpl() const { return &*cursor; } 00084 }; 00085 } 00086 00087 #endif // TNTDB_BITS_STATEMENT_ITERATOR_H 00088