#ifndef WhileUntilReceptor_First #define WhileUntilReceptor_First #include "Receptor.h" #include template class CharSetReceptor : public Receptor { public: CharSetReceptor(string charSet, int maxCount = 0) : Receptor(charSet, maxCount) {} protected: virtual istream& ReceiveFrom(istream& is) { static Comparator compare; if (!is) { return is; } myValue = ""; char nextChar; while (1) { if (is.peek() == EOF) { if (myValue.length()==0) { is.get(nextChar); } break; } if (!is.get(nextChar)) { break; } if (compare(myCharSet.find(nextChar),string::npos)) { is.putback(nextChar); break; } else { myValue += nextChar; } if (myMaxCount > 0 && myValue.length() >= myMaxCount) { break; } } return is; } }; typedef CharSetReceptor< equal_to > WhileReceptor; typedef CharSetReceptor< not_equal_to > UntilReceptor; #endif /* WhileUntilReceptor_First */