HasProperty config parameter recursion is now a thing, allowing for subproperties to be checked via the . syntax.

This commit is contained in:
2023-09-19 04:24:07 -05:00
parent 7745010099
commit 064d717e27
3 changed files with 36 additions and 24 deletions
+13 -2
View File
@@ -136,9 +136,20 @@ namespace olc::utils
// Checks if a property exists - useful to avoid creating properties
// via reading them, though non-essential
inline bool HasProperty(const std::string& sName) const
inline bool HasProperty(const std::string& sName)
{
return m_mapObjects.count(sName) > 0;
size_t x = sName.find_first_of('.');
if (x != std::string::npos)
{
std::string sProperty = sName.substr(0, x);
if(HasProperty(sProperty)){
return GetProperty(sName.substr(0, x)).HasProperty(sName.substr(x + 1, sName.size()));
}else{
return false;
}
}else{
return m_mapObjects.count(sName) > 0;
}
}
// Access a datafile via a convenient name - "root.node.something.property"