| 132 | SubConditionHelper); |
| 133 | |
| 134 | bool 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 | } |
no test coverage detected
searching dependent graphs…