! @brief unget current character (read it again on next get) We implement unget by setting variable next_unget to true. The input is not changed - we just simulate ungetting by modifying chars_read_total, chars_read_current_line, and token_string. The next call to get() will behave as if the unget character is read again. */
| 7243 | behave as if the unget character is read again. |
| 7244 | */ |
| 7245 | void unget() |
| 7246 | { |
| 7247 | next_unget = true; |
| 7248 | |
| 7249 | --position.chars_read_total; |
| 7250 | |
| 7251 | // in case we "unget" a newline, we have to also decrement the lines_read |
| 7252 | if (position.chars_read_current_line == 0) |
| 7253 | { |
| 7254 | if (position.lines_read > 0) |
| 7255 | { |
| 7256 | --position.lines_read; |
| 7257 | } |
| 7258 | } |
| 7259 | else |
| 7260 | { |
| 7261 | --position.chars_read_current_line; |
| 7262 | } |
| 7263 | |
| 7264 | if (JSON_HEDLEY_LIKELY(current != std::char_traits<char_type>::eof())) |
| 7265 | { |
| 7266 | JSON_ASSERT(!token_string.empty()); |
| 7267 | token_string.pop_back(); |
| 7268 | } |
| 7269 | } |
| 7270 | |
| 7271 | /// add a character to token_buffer |
| 7272 | void add(char_int_type c) |
no test coverage detected