summaryrefslogtreecommitdiffstats
path: root/Source/cmJSONHelpers.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmJSONHelpers.h')
-rw-r--r--Source/cmJSONHelpers.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/Source/cmJSONHelpers.h b/Source/cmJSONHelpers.h
index b35825d..ef94c14 100644
--- a/Source/cmJSONHelpers.h
+++ b/Source/cmJSONHelpers.h
@@ -390,4 +390,19 @@ struct cmJSONHelperBuilder
return func(out, value, state);
};
}
+
+ template <typename T, typename F, typename P>
+ static cmJSONHelper<T> Checked(const JsonErrors::ErrorGenerator& error,
+ F func, P predicate)
+ {
+ return [error, func, predicate](T& out, const Json::Value* value,
+ cmJSONState* state) -> bool {
+ bool result = func(out, value, state);
+ if (result && !predicate(out)) {
+ error(value, state);
+ result = false;
+ }
+ return result;
+ };
+ }
};