Support for getting natures by index for iterating purposes.

This commit is contained in:
Deukhoofd 2020-08-09 11:31:22 +02:00
parent ca087a7ed8
commit de3ad4a9c8
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
2 changed files with 10 additions and 0 deletions

View File

@ -21,3 +21,8 @@ export uint8_t PkmnLib_NatureLibrary_GetRandomNatureName(NatureLibrary* p, ArbUt
export uint8_t PkmnLib_NatureLibrary_GetNatureName(NatureLibrary* p, const Nature* nature, const char*& out) { export uint8_t PkmnLib_NatureLibrary_GetNatureName(NatureLibrary* p, const Nature* nature, const char*& out) {
Try(out = p->GetNatureName(nature).c_str()); Try(out = p->GetNatureName(nature).c_str());
} }
SIMPLE_GET_FUNC(NatureLibrary, GetNatureCount, size_t)
export uint8_t PkmnLib_NatureLibrary_GetNatureByIndex(NatureLibrary* p, size_t index, const char*& out) {
Try(out = p->GetNatureFromIndex(index).c_str();)
}

View File

@ -42,6 +42,11 @@ namespace PkmnLib::Library {
} }
throw CreatureException("Nature not found."); throw CreatureException("Nature not found.");
} }
size_t GetNatureCount() const noexcept { return _items.size(); }
inline const ArbUt::StringView& GetNatureFromIndex(size_t index) const {
return std::next(std::begin(_items), index)->first;
}
}; };
} }