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

Function applyMoveOperation

source/core/StarJsonPatch.cpp:144–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142 }
143
144 Json applyMoveOperation(Json const& base, Json const& op) {
145 String path = op.getString("path");
146 auto toPointer = JsonPath::Pointer(path);
147 auto fromPointer = JsonPath::Pointer(op.getString("from"));
148
149 if (op.contains("search")) {
150 auto searchable = fromPointer.get(base);
151 auto searchValue = op.get("search");
152 if (size_t index = findJsonMatch(searchable, searchValue, fromPointer)) {
153 auto result = toPointer.add(base, searchable.get(index - 1));
154 return fromPointer.add(result, searchable.eraseIndex(index - 1));
155 }
156 else
157 return base;
158 } else {
159 Json value = fromPointer.get(base);
160 return toPointer.add(fromPointer.remove(base), value);
161 }
162 }
163
164 Json applyCopyOperation(Json const& base, Json const& op) {
165 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
eraseIndexMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected