MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / next_byte_in_range

Method next_byte_in_range

Source/Utils/json.hpp:6088–6108  ·  view source on GitHub ↗

! @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

Source from the content-addressed store, hash-verified

6086 @return true if and only if no range violation was detected
6087 */
6088 bool next_byte_in_range(std::initializer_list<char_int_type> ranges)
6089 {
6090 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
6091 add(current);
6092
6093 for (auto range = ranges.begin(); range != ranges.end(); ++range)
6094 {
6095 get();
6096 if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range)))
6097 {
6098 add(current);
6099 }
6100 else
6101 {
6102 error_message = "invalid string: ill-formed UTF-8 byte";
6103 return false;
6104 }
6105 }
6106
6107 return true;
6108 }
6109
6110 /*!
6111 @brief scan a string literal

Callers

nothing calls this directly

Calls 5

addFunction · 0.85
getFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected