13338 {
13339 std::vector<std::string> result;
13340
13341
13342 if (reference_string.empty())
13343 {
13344 return result;
13345 }
13346
13347
13348 if (JSON_HEDLEY_UNLIKELY(reference_string[0] != '/'))
13349 {
13350 JSON_THROW(
detail::parse_error::create(107, 1,
"JSON pointer must be empty or begin with '/' - was: '" + reference_string +
"'", BasicJsonType()));
13351 }
13352
13353
13354
13355
13356 for (
13357
13358 std::size_t slash = reference_string.find_first_of('/', 1),
13359
13360 start = 1;
13361
13362 start != 0;
13363
13364
13365 start = (slash == std::string::npos) ? 0 : slash + 1,
13366
13367 slash = reference_string.find_first_of('/', start))
13368 {
13369
13370
13371 auto reference_token = reference_string.substr(start, slash - start);
13372
13373
13374 for (std::size_t pos = reference_token.find_first_of('~');
13375 pos != std::string::npos;
13376 pos = reference_token.find_first_of('~', pos + 1))
13377 {
13378 JSON_ASSERT(reference_token[pos] == '~');
13379
13380
13381 if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 ||
13382 (reference_token[pos + 1] != '0' &&
13383 reference_token[pos + 1] != '1')))
13384 {
13386 }
13387 }
13388
13389
13391 result.push_back(reference_token);
13392 }
13393
13394 return result;
13395 }
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, const BasicJsonType &context)
create a parse error exception
static void unescape(std::string &s)
string unescaping as described in RFC 6901 (Sect. 4)