equal
deleted
inserted
replaced
265 } |
265 } |
266 |
266 |
267 commit(); |
267 commit(); |
268 } |
268 } |
269 |
269 |
|
270 bool hasAvailableForReading() { |
|
271 // TODO: API in AbstractParser for checking available bytes? |
|
272 uint8_t tmp; |
|
273 try { |
|
274 peek(&tmp, 1); |
|
275 return true; |
|
276 } catch (...) { |
|
277 return false; |
|
278 } |
|
279 } |
|
280 |
270 protected: |
281 protected: |
271 |
282 |
272 void update() override { |
283 void update() override { |
273 while (true) readNext(); |
284 while (true) readNext(); |
274 } |
285 } |
275 |
286 |
276 public: |
287 public: |
277 |
288 |
278 void close() override { |
289 void close() override { |
|
290 if (hasAvailableForReading()) throw std::logic_error("Unexpected content at the end of the stream"); // TODO: better exception |
|
291 |
279 checkRemainingItems(); |
292 checkRemainingItems(); |
280 // TODO: check the bytes remaining in the buffer |
293 // TODO: check the bytes remaining in the buffer |
281 if (started) handlers.writeStreamEnd(); |
294 if (started) handlers.writeStreamEnd(); |
282 } |
295 } |
283 |
296 |