| 3699 | } |
| 3700 | |
| 3701 | bool Value::removeIndex(ArrayIndex index, Value* removed) { |
| 3702 | if (type_ != arrayValue) { |
| 3703 | return false; |
| 3704 | } |
| 3705 | CZString key(index); |
| 3706 | ObjectValues::iterator it = value_.map_->find(key); |
| 3707 | if (it == value_.map_->end()) { |
| 3708 | return false; |
| 3709 | } |
| 3710 | *removed = it->second; |
| 3711 | ArrayIndex oldSize = size(); |
| 3712 | // shift left all items left, into the place of the "removed" |
| 3713 | for (ArrayIndex i = index; i < (oldSize - 1); ++i) { |
| 3714 | CZString keey(i); |
| 3715 | (*value_.map_)[keey] = (*this)[i + 1]; |
| 3716 | } |
| 3717 | // erase the last one ("leftover") |
| 3718 | CZString keyLast(oldSize - 1); |
| 3719 | ObjectValues::iterator itLast = value_.map_->find(keyLast); |
| 3720 | value_.map_->erase(itLast); |
| 3721 | return true; |
| 3722 | } |
| 3723 | |
| 3724 | #ifdef JSON_USE_CPPTL |
| 3725 | Value Value::get(const CppTL::ConstString& key, |