! @brief check if the next byte(s) are inside a given range Adds the current byte and, for each passed range, reads a new byte and checks if it is inside the range. If a violation was detected, set up an error message and return false. Otherwise, return true. @param[in] ranges list of integers; interpreted as list of pairs of inclusive lower and upper bound, respectively @pre The
| 7516 | @return true if and only if no range violation was detected |
| 7517 | */ |
| 7518 | bool next_byte_in_range(std::initializer_list<char_int_type> ranges) |
| 7519 | { |
| 7520 | JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6); |
| 7521 | add(current); |
| 7522 | |
| 7523 | for (auto range = ranges.begin(); range != ranges.end(); ++range) |
| 7524 | { |
| 7525 | get(); |
| 7526 | if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) |
| 7527 | { |
| 7528 | add(current); |
| 7529 | } |
| 7530 | else |
| 7531 | { |
| 7532 | error_message = "invalid string: ill-formed UTF-8 byte"; |
| 7533 | return false; |
| 7534 | } |
| 7535 | } |
| 7536 | |
| 7537 | return true; |
| 7538 | } |
| 7539 | |
| 7540 | /*! |
| 7541 | @brief scan a string literal |