| 3601 | } |
| 3602 | |
| 3603 | bool Value::removeIndex(ArrayIndex index, Value* removed) { |
| 3604 | if (type_ != arrayValue) { |
| 3605 | return false; |
| 3606 | } |
| 3607 | CZString key(index); |
| 3608 | ObjectValues::iterator it = value_.map_->find(key); |
| 3609 | if (it == value_.map_->end()) { |
| 3610 | return false; |
| 3611 | } |
| 3612 | *removed = it->second; |
| 3613 | ArrayIndex oldSize = size(); |
| 3614 | // shift left all items left, into the place of the "removed" |
| 3615 | for (ArrayIndex i = index; i < (oldSize - 1); ++i){ |
| 3616 | CZString keey(i); |
| 3617 | (*value_.map_)[keey] = (*this)[i + 1]; |
| 3618 | } |
| 3619 | // erase the last one ("leftover") |
| 3620 | CZString keyLast(oldSize - 1); |
| 3621 | ObjectValues::iterator itLast = value_.map_->find(keyLast); |
| 3622 | value_.map_->erase(itLast); |
| 3623 | return true; |
| 3624 | } |
| 3625 | |
| 3626 | #ifdef JSON_USE_CPPTL |
| 3627 | Value Value::get(const CppTL::ConstString& key, |