32 |
|
*/ |
33 |
|
|
34 |
|
#ifndef UTIL_STRINGTOKENIZER_HPP |
35 |
– |
|
35 |
|
#define UTIL_STRINGTOKENIZER_HPP |
36 |
|
|
37 |
|
#include <string> |
38 |
|
|
40 |
– |
//#include "util/NoSuchElementException.hpp" |
41 |
– |
|
39 |
|
namespace oopse { |
40 |
|
|
41 |
|
/** |
49 |
|
class StringTokenizer { |
50 |
|
public: |
51 |
|
|
55 |
– |
static const std::string defaultDelim; |
52 |
|
/** |
53 |
|
* Constructs a string tokenizer for the specified string. The characters in the delim argument |
54 |
|
* are the delimiters for separating tokens. characters are skipped and only serve as |
59 |
|
* Boost's tokenizer class is one of them |
60 |
|
*/ |
61 |
|
StringTokenizer(const std::string & str, |
62 |
< |
const std::string & delim = defaultDelim); |
62 |
> |
const std::string & delim = " \t\n\r"); |
63 |
|
|
64 |
|
/** |
65 |
|
* Constructs a string tokenizer for an iterator range [first, last). The characters in the delim argument |
72 |
|
* Boost's tokenizer class is one of them |
73 |
|
*/ |
74 |
|
StringTokenizer(std::string::const_iterator& first, std::string::const_iterator& last, |
75 |
< |
const std::string & delim = defaultDelim); |
75 |
> |
const std::string & delim = " \t\n\r"); |
76 |
|
|
77 |
|
/** |
78 |
|
* Constructs a string tokenizer for the specified string. The characters in the delim argument |
107 |
|
*/ |
108 |
|
std::string nextToken(); |
109 |
|
|
110 |
+ |
//actually, nextToken Can be template function |
111 |
+ |
//template <typename ReturnType> |
112 |
+ |
//ReturnType nextToken(); |
113 |
+ |
|
114 |
|
/** |
115 |
+ |
* Returns the next token from this string tokenizer as a bool. |
116 |
+ |
* @return the next token from this string tokenizer as a bool. |
117 |
+ |
*/ |
118 |
+ |
bool nextTokenAsBool(); |
119 |
+ |
|
120 |
+ |
/** |
121 |
|
* Returns the next token from this string tokenizer as an integer. |
122 |
|
* @return the next token from this string tokenizer as an integer. |
123 |
|
*/ |
164 |
|
* @param c character to be tested |
165 |
|
* @return true if character is in current delimiter set, flase otherwise. |
166 |
|
*/ |
167 |
< |
bool isDelimiter(char c); |
167 |
> |
bool isDelimiter(const char c); |
168 |
|
|
169 |
|
std::string tokenString_; |
170 |
|
|