ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/StreamTokenizer.hpp
Revision: 1252
Committed: Mon Jun 7 14:26:33 2004 UTC (20 years, 1 month ago) by gezelter
File size: 825 byte(s)
Log Message:
Fixes from gcc -Wall

File Contents

# User Rev Content
1 gezelter 593 //: C07:StreamTokenizer.hpp
2     // From "Thinking in C++, 2nd Edition, Volume 2"
3     // by Bruce Eckel & Chuck Allison, (c) 2001 MindView, Inc.
4     // Available at www.BruceEckel.com.
5     // C++ Replacement for Standard C strtok()
6    
7     #ifndef STREAMTOKENIZER_H
8     #define STREAMTOKENIZER_H
9     #include <string>
10     #include <iostream>
11     #include <iterator>
12    
13     class StreamTokenizer {
14     typedef std::istreambuf_iterator<char> It;
15     It p, end;
16     std::string delimiters;
17     bool isDelimiter(char c) {
18     return
19     delimiters.find(c) != std::string::npos;
20     }
21     public:
22     StreamTokenizer(std::istream& is,
23     std::string delim = " \t\n;()\"<>:{}[]+-=&*#"
24     ".,/\\~!0123456789") : p(is), end(It()),
25     delimiters(delim) {}
26     std::string next(); // Get next token
27     };
28 gezelter 1252 #endif STREAMTOKENIZER_H