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

Function VectorFilter

Source/cmJSONHelpers.h:306–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304
305 template <typename T, typename F, typename Filter>
306 static cmJSONHelper<std::vector<T>> VectorFilter(
307 JsonErrors::ErrorGenerator const& error, F func, Filter filter)
308 {
309 return [error, func, filter](std::vector<T>& out, Json::Value const* value,
310 cmJSONState* state) -> bool {
311 bool success = true;
312 if (!value) {
313 out.clear();
314 return true;
315 }
316 if (!value->isArray()) {
317 error(value, state);
318 return false;
319 }
320 out.clear();
321 int index = 0;
322 for (auto const& item : *value) {
323 state->push_stack(cmStrCat("$vector_item_", index++), &item);
324 T t;
325 if (!func(t, &item, state)) {
326 success = false;
327 }
328 if (!filter(t)) {
329 state->pop_stack();
330 continue;
331 }
332 out.push_back(std::move(t));
333 state->pop_stack();
334 }
335 return success;
336 };
337 }
338
339 template <typename T, typename F>
340 static cmJSONHelper<std::vector<T>> Vector(JsonErrors::ErrorGenerator error,

Callers

nothing calls this directly

Calls 10

errorFunction · 0.85
filterFunction · 0.85
moveFunction · 0.85
isArrayMethod · 0.80
push_stackMethod · 0.80
pop_stackMethod · 0.80
push_backMethod · 0.80
cmStrCatFunction · 0.70
funcFunction · 0.50
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…