MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / getGroupName

Function getGroupName

src/epjson/epJSONTranslator.cpp:253–280  ·  view source on GitHub ↗

Find name of an extensible group and cache it */

Source from the content-addressed store, hash-verified

251
252/* Find name of an extensible group and cache it */
253auto getGroupName(std::map<std::pair<std::string, std::string>, std::pair<std::string, bool>>& group_names,
254 std::map<std::string, std::string>& /*field_names*/, const Json::Value& schema, const std::string& type_description,
255 const std::string& group_name) -> const auto& {
256
257 const auto key = std::pair{type_description, group_name};
258
259 if (const auto cached = group_names.find(key); cached != group_names.end()) {
260 return cached->second;
261 }
262
263 const auto cache_result = [&](const auto& name, const bool is_array) -> const auto& {
264 return group_names.emplace(key, std::pair{name, is_array}).first->second;
265 };
266
267 const auto& objectProperties = getSchemaObjectProperties(schema, type_description);
268
269 for (const auto& propertyName : objectProperties.getMemberNames()) {
270 const auto& type = safeLookupValue(objectProperties, propertyName, "type");
271 if (type.isString()) {
272 if (type.asString() == "array") {
273 return cache_result(propertyName, true);
274 }
275 }
276 }
277
278 // group name is irrelevant if it's not an array group
279 return cache_result("", false);
280}
281
282openstudio::path defaultSchemaPath(openstudio::IddFileType filetype) {
283 openstudio::path schemaPath;

Callers 1

toJSONFunction · 0.85

Calls 2

findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected