| 1203 | } |
| 1204 | |
| 1205 | bool Value::removeIndex(ArrayIndex index, Value* removed) { |
| 1206 | if (type_ != arrayValue) { |
| 1207 | return false; |
| 1208 | } |
| 1209 | CZString key(index); |
| 1210 | ObjectValues::iterator it = value_.map_->find(key); |
| 1211 | if (it == value_.map_->end()) { |
| 1212 | return false; |
| 1213 | } |
| 1214 | *removed = it->second; |
| 1215 | ArrayIndex oldSize = size(); |
| 1216 | // shift left all items left, into the place of the "removed" |
| 1217 | for (ArrayIndex i = index; i < (oldSize - 1); ++i){ |
| 1218 | CZString keey(i); |
| 1219 | (*value_.map_)[keey] = (*this)[i + 1]; |
| 1220 | } |
| 1221 | // erase the last one ("leftover") |
| 1222 | CZString keyLast(oldSize - 1); |
| 1223 | ObjectValues::iterator itLast = value_.map_->find(keyLast); |
| 1224 | value_.map_->erase(itLast); |
| 1225 | return true; |
| 1226 | } |
| 1227 | |
| 1228 | #ifdef JSON_USE_CPPTL |
| 1229 | Value Value::get(const CppTL::ConstString& key, |
no test coverage detected