00001 #ifndef WORDSTREAMITERATOR_H 00002 #define WORDSTREAMITERATOR_H 00003 00004 // $Id: wordstreamiterator.h,v 1.1.1.1 2002/03/24 12:37:04 dvermeir Exp $ 00005 #include <string> 00006 #include <iostream> 00007 #include <stdexcept> 00008 #include <iterator> 00009 #include <set> 00010 00011 00018 class wordstream_iterator: input_iterator<string,ptrdiff_t> { 00019 public: 00025 wordstream_iterator(istream& is, const set<string>& ignore); 00026 wordstream_iterator(); 00027 00028 const string& operator*() const { return value_; } 00029 wordstream_iterator& operator++() { get(); return *this; } 00030 wordstream_iterator operator++(int) { 00031 wordstream_iterator tmp(*this); 00032 get(); 00033 return tmp; 00034 } 00035 friend bool 00036 operator==(const wordstream_iterator& i1, const wordstream_iterator& i2) { 00037 return i1.is_ == i2.is_ && i1.ok_ == i2.ok_ 00038 || i1.ok_ == false && i2.ok_ == false; 00039 } 00040 00041 size_t ignored() const { return ignored_; } 00042 size_t read() const { return read_; } 00043 private: 00044 void get(); 00045 00046 const set<string>* ignore_; 00047 string value_; 00048 istream* is_; 00049 bool ok_; 00050 size_t ignored_; 00051 size_t read_; 00052 }; 00053 #endif 00054
textindexer-0.2 | [27 March, 2002] |