Bitstream Interpretation Library (BIL)
0.1
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
util
StreamTokenizer.hpp
Go to the documentation of this file.
1
6
#pragma once
7
#ifndef BIL_STREAMTOKENIZER_HPP
8
#define BIL_STREAMTOKENIZER_HPP
9
10
#include <cstring>
11
#include <istream>
12
13
14
namespace
bil {
15
23
class
StreamTokenizer
{
24
public
:
25
26
/**********************************************************************/
27
/* CONSTRUCTION / DESTRUCTION */
28
/**********************************************************************/
29
34
explicit
StreamTokenizer
(std::istream&
inputStream
);
35
39
StreamTokenizer::~StreamTokenizer
();
40
41
42
/**********************************************************************/
43
/* INPUT STREAM */
44
/**********************************************************************/
45
51
void
inputStream
(std::istream& inputStream);
52
53
54
/**********************************************************************/
55
/* TOKENIZER STATE */
56
/**********************************************************************/
57
64
void
reset
();
65
66
67
/**********************************************************************/
68
/* SYNTAX SETUP */
69
/**********************************************************************/
70
77
void
separatorChar
(
char
c);
78
86
void
separatorChars
(
char
firstChar,
char
lastChar);
87
94
void
wordChar
(
char
c);
95
103
void
wordChars
(
char
firstChar,
char
lastChar);
104
110
void
whitespaceChar
(
char
c);
111
118
void
commentChar
(
char
c);
119
124
void
resetSyntax
();
125
126
127
/**********************************************************************/
128
/* TOKEN RETRIEVAL */
129
/**********************************************************************/
130
132
typedef
unsigned
token_t
;
133
135
const
static
token_t
TT_NONE
= 0;
136
138
const
static
token_t
TT_EOF
= 1;
139
141
const
static
token_t
TT_SEPARATOR
= 2;
142
144
const
static
token_t
TT_WORD
= 3;
145
153
token_t
nextToken
();
154
155
156
/**********************************************************************/
157
/* CURRENT TOKEN */
158
/**********************************************************************/
159
164
token_t
tokenType
()
const
;
165
166
171
char
separatorToken
()
const
;
172
173
178
const
char
*
wordToken
()
const
;
179
184
size_t
wordTokenSize
()
const
;
185
186
192
bool
uintToken
(
unsigned
& val)
const
;
193
194
195
private
:
196
197
StreamTokenizer
(
const
StreamTokenizer
&);
198
StreamTokenizer
& operator=(
const
StreamTokenizer
&);
199
200
size_t
checkBuffer();
201
202
std::istream* m_inputStream;
203
char
* m_buffer;
204
size_t
m_bufferSize;
205
size_t
m_readIndex;
206
207
unsigned
char
m_syntaxTable[0xff];
208
209
token_t
m_tokenType;
210
char
m_separatorToken;
211
char
* m_wordBuffer;
212
size_t
m_wordBufferSize;
213
214
};
215
216
}
217
218
#endif
Generated on Wed Aug 8 2012 21:57:41 for Bitstream Interpretation Library (BIL) by
1.8.1.1