yat
0.8.3pre
|
00001 #ifndef _theplu_yat_utility_getline_iterator_ 00002 #define _theplu_yat_utility_getline_iterator_ 00003 00004 // $Id: GetlineIterator.h 1881 2009-03-28 22:15:26Z peter $ 00005 00006 /* 00007 Copyright (C) 2009 Peter Johansson 00008 00009 This file is part of the yat library, http://dev.thep.lu.se/yat 00010 00011 The yat library is free software; you can redistribute it and/or 00012 modify it under the terms of the GNU General Public License as 00013 published by the Free Software Foundation; either version 3 of the 00014 License, or (at your option) any later version. 00015 00016 The yat library is distributed in the hope that it will be useful, 00017 but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 General Public License for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with yat. If not, see <http://www.gnu.org/licenses/>. 00023 */ 00024 00025 #include <boost/iterator/iterator_facade.hpp> 00026 00027 #include <iterator> 00028 #include <string> 00029 00030 namespace theplu { 00031 namespace yat { 00032 namespace utility { 00033 00058 class GetlineIterator 00059 : public boost::iterator_facade< 00060 GetlineIterator, const std::string, std::input_iterator_tag 00061 > 00062 { 00063 public: 00067 GetlineIterator(void); 00068 00075 GetlineIterator(std::istream& is, char delimiter='\n'); 00076 00077 private: 00078 friend class boost::iterator_core_access; 00079 00080 char delimiter_; 00081 std::istream* istream_; 00082 std::string line_; 00083 00084 GetlineIterator::reference dereference(void) const; 00085 00086 bool equal(const GetlineIterator& other) const; 00087 00088 void increment(void); 00089 00090 // Using compiler generated copy 00091 //GetlineIterator(const GetlineIterator&); 00092 //GetlineIterator& operator=(const GetlineIterator&); 00093 }; 00094 00095 }}} // of namespace utility, yat, and theplu 00096 00097 #endif