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

Function process

source/json_tool/json_tool.cpp:147–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145}
146
147bool process(function<void(FormattedJson const&)> output,
148 Command const& command,
149 Options const& options,
150 FormattedJson const& input) {
151 if (command.is<GetCommand>()) {
152 GetCommand const& getCmd = command.get<GetCommand>();
153 try {
154 FormattedJson value = getCmd.path->get(input);
155 if (getCmd.children) {
156 forEachChild(value, output);
157 } else {
158 output(value);
159 }
160 } catch (JsonPath::TraversalException const& e) {
161 if (!getCmd.opt)
162 throw e;
163 }
164
165 } else if (command.is<SetCommand>()) {
166 SetCommand const& setCmd = command.get<SetCommand>();
167 output(addOrSet(false, setCmd.path, input, options.insertLocation, setCmd.value));
168
169 } else if (command.is<AddCommand>()) {
170 AddCommand const& addCmd = command.get<AddCommand>();
171 output(addOrSet(true, addCmd.path, input, options.insertLocation, addCmd.value));
172
173 } else if (command.is<RemoveCommand>()) {
174 output(command.get<RemoveCommand>().path->remove(input));
175
176 } else {
177 starAssert(command.empty());
178 output(input);
179 }
180 return true;
181}
182
183bool process(
184 function<void(FormattedJson const&)> output, Command const& command, Options const& options, String const& input) {

Callers 1

mainFunction · 0.85

Calls 5

forEachChildFunction · 0.85
parseFunction · 0.50
getMethod · 0.45
removeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected