MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / applyRemoveOperation

Function applyRemoveOperation

source/core/StarJsonPatch.cpp:94–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92 }
93
94 Json applyRemoveOperation(Json const& base, Json const& op) {
95 String path = op.getString("path");
96 auto pointer = JsonPath::Pointer(path);
97
98 if (op.contains("search")) {
99 auto searchable = pointer.get(base);
100 auto searchValue = op.get("search");
101 if (size_t index = findJsonMatch(searchable, searchValue, pointer))
102 return pointer.add(pointer.remove(base), searchable.eraseIndex(index - 1));
103 else
104 return base;
105 } else {
106 return pointer.remove(base);
107 }
108 }
109
110 Json applyAddOperation(Json const& base, Json const& op) {
111 String path = op.getString("path");

Callers

nothing calls this directly

Calls 8

PointerClass · 0.85
findJsonMatchFunction · 0.85
getStringMethod · 0.80
containsMethod · 0.45
getMethod · 0.45
addMethod · 0.45
removeMethod · 0.45
eraseIndexMethod · 0.45

Tested by

no test coverage detected