22 m_inputStream(&inputStream),
37 StreamTokenizer::~StreamTokenizer()
39 delete[] m_wordBuffer;
65 m_syntaxTable[
static_cast<unsigned char>(c)] =
AT_SEPARATOR;
71 for (
char c = firstChar; c <= lastChar; ++c)
72 m_syntaxTable[static_cast<unsigned char>(c)] =
AT_SEPARATOR;
78 m_syntaxTable[
static_cast<unsigned char>(c)] =
AT_WORD;
84 for (
char c = firstChar; c <= lastChar; ++c)
85 m_syntaxTable[static_cast<unsigned char>(c)] =
AT_WORD;
97 m_syntaxTable[
static_cast<unsigned char>(c)] =
AT_COMMENT;
103 for (
unsigned c = 0; c < 0xff; ++c)
113 if (0 == checkBuffer())
return TT_EOF;
114 char c = m_buffer[m_readIndex];
117 switch (m_syntaxTable[static_cast<unsigned char>(c)])
127 m_wordBufferSize = 0;
130 if (m_wordBufferSize <
TOKEN_MAX_SIZE) m_wordBuffer[m_wordBufferSize++] = c;
132 if (0 == checkBuffer())
return TT_WORD;
133 c = m_buffer[m_readIndex];
135 while (
AT_WORD == (m_syntaxTable[static_cast<unsigned char>(c)]));
141 m_separatorToken = c;
150 if (0 == checkBuffer())
155 c = m_buffer[m_readIndex];
172 return m_separatorToken;
178 m_wordBuffer[m_wordBufferSize] = 0;
185 return m_wordBufferSize;
191 m_wordBuffer[m_wordBufferSize] = 0;
193 val = strtol(m_wordBuffer, &endPtr, 10);
194 return ((0 != endPtr) && (0 == *endPtr));
198 size_t StreamTokenizer::checkBuffer()
201 if (m_bufferSize > m_readIndex)
return m_bufferSize;
205 m_bufferSize = m_inputStream->gcount();