Skip to content

Commit 35d4a0a

Browse files
author
devsh
committed
now get it to compile
1 parent 9745682 commit 35d4a0a

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

include/nbl/ext/MitsubaLoader/IElement.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ class IElement
179179
}
180180

181181
public:
182+
using element_type = Derived;
183+
182184
inline void registerCallback(const SNamedPropertyElement::Type type, std::string&& propertyName, const AddPropertyCallback<Derived>& cb)
183185
{
184186
auto [nameIt,inserted] = byPropertyType[type].emplace(std::move(propertyName),cb);

src/nbl/ext/MitsubaLoader/ParserUtil.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,32 +208,44 @@ void ParserManager::XMLContext::parseElement(const char* _el, const char** _atts
208208
bool unsupportedElement = true;
209209
auto run = [&](const auto& map)->void
210210
{
211-
using element_t = std::remove_cvref_t<decltype(map)>::mapped_type::mapped_type::element_t;
211+
using element_t = std::remove_cvref_t<decltype(map)>::element_type;
212212
if (element_t::ElementType==element->getType())
213213
{
214214
unsupportedElement = false;
215215
auto& property = optProperty.value();
216-
auto typeIt = map.find(property.type);
217-
if (typeIt==map.end())
216+
const auto& typeMap = map.byPropertyType[property.type];
217+
if (typeMap.empty())
218218
{
219219
session->invalidXMLFileStructure("There's no property supported by ElementType (TODO) with PropertyType (TODO)");
220220
return;
221221
}
222-
auto nameIt = typeIt->second.find(property.name);
223-
if (nameIt==typeIt->second.end())
222+
auto nameIt = typeMap.find(property.name);
223+
if (nameIt==typeMap.end())
224224
{
225225
session->invalidXMLFileStructure("There's no Property named (TODO) of Type (TODO) supported by ElementType (TODO)");
226226
return;
227227
}
228-
// TODO: visit variant type checks
229-
nameIt->second(static_cast<element_t*>(element),std::move(property),session->params->logger);
228+
const auto& callback = nameIt->second;
229+
auto* typedElement = static_cast<element_t*>(element);
230+
if constexpr (!std::is_same_v<typename element_t::Type,IElement::Type>)
231+
if (std::find(callback.allowedVariantTypes.begin(),callback.allowedVariantTypes.end(),typedElement->type)==callback.allowedVariantTypes.end())
232+
{
233+
session->invalidXMLFileStructure("There's no Property named (TODO) of Type (TODO) not supported on ElementType (TODO) of Variant (TODO)");
234+
return;
235+
}
236+
callback(typedElement,std::move(property),session->params->logger);
230237
}
231238
};
232239
std::apply([&run](const auto&... maps)->void
233240
{
234241
(run(maps), ...);
235242
},manager->addPropertyMaps
236243
);
244+
if (unsupportedElement)
245+
{
246+
session->invalidXMLFileStructure("Current Element Type doesn't have a AddPropertyMap at all (no property adding supported)!");
247+
return;
248+
}
237249
return;
238250
}
239251

0 commit comments

Comments
 (0)