UESaveFile,GenericStructProperty: update at().

This commit is contained in:
Guillaume Jacquemin 2021-09-22 18:23:16 +02:00
parent ce29d6174c
commit f286ec0633
3 changed files with 12 additions and 11 deletions

View File

@ -26,7 +26,8 @@ struct GenericStructProperty : public StructProperty {
using ptr = Containers::Pointer<GenericStructProperty>;
template<typename T>
auto at(const std::string& name) -> T* {
std::enable_if_t<std::is_base_of<UnrealPropertyBase, T>::value, T*>
at(const std::string& name) {
for(auto& item : properties) {
if(item->name == name) {
return static_cast<T*>(item.get());

View File

@ -43,15 +43,6 @@ auto UESaveFile::reloadData() -> bool {
return valid();
}
auto UESaveFile::at(const std::string& name) -> UnrealPropertyBase* {
for(auto& prop : _properties) {
if(*(prop->name) == name) {
return prop.get();
}
}
return nullptr;
}
auto UESaveFile::props() -> Containers::ArrayView<UnrealPropertyBase::ptr> {
return _properties;
}

View File

@ -40,7 +40,16 @@ class UESaveFile {
auto reloadData() -> bool;
auto at(const std::string& name) -> UnrealPropertyBase*;
template<typename T>
std::enable_if_t<std::is_base_of<UnrealPropertyBase, T>::value, T*>
at(const std::string& name) {
for(auto& prop : _properties) {
if(prop->name == name) {
return static_cast<T*>(prop.get());
}
}
return nullptr;
}
auto props() -> Containers::ArrayView<UnrealPropertyBase::ptr>;