Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Examples  

wordstreamiterator.C

Go to the documentation of this file.
00001 // $Id: wordstreamiterator.C,v 1.1.1.1 2002/03/24 12:37:04 dvermeir Exp $
00002 
00003 #include "wordstreamiterator.h"
00004 #include "word.h"
00005 
00006 wordstream_iterator::wordstream_iterator(istream& is,
00007   const set<string>& ignore): ignore_(&ignore), is_(&is), ok_(true),
00008   ignored_(0), read_(0) {
00009 get();
00010 }
00011 
00012 wordstream_iterator::wordstream_iterator(): ignore_(0), is_(0), ok_(false) {
00013 }
00014 
00015 void
00016 wordstream_iterator::get() {
00017 if (!is_)
00018   throw logic_error("Cannot read from wordstream_iterator with null stream");
00019 Word w;
00020 ok_ = (*is_) ? true : false;
00021 bool ignored(true);
00022 if (ok_) {
00023   do {
00024     if (*is_ >> w) {
00025       value_ = w.str();
00026       if (ignored = ignore_->count(value_) )
00027         ++ignored_;
00028       }
00029     }
00030   while (*is_ &&  ignored);
00031   ok_ = (*is_ && !ignored);
00032   if (ok_)
00033     ++read_;
00034   }
00035 }

textindexer-0.2 [27 March, 2002]