Query a value in a subtree. ! \param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root. \param unresolvedTokenIndex If the pointer cannot resolve a token in the pointer, this parameter can obtain the index of unresolved token. \return Pointer to the value if it can be resolved. Otherwise null. \note There are onl
| 599 | Use unresolvedTokenIndex to retrieve the token index. |
| 600 | */ |
| 601 | ValueType* Get(ValueType& root, size_t* unresolvedTokenIndex = 0) const { |
| 602 | RAPIDJSON_ASSERT(IsValid()); |
| 603 | ValueType* v = &root; |
| 604 | for (const Token *t = tokens_; t != tokens_ + tokenCount_; ++t) { |
| 605 | switch (v->GetType()) { |
| 606 | case kObjectType: |
| 607 | { |
| 608 | typename ValueType::MemberIterator m = v->FindMember(GenericValue<EncodingType>(GenericStringRef<Ch>(t->name, t->length))); |
| 609 | if (m == v->MemberEnd()) |
| 610 | break; |
| 611 | v = &m->value; |
| 612 | } |
| 613 | continue; |
| 614 | case kArrayType: |
| 615 | if (t->index == kPointerInvalidIndex || t->index >= v->Size()) |
| 616 | break; |
| 617 | v = &((*v)[t->index]); |
| 618 | continue; |
| 619 | default: |
| 620 | break; |
| 621 | } |
| 622 | |
| 623 | // Error: unresolved token |
| 624 | if (unresolvedTokenIndex) |
| 625 | *unresolvedTokenIndex = static_cast<size_t>(t - tokens_); |
| 626 | return 0; |
| 627 | } |
| 628 | return v; |
| 629 | } |
| 630 | |
| 631 | //! Query a const value in a const subtree. |
| 632 | /*! |
nothing calls this directly
no test coverage detected