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

Method Load

Source/cmBuildDatabase.cxx:177–410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175 } while (0)
176
177std::unique_ptr<cmBuildDatabase> cmBuildDatabase::Load(std::string const& path)
178{
179 Json::Value mcdb;
180 {
181 cmsys::ifstream mcdbf(path.c_str(), std::ios::in | std::ios::binary);
182 Json::Reader reader;
183 if (!reader.parse(mcdbf, mcdb, false)) {
184 cmSystemTools::Error(
185 cmStrCat("-E cmake_module_compile_db failed to parse ", path,
186 reader.getFormattedErrorMessages()));
187 return {};
188 }
189 }
190
191 Json::Value const& version = mcdb["version"];
192 if (version.asUInt() > 1) {
193 cmSystemTools::Error(
194 cmStrCat("-E cmake_module_compile_db failed to parse ", path,
195 ": version ", version.asString()));
196 return {};
197 }
198
199 auto db = cm::make_unique<cmBuildDatabase>();
200
201 Json::Value const& sets = mcdb["sets"];
202 if (sets.isArray()) {
203 for (auto const& set : sets) {
204 Set Set_;
205
206 Json::Value const& name = set["name"];
207 if (!name.isString()) {
208 cmSystemTools::Error(
209 cmStrCat("-E cmake_module_compile_db failed to parse ", path,
210 ": name is not a string"));
211 return {};
212 }
213 Set_.Name = name.asString();
214
215 Json::Value const& family_name = set["family-name"];
216 if (!family_name.isString()) {
217 cmSystemTools::Error(
218 cmStrCat("-E cmake_module_compile_db failed to parse ", path,
219 ": family-name is not a string"));
220 return {};
221 }
222 Set_.FamilyName = family_name.asString();
223
224 Json::Value const& visible_sets = set["visible-sets"];
225 if (!visible_sets.isArray()) {
226 cmSystemTools::Error(
227 cmStrCat("-E cmake_module_compile_db failed to parse ", path,
228 ": visible-sets is not an array"));
229 return {};
230 }
231 for (auto const& visible_set : visible_sets) {
232 if (!visible_set.isString()) {
233 cmSystemTools::Error(
234 cmStrCat("-E cmake_module_compile_db failed to parse ", path,

Callers

nothing calls this directly

Calls 15

moveFunction · 0.85
c_strMethod · 0.80
asUIntMethod · 0.80
asStringMethod · 0.80
isArrayMethod · 0.80
isStringMethod · 0.80
emplace_backMethod · 0.80
isObjectMethod · 0.80
isNullMethod · 0.80
isMemberMethod · 0.80
isBoolMethod · 0.80

Tested by

no test coverage detected