MCPcopy Create free account
hub / github.com/Kitware/CMake / removeIndex

Method removeIndex

Utilities/cmjsoncpp/src/lib_json/json_value.cpp:1201–1223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1199void Value::removeMember(const String& key) { removeMember(key.c_str()); }
1200
1201bool Value::removeIndex(ArrayIndex index, Value* removed) {
1202 if (type() != arrayValue) {
1203 return false;
1204 }
1205 CZString key(index);
1206 auto it = value_.map_->find(key);
1207 if (it == value_.map_->end()) {
1208 return false;
1209 }
1210 if (removed)
1211 *removed = std::move(it->second);
1212 ArrayIndex oldSize = size();
1213 // shift left all items left, into the place of the "removed"
1214 for (ArrayIndex i = index; i < (oldSize - 1); ++i) {
1215 CZString keey(i);
1216 (*value_.map_)[keey] = (*this)[i + 1];
1217 }
1218 // erase the last one ("leftover")
1219 CZString keyLast(oldSize - 1);
1220 auto itLast = value_.map_->find(keyLast);
1221 value_.map_->erase(itLast);
1222 return true;
1223}
1224
1225bool Value::isMember(char const* begin, char const* end) const {
1226 Value const* value = find(begin, end);

Callers 1

HandleJSONCommandFunction · 0.80

Calls 5

moveFunction · 0.85
eraseMethod · 0.80
typeClass · 0.50
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected