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

Function applyAddOperation

source/core/StarJsonPatch.cpp:110–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108 }
109
110 Json applyAddOperation(Json const& base, Json const& op) {
111 String path = op.getString("path");
112 auto value = op.get("value");
113 auto pointer = JsonPath::Pointer(path);
114
115 if (op.contains("search")) {
116 auto searchable = pointer.get(base);
117 auto searchValue = op.get("search");
118 if (size_t index = findJsonMatch(searchable, searchValue, pointer))
119 return pointer.add(pointer.remove(base), searchable.insert(index - 1, value));
120 else
121 return base;
122 } else {
123 return pointer.add(base, value);
124 }
125 }
126
127 Json applyReplaceOperation(Json const& base, Json const& op) {
128 String path = op.getString("path");

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected