00001 // $Id 00002 #include "word.h" 00003 #include <ctype.h> 00004 00005 Word::Word(const string& w=""): w_(w) { 00006 } 00007 00008 istream& 00009 operator>>(istream& is, Word& w) { 00010 w.w_.resize(0); 00011 char c(EOF); 00012 while (is.get(c) && ! isalpha(c)) 00013 ; 00014 if ( isalpha(c) ) { 00015 do 00016 w.w_ += tolower(c); 00017 while (is.get(c) && isalpha(c)); 00018 // operation succeeded, so we want stream in ok state 00019 // otherwise is >> w would fail if w was followed in is by EOF 00020 is.clear(); 00021 } 00022 return is; 00023 }
textindexer-0.2 | [27 March, 2002] |