| 3672 | } |
| 3673 | |
| 3674 | bool Value::removeIndex(ArrayIndex index, Value* removed) { |
| 3675 | if (type_ != arrayValue) { |
| 3676 | return false; |
| 3677 | } |
| 3678 | CZString key(index); |
| 3679 | ObjectValues::iterator it = value_.map_->find(key); |
| 3680 | if (it == value_.map_->end()) { |
| 3681 | return false; |
| 3682 | } |
| 3683 | *removed = it->second; |
| 3684 | ArrayIndex oldSize = size(); |
| 3685 | // shift left all items left, into the place of the "removed" |
| 3686 | for (ArrayIndex i = index; i < (oldSize - 1); ++i){ |
| 3687 | CZString keey(i); |
| 3688 | (*value_.map_)[keey] = (*this)[i + 1]; |
| 3689 | } |
| 3690 | // erase the last one ("leftover") |
| 3691 | CZString keyLast(oldSize - 1); |
| 3692 | ObjectValues::iterator itLast = value_.map_->find(keyLast); |
| 3693 | value_.map_->erase(itLast); |
| 3694 | return true; |
| 3695 | } |
| 3696 | |
| 3697 | #ifdef JSON_USE_CPPTL |
| 3698 | Value Value::get(const CppTL::ConstString& key, |