| 3590 | void Value::removeMember(const String &key) { removeMember(key.c_str()); } |
| 3591 | |
| 3592 | bool Value::removeIndex(ArrayIndex index, Value *removed) { |
| 3593 | if (type() != arrayValue) { |
| 3594 | return false; |
| 3595 | } |
| 3596 | CZString key(index); |
| 3597 | auto it = value_.map_->find(key); |
| 3598 | if (it == value_.map_->end()) { |
| 3599 | return false; |
| 3600 | } |
| 3601 | if (removed) |
| 3602 | *removed = it->second; |
| 3603 | ArrayIndex oldSize = size(); |
| 3604 | // shift left all items left, into the place of the "removed" |
| 3605 | for (ArrayIndex i = index; i < (oldSize - 1); ++i) { |
| 3606 | CZString keey(i); |
| 3607 | (*value_.map_)[keey] = (*this)[i + 1]; |
| 3608 | } |
| 3609 | // erase the last one ("leftover") |
| 3610 | CZString keyLast(oldSize - 1); |
| 3611 | auto itLast = value_.map_->find(keyLast); |
| 3612 | value_.map_->erase(itLast); |
| 3613 | return true; |
| 3614 | } |
| 3615 | |
| 3616 | #ifdef JSON_USE_CPPTL |
| 3617 | Value Value::get(const CppTL::ConstString &key, |