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

Function ConditionHelper

Source/cmCMakePresetsGraphReadJSON.cxx:134–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132 SubConditionHelper);
133
134bool ConditionHelper(std::unique_ptr<cmCMakePresetsGraph::Condition>& out,
135 Json::Value const* value, cmJSONState* state)
136{
137 if (!value) {
138 out.reset();
139 return true;
140 }
141
142 if (value->isBool()) {
143 auto c = cm::make_unique<cmCMakePresetsGraphInternal::ConstCondition>();
144 c->Value = value->asBool();
145 out = std::move(c);
146 return true;
147 }
148
149 if (value->isNull()) {
150 out = cm::make_unique<cmCMakePresetsGraphInternal::NullCondition>();
151 return true;
152 }
153
154 if (value->isObject()) {
155 if (!value->isMember("type")) {
156 cmCMakePresetsErrors::INVALID_CONDITION(value, state);
157 return false;
158 }
159
160 if (!(*value)["type"].isString()) {
161 cmCMakePresetsErrors::INVALID_CONDITION(value, state);
162 return false;
163 }
164 auto type = (*value)["type"].asString();
165
166 if (type == "const") {
167 auto c = cm::make_unique<cmCMakePresetsGraphInternal::ConstCondition>();
168 CHECK_OK(ConstConditionHelper(*c, value, state));
169 out = std::move(c);
170 return true;
171 }
172
173 if (type == "equals" || type == "notEquals") {
174 auto c = cm::make_unique<cmCMakePresetsGraphInternal::EqualsCondition>();
175 CHECK_OK(EqualsConditionHelper(*c, value, state));
176 out = std::move(c);
177 if (type == "notEquals") {
178 out = InvertCondition(std::move(out));
179 }
180 return true;
181 }
182
183 if (type == "inList" || type == "notInList") {
184 auto c = cm::make_unique<cmCMakePresetsGraphInternal::InListCondition>();
185 CHECK_OK(InListConditionHelper(*c, value, state));
186 out = std::move(c);
187 if (type == "notInList") {
188 out = InvertCondition(std::move(out));
189 }
190 return true;
191 }

Callers 2

SubConditionHelperFunction · 0.85
PresetConditionHelperFunction · 0.85

Calls 11

moveFunction · 0.85
INVALID_CONDITIONFunction · 0.85
InvertConditionFunction · 0.85
isBoolMethod · 0.80
asBoolMethod · 0.80
isNullMethod · 0.80
isObjectMethod · 0.80
isMemberMethod · 0.80
isStringMethod · 0.80
asStringMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…