2
This file is part of kdev-pg
3
Copyright 2005, 2006 Roberto Raggi <roberto@kdevelop.org>
5
Permission to use, copy, modify, distribute, and sell this software and its
6
documentation for any purpose is hereby granted without fee, provided that
7
the above copyright notice appear in all copies and that both that
8
copyright notice and this permission notice appear in supporting
11
The above copyright notice and this permission notice shall be included in
12
all copies or substantial portions of the Software.
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
KDEVELOP TEAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
//krazy:exclude-all=inline
23
#ifndef KDEV_PG_TOKEN_STREAM_H
24
#define KDEV_PG_TOKEN_STREAM_H
26
#include <QtCore/QtGlobal>
28
#include "kdev-pg-location-table.h"
59
delete mLocationTable;
68
inline qint64 size() const
73
inline qint64 index() const
78
inline qint64 tokenIndex() const
85
inline void rewind(qint64 index)
90
inline T const &token(qint64 index) const
92
return mTokenBuffer[index];
95
inline T &token(qint64 index)
97
return mTokenBuffer[index];
100
inline int nextToken()
102
return mTokenBuffer[mIndex++].kind;
107
if (mTokenCount == mTokenBufferSize)
109
if (mTokenBufferSize == 0)
110
mTokenBufferSize = 1024;
112
mTokenBufferSize <<= 2;
114
mTokenBuffer = reinterpret_cast<T*>
115
(::realloc(mTokenBuffer, mTokenBufferSize * sizeof(T)));
118
return mTokenBuffer[mTokenCount++];
121
inline LocationTable *locationTable()
124
mLocationTable = new LocationTable();
126
return mLocationTable;
129
inline void startPosition(qint64 index, qint64 *line, qint64 *column)
133
*line = 0; *column = 0;
136
mLocationTable->positionAt(token(index).begin, line, column);
139
inline void endPosition(qint64 index, qint64 *line, qint64 *column)
143
*line = 0; *column = 0;
146
mLocationTable->positionAt(token(index).end, line, column);
151
qint64 mTokenBufferSize;
154
LocationTable *mLocationTable;
157
TokenStreamBase(TokenStreamBase const &other);
158
void operator = (TokenStreamBase const &other);
162
class TokenStream : public TokenStreamBase<Token>
169
#endif // KDEV_PG_TOKEN_STREAM_H