diff options
author | Milo Yip <miloyip@gmail.com> | 2015-05-29 13:39:16 +0300 |
---|---|---|
committer | Milo Yip <miloyip@gmail.com> | 2015-05-29 13:39:16 +0300 |
commit | b8d2f7e66066a923c66b4f4596ba7055a367eb7b (patch) | |
tree | 61329797d41bf3377c219daf1db76c649d5db6f0 /include/rapidjson/pointer.h | |
parent | 3ffac19f2576b149775d4b935923d69577bec795 (diff) | |
parent | a8feeb4c3ef7198ab8883a754f2780657a4b2267 (diff) |
Merge regex into schema
Diffstat (limited to 'include/rapidjson/pointer.h')
-rw-r--r-- | include/rapidjson/pointer.h | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/include/rapidjson/pointer.h b/include/rapidjson/pointer.h index a1411e9f..ab80e97d 100644 --- a/include/rapidjson/pointer.h +++ b/include/rapidjson/pointer.h @@ -689,34 +689,37 @@ public: ValueType* v = &root; const Token* last = tokens_ + (tokenCount_ - 1); - for (const Token *t = tokens_; t != tokens_ + tokenCount_; ++t) { + for (const Token *t = tokens_; t != last; ++t) { switch (v->GetType()) { case kObjectType: { typename ValueType::MemberIterator m = v->FindMember(GenericStringRef<Ch>(t->name, t->length)); if (m == v->MemberEnd()) return false; - if (t == last) { - v->EraseMember(m); - return true; - } v = &m->value; } break; case kArrayType: if (t->index == kPointerInvalidIndex || t->index >= v->Size()) return false; - if (t == last) { - v->Erase(v->Begin() + t->index); - return true; - } v = &((*v)[t->index]); break; default: return false; } } - return false; + + switch (v->GetType()) { + case kObjectType: + return v->EraseMember(GenericStringRef<Ch>(last->name, last->length)); + case kArrayType: + if (last->index == kPointerInvalidIndex || last->index >= v->Size()) + return false; + v->Erase(v->Begin() + last->index); + return true; + default: + return false; + } } private: |