Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miloyip/rapidjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormiloyip <miloyip@gmail.com>2015-05-04 10:02:43 +0300
committermiloyip <miloyip@gmail.com>2015-05-04 10:02:43 +0300
commit436625f83cbeabc8c6c30b7a7a099b7406f1aee8 (patch)
treec6cb3695f71929dd4446ed2dcb6e086a5530dc40 /include/rapidjson/pointer.h
parentb6a54f724480831f397938740d14e5d3d76ad6cb (diff)
Fix ambiguous cases in Pointer::Create()
Diffstat (limited to 'include/rapidjson/pointer.h')
-rw-r--r--include/rapidjson/pointer.h44
1 files changed, 22 insertions, 22 deletions
diff --git a/include/rapidjson/pointer.h b/include/rapidjson/pointer.h
index 3ba9e1c7..89dfa48c 100644
--- a/include/rapidjson/pointer.h
+++ b/include/rapidjson/pointer.h
@@ -305,19 +305,31 @@ public:
ValueType* v = &root;
bool exist = true;
for (Token *t = tokens_; t != tokens_ + tokenCount_; ++t) {
- if (t->index == kPointerInvalidIndex) { // object name
- // Handling of '-' for last element of array
- if (t->name[0] == '-' && t->length == 1) {
- if (!v->IsArray())
- v->SetArray(); // Change to Array
- v->PushBack(Value().Move(), allocator);
- v = &((*v)[v->Size() - 1]);
- exist = false;
- }
- else {
+ if (v->IsArray() && t->name[0] == '-' && t->length == 1) {
+ v->PushBack(Value().Move(), allocator);
+ v = &((*v)[v->Size() - 1]);
+ exist = false;
+ }
+ else {
+ if (t->index == kPointerInvalidIndex) { // must be object name
if (!v->IsObject())
v->SetObject(); // Change to Object
+ }
+ else { // object name or array index
+ if (!v->IsArray() && !v->IsObject())
+ v->SetArray(); // Change to Array
+ }
+ if (v->IsArray()) {
+ if (t->index >= v->Size()) {
+ v->Reserve(t->index + 1, allocator);
+ while (t->index >= v->Size())
+ v->PushBack(Value().Move(), allocator);
+ exist = false;
+ }
+ v = &((*v)[t->index]);
+ }
+ else {
typename ValueType::MemberIterator m = v->FindMember(GenericStringRef<Ch>(t->name, t->length));
if (m == v->MemberEnd()) {
v->AddMember(Value(t->name, t->length, allocator).Move(), Value().Move(), allocator);
@@ -328,18 +340,6 @@ public:
v = &m->value;
}
}
- else { // array index
- if (!v->IsArray())
- v->SetArray(); // Change to Array
-
- if (t->index >= v->Size()) {
- v->Reserve(t->index + 1, allocator);
- while (t->index >= v->Size())
- v->PushBack(Value().Move(), allocator);
- exist = false;
- }
- v = &((*v)[t->index]);
- }
}
if (alreadyExist)