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