MCPcopy Index your code
hub / github.com/Kitware/CMake / operator()

Method operator()

Source/cmJSONHelpers.h:127–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125 }
126
127 bool operator()(T& out, Json::Value const* value, cmJSONState* state) const
128 {
129 Json::Value::Members extraFields;
130 if (!value && this->AnyRequired) {
131 Error(JsonErrors::ObjectError::RequiredMissing, extraFields)(value,
132 state);
133 return false;
134 }
135 if (value && !value->isObject()) {
136 Error(JsonErrors::ObjectError::InvalidObject, extraFields)(value,
137 state);
138 return false;
139 }
140 if (value) {
141 extraFields = value->getMemberNames();
142 }
143
144 if (state->allowComments) {
145 extraFields.erase(
146 std::remove(extraFields.begin(), extraFields.end(), "$comment"),
147 extraFields.end());
148 }
149
150 bool success = true;
151 for (auto const& m : this->Members) {
152 std::string name(m.Name.data(), m.Name.size());
153 state->push_stack(name, value);
154 if (value && value->isMember(name)) {
155 if (!m.Function(out, &(*value)[name], state)) {
156 success = false;
157 }
158 extraFields.erase(
159 std::find(extraFields.begin(), extraFields.end(), name));
160 } else if (!m.Required) {
161 if (!m.Function(out, nullptr, state)) {
162 success = false;
163 }
164 } else {
165 Error(JsonErrors::ObjectError::MissingRequired, extraFields)(value,
166 state);
167 success = false;
168 }
169 state->pop_stack();
170 }
171
172 if (!this->AllowExtra && !extraFields.empty()) {
173 Error(JsonErrors::ObjectError::ExtraField, extraFields)(value, state);
174 success = false;
175 }
176 return success;
177 }
178
179 private:
180 // Not a true cmJSONHelper, it just happens to match the signature

Callers

nothing calls this directly

Calls 13

isObjectMethod · 0.80
getMemberNamesMethod · 0.80
eraseMethod · 0.80
push_stackMethod · 0.80
isMemberMethod · 0.80
pop_stackMethod · 0.80
ErrorClass · 0.70
findFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected