MCPcopy Create free account
hub / github.com/comaps/comaps / GetTypeDescription

Method GetTypeDescription

libs/editor/editor_config.cpp:142–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140} // namespace
141
142bool EditorConfig::GetTypeDescription(std::vector<std::string> classificatorTypes,
143 TypeAggregatedDescription & outDesc) const
144{
145 bool isBuilding = false;
146 std::vector<std::string> addTypes;
147 for (auto it = classificatorTypes.begin(); it != classificatorTypes.end(); ++it)
148 {
149 if (*it == "building")
150 {
151 outDesc.m_address = isBuilding = true;
152 outDesc.m_editableFields.push_back(EType::FMD_BUILDING_LEVELS);
153 outDesc.m_editableFields.push_back(EType::FMD_POSTCODE);
154 classificatorTypes.erase(it);
155 break;
156 }
157
158 // Adding partial types for 2..N-1 parts of a N-part type.
159 auto hyphenPos = it->find('-');
160 while ((hyphenPos = it->find('-', hyphenPos + 1)) != std::string::npos)
161 addTypes.push_back(it->substr(0, hyphenPos));
162 }
163
164 classificatorTypes.insert(classificatorTypes.end(), addTypes.begin(), addTypes.end());
165
166 auto const typeNodes = GetPrioritizedTypes(m_document);
167 auto const it = base::FindIf(typeNodes, [&classificatorTypes](pugi::xml_node const & node)
168 { return base::IsExist(classificatorTypes, node.attribute("id").value()); });
169 if (it == end(typeNodes))
170 return isBuilding;
171
172 return TypeDescriptionFromXml(m_document, *it, outDesc);
173}
174
175std::vector<std::string> EditorConfig::GetTypesThatCanBeAdded() const
176{

Callers 2

UNIT_TESTFunction · 0.80

Calls 12

GetPrioritizedTypesFunction · 0.85
IsExistFunction · 0.85
TypeDescriptionFromXmlFunction · 0.85
FindIfFunction · 0.50
endFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
eraseMethod · 0.45
findMethod · 0.45
insertMethod · 0.45
valueMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.64