Changeset View
Changeset View
Standalone View
Standalone View
include/kdev-pg-token-stream.h
Show First 20 Lines • Show All 122 Lines • ▼ Show 20 Line(s) | 72 | public: | |||
---|---|---|---|---|---|
123 | } | 123 | } | ||
124 | 124 | | |||
125 | /** | 125 | /** | ||
126 | * Sets the position in the stream. | 126 | * Sets the position in the stream. | ||
127 | * All tokens will be unaffected. | 127 | * All tokens will be unaffected. | ||
128 | */ | 128 | */ | ||
129 | inline void rewind(qint64 index) | 129 | inline void rewind(qint64 index) | ||
130 | { | 130 | { | ||
131 | Q_ASSERT(0 <= index && index <= size()); | ||||
131 | mIndex = index; | 132 | mIndex = index; | ||
132 | } | 133 | } | ||
133 | 134 | | |||
134 | /** | 135 | /** | ||
135 | * Returns the token at the specified position in the stream. | 136 | * Returns the token at the specified position in the stream. | ||
136 | */ | 137 | */ | ||
137 | inline T const &at(qint64 index) const | 138 | inline T const &at(qint64 index) const | ||
138 | { | 139 | { | ||
140 | Q_ASSERT(0 <= index && index < size()); | ||||
139 | return mTokenBuffer[index]; | 141 | return mTokenBuffer[index]; | ||
140 | } | 142 | } | ||
141 | 143 | | |||
142 | /** | 144 | /** | ||
143 | * Returns the token at the specified position in the stream. | 145 | * Returns the token at the specified position in the stream. | ||
144 | */ | 146 | */ | ||
145 | inline T &at(qint64 index) | 147 | inline T &at(qint64 index) | ||
146 | { | 148 | { | ||
149 | Q_ASSERT(0 <= index && index < size()); | ||||
147 | return mTokenBuffer[index]; | 150 | return mTokenBuffer[index]; | ||
148 | } | 151 | } | ||
149 | 152 | | |||
150 | /** | 153 | /** | ||
151 | * Pushes a new token to the stream. | 154 | * Pushes a new token to the stream. | ||
152 | * @return The new default-initialized token (reference) | 155 | * @return The new default-initialized token (reference) | ||
153 | */ | 156 | */ | ||
154 | inline T &push() | 157 | inline T &push() | ||
Show All 24 Lines | 177 | { | |||
179 | return mTokenBuffer[mIndex++]; | 182 | return mTokenBuffer[mIndex++]; | ||
180 | } | 183 | } | ||
181 | 184 | | |||
182 | /** | 185 | /** | ||
183 | * Current token in the stream. | 186 | * Current token in the stream. | ||
184 | */ | 187 | */ | ||
185 | inline T &curr() | 188 | inline T &curr() | ||
186 | { | 189 | { | ||
190 | Q_ASSERT(mIndex < size()); | ||||
187 | return mTokenBuffer[mIndex]; | 191 | return mTokenBuffer[mIndex]; | ||
188 | } | 192 | } | ||
189 | 193 | | |||
190 | /** | 194 | /** | ||
191 | * Last token in the stream. | 195 | * Last token in the stream. | ||
192 | */ | 196 | */ | ||
193 | inline T &back() | 197 | inline T &back() | ||
194 | { | 198 | { | ||
199 | Q_ASSERT(!mTokenBuffer.empty()); | ||||
195 | return mTokenBuffer.back(); | 200 | return mTokenBuffer.back(); | ||
kfunk: assert non-empty? | |||||
196 | } | 201 | } | ||
197 | 202 | | |||
198 | /** | 203 | /** | ||
199 | * First token in the stream. | 204 | * First token in the stream. | ||
200 | */ | 205 | */ | ||
201 | inline T &front() | 206 | inline T &front() | ||
202 | { | 207 | { | ||
208 | Q_ASSERT(!mTokenBuffer.empty()); | ||||
203 | return mTokenBuffer.front(); | 209 | return mTokenBuffer.front(); | ||
kfunk: dito | |||||
204 | } | 210 | } | ||
205 | 211 | | |||
206 | /** | 212 | /** | ||
207 | * @return The associated location table. | 213 | * @return The associated location table. | ||
208 | */ | 214 | */ | ||
209 | inline LocationTable *locationTable() | 215 | inline LocationTable *locationTable() | ||
210 | { | 216 | { | ||
211 | if (!mLocationTable) | 217 | if (!mLocationTable) | ||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |
assert non-empty?