ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-1.0/libmdtools/StreamTokenizer.hpp
Revision: 1334
Committed: Fri Jul 16 18:58:03 2004 UTC (19 years, 11 months ago) by gezelter
File size: 825 byte(s)
Log Message:
Initial import of OOPSE-1.0 source tree

File Contents

# Content
1 //: 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