ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/utils/StreamTokenizer.hpp
Revision: 1490
Committed: Fri Sep 24 04:16:43 2004 UTC (19 years, 9 months ago) by gezelter
File size: 825 byte(s)
Log Message:
Import of OOPSE v. 2.0

File Contents

# User Rev Content
1 gezelter 1490 //: 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     #endif STREAMTOKENIZER_H