| 110 | } |
| 111 | |
| 112 | void PeekableReadBuffer::rollbackToCheckpoint(bool drop) |
| 113 | { |
| 114 | checkStateCorrect(); |
| 115 | |
| 116 | assert(checkpoint); |
| 117 | |
| 118 | if (checkpointInOwnMemory() == currentlyReadFromOwnMemory()) |
| 119 | { |
| 120 | /// Both checkpoint and position are in the same buffer. |
| 121 | pos = *checkpoint; |
| 122 | } |
| 123 | else |
| 124 | { |
| 125 | /// Checkpoint is in own memory and position is not. |
| 126 | assert(checkpointInOwnMemory()); |
| 127 | |
| 128 | /// Switch to reading from own memory. |
| 129 | BufferBase::set(memory.data(), peeked_size, *checkpoint - memory.data()); |
| 130 | } |
| 131 | |
| 132 | if (drop) |
| 133 | dropCheckpoint(); |
| 134 | |
| 135 | checkStateCorrect(); |
| 136 | } |
| 137 | |
| 138 | bool PeekableReadBuffer::nextImpl() |
| 139 | { |