| 239 | } |
| 240 | |
| 241 | DefaultTokenizer::CodePointInfo DefaultTokenizer::decodeCurrentCodePoint() { |
| 242 | if (index_ >= path_.size()) { |
| 243 | return {0, 0}; |
| 244 | } |
| 245 | |
| 246 | const unsigned char* p = |
| 247 | reinterpret_cast<const unsigned char*>(path_.data() + index_); |
| 248 | const unsigned char* e = |
| 249 | reinterpret_cast<const unsigned char*>(path_.data() + path_.size()); |
| 250 | const unsigned char* start = p; |
| 251 | |
| 252 | bool skipOnError = false; |
| 253 | try { |
| 254 | char32_t cp = folly::utf8ToCodePoint(p, e, skipOnError); |
| 255 | return {cp, static_cast<size_t>(p - start)}; |
| 256 | } catch (const std::exception&) { |
| 257 | invalidSubfieldPath(); // Throws BoltRuntimeError |
| 258 | return {0, 0}; // Unreachable |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | char32_t DefaultTokenizer::peekCodePoint() { |
| 263 | if (index_ >= path_.size()) { |