Merge pull request #19907 from benj5378/getAttribute

Base: make getAttribute template
This commit is contained in:
Chris Hennes
2025-05-12 10:39:55 -05:00
committed by GitHub
64 changed files with 834 additions and 677 deletions

View File

@@ -315,25 +315,25 @@ void PropertyContainer::Restore(Base::XMLReader &reader)
{
reader.clearPartialRestoreProperty();
reader.readElement("Properties");
int Cnt = reader.getAttributeAsInteger("Count");
int Cnt = reader.getAttribute<long>("Count");
int transientCount = 0;
if(reader.hasAttribute("TransientCount"))
transientCount = reader.getAttributeAsUnsigned("TransientCount");
transientCount = reader.getAttribute<unsigned long>("TransientCount");
for (int i=0;i<transientCount; ++i) {
reader.readElement("_Property");
Property* prop = getPropertyByName(reader.getAttribute("name"));
Property* prop = getPropertyByName(reader.getAttribute<const char*>("name"));
if(prop)
FC_TRACE("restore transient '" << prop->getName() << "'");
if(prop && reader.hasAttribute("status"))
prop->setStatusValue(reader.getAttributeAsUnsigned("status"));
prop->setStatusValue(reader.getAttribute<unsigned long>("status"));
}
for (int i=0 ;i<Cnt ;i++) {
reader.readElement("Property");
std::string PropName = reader.getAttribute("name");
std::string TypeName = reader.getAttribute("type");
std::string PropName = reader.getAttribute<const char*>("name");
std::string TypeName = reader.getAttribute<const char*>("type");
// NOTE: We must also check the type of the current property because a
// subclass of PropertyContainer might change the type of a property but
// not its name. In this case we would force to read-in a wrong property
@@ -346,7 +346,7 @@ void PropertyContainer::Restore(Base::XMLReader &reader)
decltype(Property::StatusBits) status;
if(reader.hasAttribute("status")) {
status = decltype(status)(reader.getAttributeAsUnsigned("status"));
status = decltype(status)(reader.getAttribute<unsigned long>("status"));
if(prop)
prop->setStatusValue(status.to_ulong());
}