#ifndef SIMPLETOKER_H #define SIMPLETOKER_H ///////////////////////////////////////////////////////////////// // simpleToker.h - Extracts tokens from a stream // // ver 1.1 // // Language: Visual C++, ver 7.1 // // Platform: Dell Dimension 8300, Windows XP Prof, SP 2 // // Application: CSE687 prototype for project #1, Spring 2005 // // Author: Jim Fawcett, CST 2-187, Syracuse University // // (315) 443-3948, jfawcett@twcny.rr.com // ///////////////////////////////////////////////////////////////// /* * Module Operations * ----------------- * A token is a contiguous sequence of alphanumeric characters * or a single punctuator character. These are extracted, one by * one, from an ifstream or istringstream. * * Public Interface * ---------------- * istringstream in("set of tokens"); * SimpleToker toker(in); // construct with any stream * string tok; * while(toker.good()) // good tests stream state * tok = getTok(); // extracts word or punctuator * char next = toker.peek(); // looks at next char in stream * */ /* Build Process * ------------- * Required Files: SimpleToker.h SimpleToker.cpp * Compile Command: * cl /DTEST_SIMPLETOKER SimpleToker.cpp * * Maintenance History * ------------------- * ver 1.1 : 04 Feb 05 * - fixed bug that missed some '\n' tokens in getTok(). This was * reported by Divyakaran Sachar. Thanks Divyakaran. * ver 1.0 : 23 Jan 05 * - first release * */ // #include class SimpleToker { public: SimpleToker(std::istream &in); ~SimpleToker(); std::string getTok(); bool good(); int peek(); private: std::istream &is_; }; inline SimpleToker::~SimpleToker() { is_.clear(); } inline bool SimpleToker::good() { return is_.good(); } inline int SimpleToker::peek() { return is_.peek(); } #endif