Merge pull request #19907 from benj5378/getAttribute
Base: make getAttribute template
This commit is contained in:
@@ -480,7 +480,7 @@ void ComplexGeoData::Restore(Base::XMLReader& reader)
|
||||
|
||||
reader.readElement("ElementMap");
|
||||
bool newTag = false;
|
||||
if (reader.hasAttribute("new") && reader.getAttributeAsInteger("new") > 0) {
|
||||
if (reader.hasAttribute("new") && reader.getAttribute<bool>("new")) {
|
||||
reader.readEndElement("ElementMap");
|
||||
reader.readElement("ElementMap2");
|
||||
newTag = true;
|
||||
@@ -488,7 +488,7 @@ void ComplexGeoData::Restore(Base::XMLReader& reader)
|
||||
|
||||
const char* file = "";
|
||||
if (reader.hasAttribute("file")) {
|
||||
file = reader.getAttribute("file");
|
||||
file = reader.getAttribute<const char*>("file");
|
||||
}
|
||||
if (*file != 0) {
|
||||
reader.addFile(file, this);
|
||||
@@ -497,7 +497,7 @@ void ComplexGeoData::Restore(Base::XMLReader& reader)
|
||||
|
||||
std::size_t count = 0;
|
||||
if (reader.hasAttribute("count")) {
|
||||
count = reader.getAttributeAsUnsigned("count");
|
||||
count = reader.getAttribute<unsigned long>("count");
|
||||
}
|
||||
if (count == 0) {
|
||||
return;
|
||||
@@ -539,7 +539,7 @@ void ComplexGeoData::readElements(Base::XMLReader& reader, size_t count)
|
||||
}
|
||||
}
|
||||
else {
|
||||
const char* attr = reader.getAttribute("sid");
|
||||
const char* attr = reader.getAttribute<const char*>("sid");
|
||||
bio::stream<bio::array_source> iss(attr, std::strlen(attr));
|
||||
long id {};
|
||||
while ((iss >> id)) {
|
||||
@@ -558,8 +558,8 @@ void ComplexGeoData::readElements(Base::XMLReader& reader, size_t count)
|
||||
}
|
||||
}
|
||||
}
|
||||
ensureElementMap()->setElementName(IndexedName(reader.getAttribute("value"), types),
|
||||
MappedName(reader.getAttribute("key")),
|
||||
ensureElementMap()->setElementName(IndexedName(reader.getAttribute<const char*>("value"), types),
|
||||
MappedName(reader.getAttribute<const char*>("key")),
|
||||
Tag,
|
||||
&sids);
|
||||
}
|
||||
|
||||
@@ -1038,16 +1038,16 @@ void Document::Restore(Base::XMLReader& reader)
|
||||
setStatus(Document::PartialDoc, false);
|
||||
|
||||
reader.readElement("Document");
|
||||
long scheme = reader.getAttributeAsInteger("SchemaVersion");
|
||||
long scheme = reader.getAttribute<long>("SchemaVersion");
|
||||
reader.DocumentSchema = scheme;
|
||||
if (reader.hasAttribute("ProgramVersion")) {
|
||||
reader.ProgramVersion = reader.getAttribute("ProgramVersion");
|
||||
reader.ProgramVersion = reader.getAttribute<const char*>("ProgramVersion");
|
||||
}
|
||||
else {
|
||||
reader.ProgramVersion = "pre-0.14";
|
||||
}
|
||||
if (reader.hasAttribute("FileVersion")) {
|
||||
reader.FileVersion = reader.getAttributeAsUnsigned("FileVersion");
|
||||
reader.FileVersion = reader.getAttribute<unsigned long>("FileVersion");
|
||||
}
|
||||
else {
|
||||
reader.FileVersion = 0;
|
||||
@@ -1083,11 +1083,11 @@ void Document::Restore(Base::XMLReader& reader)
|
||||
if (scheme == 2) {
|
||||
// read the feature types
|
||||
reader.readElement("Features");
|
||||
Cnt = reader.getAttributeAsInteger("Count");
|
||||
Cnt = reader.getAttribute<long>("Count");
|
||||
for (i = 0; i < Cnt; i++) {
|
||||
reader.readElement("Feature");
|
||||
string type = reader.getAttribute("type");
|
||||
string name = reader.getAttribute("name");
|
||||
string type = reader.getAttribute<const char*>("type");
|
||||
string name = reader.getAttribute<const char*>("name");
|
||||
try {
|
||||
addObject(type.c_str(), name.c_str(), /*isNew=*/false);
|
||||
}
|
||||
@@ -1099,10 +1099,10 @@ void Document::Restore(Base::XMLReader& reader)
|
||||
|
||||
// read the features itself
|
||||
reader.readElement("FeatureData");
|
||||
Cnt = reader.getAttributeAsInteger("Count");
|
||||
Cnt = reader.getAttribute<long>("Count");
|
||||
for (i = 0; i < Cnt; i++) {
|
||||
reader.readElement("Feature");
|
||||
string name = reader.getAttribute("name");
|
||||
string name = reader.getAttribute<const char*>("name");
|
||||
DocumentObject* pObj = getObject(name.c_str());
|
||||
if (pObj) { // check if this feature has been registered
|
||||
pObj->setStatus(ObjectStatus::Restore, true);
|
||||
@@ -1405,7 +1405,7 @@ std::vector<App::DocumentObject*> Document::readObjects(Base::XMLReader& reader)
|
||||
|
||||
// read the object types
|
||||
reader.readElement("Objects");
|
||||
int Cnt = reader.getAttributeAsInteger("Count");
|
||||
int Cnt = reader.getAttribute<long>("Count");
|
||||
|
||||
if (!reader.hasAttribute(FC_ATTR_DEPENDENCIES)) {
|
||||
d->partialLoadObjects.clear();
|
||||
@@ -1414,17 +1414,17 @@ std::vector<App::DocumentObject*> Document::readObjects(Base::XMLReader& reader)
|
||||
std::unordered_map<std::string, DepInfo> deps;
|
||||
for (int i = 0; i < Cnt; i++) {
|
||||
reader.readElement(FC_ELEMENT_OBJECT_DEPS);
|
||||
int dcount = reader.getAttributeAsInteger(FC_ATTR_DEP_COUNT);
|
||||
int dcount = reader.getAttribute<long>(FC_ATTR_DEP_COUNT);
|
||||
if (!dcount) {
|
||||
continue;
|
||||
}
|
||||
auto& info = deps[reader.getAttribute(FC_ATTR_DEP_OBJ_NAME)];
|
||||
auto& info = deps[reader.getAttribute<const char*>(FC_ATTR_DEP_OBJ_NAME)];
|
||||
if (reader.hasAttribute(FC_ATTR_DEP_ALLOW_PARTIAL)) {
|
||||
info.canLoadPartial = reader.getAttributeAsInteger(FC_ATTR_DEP_ALLOW_PARTIAL);
|
||||
info.canLoadPartial = reader.getAttribute<long>(FC_ATTR_DEP_ALLOW_PARTIAL);
|
||||
}
|
||||
for (int j = 0; j < dcount; ++j) {
|
||||
reader.readElement(FC_ELEMENT_OBJECT_DEP);
|
||||
const char* name = reader.getAttribute(FC_ATTR_DEP_OBJ_NAME);
|
||||
const char* name = reader.getAttribute<const char*>(FC_ATTR_DEP_OBJ_NAME);
|
||||
if (!Base::Tools::isNullOrEmpty(name)) {
|
||||
info.deps.insert(name);
|
||||
}
|
||||
@@ -1458,10 +1458,10 @@ std::vector<App::DocumentObject*> Document::readObjects(Base::XMLReader& reader)
|
||||
long lastId = 0;
|
||||
for (int i = 0; i < Cnt; i++) {
|
||||
reader.readElement("Object");
|
||||
std::string type = reader.getAttribute("type");
|
||||
std::string name = reader.getAttribute("name");
|
||||
std::string type = reader.getAttribute<const char*>("type");
|
||||
std::string name = reader.getAttribute<const char*>("name");
|
||||
std::string viewType =
|
||||
reader.hasAttribute("ViewType") ? reader.getAttribute("ViewType") : "";
|
||||
reader.hasAttribute("ViewType") ? reader.getAttribute<const char*>("ViewType") : "";
|
||||
|
||||
bool partial = false;
|
||||
if (!d->partialLoadObjects.empty()) {
|
||||
@@ -1475,7 +1475,7 @@ std::vector<App::DocumentObject*> Document::readObjects(Base::XMLReader& reader)
|
||||
if (!testStatus(Status::Importing) && reader.hasAttribute("id")) {
|
||||
// if not importing, then temporary reset lastObjectId and make the
|
||||
// following addObject() generate the correct id for this object.
|
||||
d->lastObjectId = reader.getAttributeAsInteger("id") - 1;
|
||||
d->lastObjectId = reader.getAttribute<long>("id") - 1;
|
||||
}
|
||||
|
||||
// To prevent duplicate name when export/import of objects from
|
||||
@@ -1514,15 +1514,15 @@ std::vector<App::DocumentObject*> Document::readObjects(Base::XMLReader& reader)
|
||||
|
||||
// restore touch/error status flags
|
||||
if (reader.hasAttribute("Touched")) {
|
||||
if (reader.getAttributeAsInteger("Touched") != 0) {
|
||||
if (reader.getAttribute<long>("Touched") != 0) {
|
||||
d->touchedObjs.insert(obj);
|
||||
}
|
||||
}
|
||||
if (reader.hasAttribute("Invalid")) {
|
||||
obj->setStatus(ObjectStatus::Error,
|
||||
reader.getAttributeAsInteger("Invalid") != 0);
|
||||
reader.getAttribute<bool>("Invalid"));
|
||||
if (obj->isError() && reader.hasAttribute("Error")) {
|
||||
d->addRecomputeLog(reader.getAttribute("Error"), obj);
|
||||
d->addRecomputeLog(reader.getAttribute<const char*>("Error"), obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1541,10 +1541,10 @@ std::vector<App::DocumentObject*> Document::readObjects(Base::XMLReader& reader)
|
||||
// read the features itself
|
||||
reader.clearPartialRestoreDocumentObject();
|
||||
reader.readElement("ObjectData");
|
||||
Cnt = reader.getAttributeAsInteger("Count");
|
||||
Cnt = reader.getAttribute<long>("Count");
|
||||
for (int i = 0; i < Cnt; i++) {
|
||||
reader.readElement("Object");
|
||||
std::string name = reader.getName(reader.getAttribute("name"));
|
||||
std::string name = reader.getName(reader.getAttribute<const char*>("name"));
|
||||
DocumentObject* pObj = getObject(name.c_str());
|
||||
if (pObj
|
||||
&& !pObj->testStatus(
|
||||
@@ -1605,16 +1605,16 @@ std::vector<App::DocumentObject*> Document::importObjects(Base::XMLReader& reade
|
||||
Base::ObjectStatusLocker<Status, Document> restoreBit2(Status::Importing, this);
|
||||
ExpressionParser::ExpressionImporter expImporter(reader);
|
||||
reader.readElement("Document");
|
||||
long scheme = reader.getAttributeAsInteger("SchemaVersion");
|
||||
long scheme = reader.getAttribute<long>("SchemaVersion");
|
||||
reader.DocumentSchema = scheme;
|
||||
if (reader.hasAttribute("ProgramVersion")) {
|
||||
reader.ProgramVersion = reader.getAttribute("ProgramVersion");
|
||||
reader.ProgramVersion = reader.getAttribute<const char*>("ProgramVersion");
|
||||
}
|
||||
else {
|
||||
reader.ProgramVersion = "pre-0.14";
|
||||
}
|
||||
if (reader.hasAttribute("FileVersion")) {
|
||||
reader.FileVersion = reader.getAttributeAsUnsigned("FileVersion");
|
||||
reader.FileVersion = reader.getAttribute<unsigned long>("FileVersion");
|
||||
}
|
||||
else {
|
||||
reader.FileVersion = 0;
|
||||
|
||||
@@ -358,25 +358,25 @@ Property* DynamicProperty::restore(PropertyContainer& pc,
|
||||
short attribute = 0;
|
||||
bool readonly = false, hidden = false;
|
||||
const char *group = nullptr, *doc = nullptr, *attr = nullptr, *ro = nullptr, *hide = nullptr;
|
||||
group = reader.getAttribute("group");
|
||||
group = reader.getAttribute<const char*>("group");
|
||||
if (reader.hasAttribute("doc")) {
|
||||
doc = reader.getAttribute("doc");
|
||||
doc = reader.getAttribute<const char*>("doc");
|
||||
}
|
||||
if (reader.hasAttribute("attr")) {
|
||||
attr = reader.getAttribute("attr");
|
||||
attr = reader.getAttribute<const char*>("attr");
|
||||
if (attr) {
|
||||
std::istringstream str(attr);
|
||||
str >> attribute;
|
||||
}
|
||||
}
|
||||
if (reader.hasAttribute("ro")) {
|
||||
ro = reader.getAttribute("ro");
|
||||
ro = reader.getAttribute<const char*>("ro");
|
||||
if (ro) {
|
||||
readonly = (ro[0] - 48) != 0;
|
||||
}
|
||||
}
|
||||
if (reader.hasAttribute("hide")) {
|
||||
hide = reader.getAttribute("hide");
|
||||
hide = reader.getAttribute<const char*>("hide");
|
||||
if (hide) {
|
||||
hidden = (hide[0] - 48) != 0;
|
||||
}
|
||||
|
||||
@@ -431,12 +431,12 @@ void ExtensionContainer::restoreExtensions(Base::XMLReader& reader)
|
||||
}
|
||||
|
||||
reader.readElement("Extensions");
|
||||
int Cnt = reader.getAttributeAsInteger("Count");
|
||||
int Cnt = reader.getAttribute<long>("Count");
|
||||
|
||||
for (int i = 0; i < Cnt; i++) {
|
||||
reader.readElement("Extension");
|
||||
const char* Type = reader.getAttribute("type");
|
||||
const char* Name = reader.getAttribute("name");
|
||||
const char* Type = reader.getAttribute<const char*>("type");
|
||||
const char* Name = reader.getAttribute<const char*>("name");
|
||||
try {
|
||||
App::Extension* ext = getExtension(Name);
|
||||
if (!ext) {
|
||||
|
||||
@@ -338,10 +338,10 @@ bool ProjectFile::restoreObject(const std::string& name, App::PropertyContainer*
|
||||
reader.readEndElement("Objects");
|
||||
|
||||
reader.readElement("ObjectData");
|
||||
long Cnt = reader.getAttributeAsInteger("Count");
|
||||
long Cnt = reader.getAttribute<long>("Count");
|
||||
for (long i = 0; i < Cnt; i++) {
|
||||
reader.readElement("Object");
|
||||
std::string nameAttr = reader.getAttribute("name");
|
||||
std::string nameAttr = reader.getAttribute<const char*>("name");
|
||||
|
||||
if (nameAttr == name) {
|
||||
// obj->StatusBits.set(4);
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -327,9 +327,9 @@ void PropertyExpressionEngine::Save(Base::Writer& writer) const
|
||||
void PropertyExpressionEngine::Restore(Base::XMLReader& reader)
|
||||
{
|
||||
reader.readElement("ExpressionEngine");
|
||||
int count = reader.getAttributeAsFloat("count");
|
||||
int count = reader.getAttribute<double>("count");
|
||||
|
||||
if (reader.hasAttribute("xlink") && reader.getAttributeAsInteger("xlink")) {
|
||||
if (reader.hasAttribute("xlink") && reader.getAttribute<bool>("xlink")) {
|
||||
PropertyExpressionContainer::Restore(reader);
|
||||
}
|
||||
|
||||
@@ -340,10 +340,10 @@ void PropertyExpressionEngine::Restore(Base::XMLReader& reader)
|
||||
reader.readElement("Expression");
|
||||
restoredExpressions->emplace_back();
|
||||
auto& info = restoredExpressions->back();
|
||||
info.path = reader.getAttribute("path");
|
||||
info.expr = reader.getAttribute("expression");
|
||||
info.path = reader.getAttribute<const char*>("path");
|
||||
info.expr = reader.getAttribute<const char*>("expression");
|
||||
if (reader.hasAttribute("comment")) {
|
||||
info.comment = reader.getAttribute("comment");
|
||||
info.comment = reader.getAttribute<const char*>("comment");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -398,7 +398,7 @@ void PropertyFileIncluded::Restore(Base::XMLReader& reader)
|
||||
{
|
||||
reader.readElement("FileIncluded");
|
||||
if (reader.hasAttribute("file")) {
|
||||
string file(reader.getAttribute("file"));
|
||||
string file(reader.getAttribute<const char*>("file"));
|
||||
if (!file.empty()) {
|
||||
// initiate a file read
|
||||
reader.addFile(file.c_str(), this);
|
||||
@@ -411,7 +411,7 @@ void PropertyFileIncluded::Restore(Base::XMLReader& reader)
|
||||
}
|
||||
// section is XML stream
|
||||
else if (reader.hasAttribute("data")) {
|
||||
string file(reader.getAttribute("data"));
|
||||
string file(reader.getAttribute<const char*>("data"));
|
||||
if (!file.empty()) {
|
||||
// is in the document transient path
|
||||
aboutToSetValue();
|
||||
|
||||
@@ -160,9 +160,9 @@ void PropertyVector::Restore(Base::XMLReader& reader)
|
||||
reader.readElement("PropertyVector");
|
||||
// get the value of my Attribute
|
||||
aboutToSetValue();
|
||||
_cVec.x = reader.getAttributeAsFloat("valueX");
|
||||
_cVec.y = reader.getAttributeAsFloat("valueY");
|
||||
_cVec.z = reader.getAttributeAsFloat("valueZ");
|
||||
_cVec.x = reader.getAttribute<double>("valueX");
|
||||
_cVec.y = reader.getAttribute<double>("valueY");
|
||||
_cVec.z = reader.getAttribute<double>("valueZ");
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ void PropertyVectorList::Save(Base::Writer& writer) const
|
||||
void PropertyVectorList::Restore(Base::XMLReader& reader)
|
||||
{
|
||||
reader.readElement("VectorList");
|
||||
std::string file(reader.getAttribute("file"));
|
||||
std::string file(reader.getAttribute<const char*>("file"));
|
||||
|
||||
if (!file.empty()) {
|
||||
// initiate a file read
|
||||
@@ -478,25 +478,25 @@ void PropertyMatrix::Restore(Base::XMLReader& reader)
|
||||
reader.readElement("PropertyMatrix");
|
||||
// get the value of my Attribute
|
||||
aboutToSetValue();
|
||||
_cMat[0][0] = reader.getAttributeAsFloat("a11");
|
||||
_cMat[0][1] = reader.getAttributeAsFloat("a12");
|
||||
_cMat[0][2] = reader.getAttributeAsFloat("a13");
|
||||
_cMat[0][3] = reader.getAttributeAsFloat("a14");
|
||||
_cMat[0][0] = reader.getAttribute<double>("a11");
|
||||
_cMat[0][1] = reader.getAttribute<double>("a12");
|
||||
_cMat[0][2] = reader.getAttribute<double>("a13");
|
||||
_cMat[0][3] = reader.getAttribute<double>("a14");
|
||||
|
||||
_cMat[1][0] = reader.getAttributeAsFloat("a21");
|
||||
_cMat[1][1] = reader.getAttributeAsFloat("a22");
|
||||
_cMat[1][2] = reader.getAttributeAsFloat("a23");
|
||||
_cMat[1][3] = reader.getAttributeAsFloat("a24");
|
||||
_cMat[1][0] = reader.getAttribute<double>("a21");
|
||||
_cMat[1][1] = reader.getAttribute<double>("a22");
|
||||
_cMat[1][2] = reader.getAttribute<double>("a23");
|
||||
_cMat[1][3] = reader.getAttribute<double>("a24");
|
||||
|
||||
_cMat[2][0] = reader.getAttributeAsFloat("a31");
|
||||
_cMat[2][1] = reader.getAttributeAsFloat("a32");
|
||||
_cMat[2][2] = reader.getAttributeAsFloat("a33");
|
||||
_cMat[2][3] = reader.getAttributeAsFloat("a34");
|
||||
_cMat[2][0] = reader.getAttribute<double>("a31");
|
||||
_cMat[2][1] = reader.getAttribute<double>("a32");
|
||||
_cMat[2][2] = reader.getAttribute<double>("a33");
|
||||
_cMat[2][3] = reader.getAttribute<double>("a34");
|
||||
|
||||
_cMat[3][0] = reader.getAttributeAsFloat("a41");
|
||||
_cMat[3][1] = reader.getAttributeAsFloat("a42");
|
||||
_cMat[3][2] = reader.getAttributeAsFloat("a43");
|
||||
_cMat[3][3] = reader.getAttributeAsFloat("a44");
|
||||
_cMat[3][0] = reader.getAttribute<double>("a41");
|
||||
_cMat[3][1] = reader.getAttribute<double>("a42");
|
||||
_cMat[3][2] = reader.getAttribute<double>("a43");
|
||||
_cMat[3][3] = reader.getAttribute<double>("a44");
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
@@ -865,22 +865,22 @@ void PropertyPlacement::Restore(Base::XMLReader& reader)
|
||||
aboutToSetValue();
|
||||
|
||||
if (reader.hasAttribute("A")) {
|
||||
_cPos = Base::Placement(Vector3d(reader.getAttributeAsFloat("Px"),
|
||||
reader.getAttributeAsFloat("Py"),
|
||||
reader.getAttributeAsFloat("Pz")),
|
||||
Rotation(Vector3d(reader.getAttributeAsFloat("Ox"),
|
||||
reader.getAttributeAsFloat("Oy"),
|
||||
reader.getAttributeAsFloat("Oz")),
|
||||
reader.getAttributeAsFloat("A")));
|
||||
_cPos = Base::Placement(Vector3d(reader.getAttribute<double>("Px"),
|
||||
reader.getAttribute<double>("Py"),
|
||||
reader.getAttribute<double>("Pz")),
|
||||
Rotation(Vector3d(reader.getAttribute<double>("Ox"),
|
||||
reader.getAttribute<double>("Oy"),
|
||||
reader.getAttribute<double>("Oz")),
|
||||
reader.getAttribute<double>("A")));
|
||||
}
|
||||
else {
|
||||
_cPos = Base::Placement(Vector3d(reader.getAttributeAsFloat("Px"),
|
||||
reader.getAttributeAsFloat("Py"),
|
||||
reader.getAttributeAsFloat("Pz")),
|
||||
Rotation(reader.getAttributeAsFloat("Q0"),
|
||||
reader.getAttributeAsFloat("Q1"),
|
||||
reader.getAttributeAsFloat("Q2"),
|
||||
reader.getAttributeAsFloat("Q3")));
|
||||
_cPos = Base::Placement(Vector3d(reader.getAttribute<double>("Px"),
|
||||
reader.getAttribute<double>("Py"),
|
||||
reader.getAttribute<double>("Pz")),
|
||||
Rotation(reader.getAttribute<double>("Q0"),
|
||||
reader.getAttribute<double>("Q1"),
|
||||
reader.getAttribute<double>("Q2"),
|
||||
reader.getAttribute<double>("Q3")));
|
||||
}
|
||||
|
||||
hasSetValue();
|
||||
@@ -947,7 +947,7 @@ void PropertyPlacementList::Save(Base::Writer& writer) const
|
||||
void PropertyPlacementList::Restore(Base::XMLReader& reader)
|
||||
{
|
||||
reader.readElement("PlacementList");
|
||||
std::string file(reader.getAttribute("file"));
|
||||
std::string file(reader.getAttribute<const char*>("file"));
|
||||
|
||||
if (!file.empty()) {
|
||||
// initiate a file read
|
||||
@@ -1258,10 +1258,10 @@ void PropertyRotation::Restore(Base::XMLReader& reader)
|
||||
reader.readElement("PropertyRotation");
|
||||
aboutToSetValue();
|
||||
|
||||
_rot = Rotation(Vector3d(reader.getAttributeAsFloat("Ox"),
|
||||
reader.getAttributeAsFloat("Oy"),
|
||||
reader.getAttributeAsFloat("Oz")),
|
||||
reader.getAttributeAsFloat("A"));
|
||||
_rot = Rotation(Vector3d(reader.getAttribute<double>("Ox"),
|
||||
reader.getAttribute<double>("Oy"),
|
||||
reader.getAttribute<double>("Oz")),
|
||||
reader.getAttribute<double>("A"));
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
|
||||
@@ -776,7 +776,7 @@ void PropertyLink::Restore(Base::XMLReader& reader)
|
||||
// read my element
|
||||
reader.readElement("Link");
|
||||
// get the value of my attribute
|
||||
std::string name = reader.getName(reader.getAttribute("value"));
|
||||
std::string name = reader.getName(reader.getAttribute<const char*>("value"));
|
||||
|
||||
// Property not in a DocumentObject!
|
||||
assert(getContainer()->isDerivedFrom<App::DocumentObject>());
|
||||
@@ -1060,7 +1060,7 @@ void PropertyLinkList::Restore(Base::XMLReader& reader)
|
||||
// read my element
|
||||
reader.readElement("LinkList");
|
||||
// get the value of my attribute
|
||||
int count = reader.getAttributeAsInteger("count");
|
||||
int count = reader.getAttribute<long>("count");
|
||||
App::PropertyContainer* container = getContainer();
|
||||
if (!container) {
|
||||
throw Base::RuntimeError("Property is not part of a container");
|
||||
@@ -1075,7 +1075,7 @@ void PropertyLinkList::Restore(Base::XMLReader& reader)
|
||||
values.reserve(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
reader.readElement("Link");
|
||||
std::string name = reader.getName(reader.getAttribute("value"));
|
||||
std::string name = reader.getName(reader.getAttribute<const char*>("value"));
|
||||
// In order to do copy/paste it must be allowed to have defined some
|
||||
// referenced objects in XML which do not exist anymore in the new
|
||||
// document. Thus, we should silently ignore this.
|
||||
@@ -1888,8 +1888,8 @@ void PropertyLinkSub::Restore(Base::XMLReader& reader)
|
||||
// read my element
|
||||
reader.readElement("LinkSub");
|
||||
// get the values of my attributes
|
||||
std::string name = reader.getName(reader.getAttribute("value"));
|
||||
int count = reader.getAttributeAsInteger("count");
|
||||
std::string name = reader.getName(reader.getAttribute<const char*>("value"));
|
||||
int count = reader.getAttribute<long>("count");
|
||||
|
||||
// Property not in a DocumentObject!
|
||||
assert(getContainer()->isDerivedFrom<App::DocumentObject>());
|
||||
@@ -1913,16 +1913,16 @@ void PropertyLinkSub::Restore(Base::XMLReader& reader)
|
||||
// Sub may store '.' separated object names, so be aware of the possible mapping when import
|
||||
for (int i = 0; i < count; i++) {
|
||||
reader.readElement("Sub");
|
||||
shadows[i].oldName = importSubName(reader, reader.getAttribute("value"), restoreLabel);
|
||||
shadows[i].oldName = importSubName(reader, reader.getAttribute<const char*>("value"), restoreLabel);
|
||||
if (reader.hasAttribute(ATTR_SHADOWED) && !IGNORE_SHADOW) {
|
||||
values[i] = shadows[i].newName =
|
||||
importSubName(reader, reader.getAttribute(ATTR_SHADOWED), restoreLabel);
|
||||
importSubName(reader, reader.getAttribute<const char*>(ATTR_SHADOWED), restoreLabel);
|
||||
}
|
||||
else {
|
||||
values[i] = shadows[i].oldName;
|
||||
if (reader.hasAttribute(ATTR_SHADOW) && !IGNORE_SHADOW) {
|
||||
shadows[i].newName =
|
||||
importSubName(reader, reader.getAttribute(ATTR_SHADOW), restoreLabel);
|
||||
importSubName(reader, reader.getAttribute<const char*>(ATTR_SHADOW), restoreLabel);
|
||||
}
|
||||
}
|
||||
if (reader.hasAttribute(ATTR_MAPPED)) {
|
||||
@@ -2836,7 +2836,7 @@ void PropertyLinkSubList::Restore(Base::XMLReader& reader)
|
||||
// read my element
|
||||
reader.readElement("LinkSubList");
|
||||
// get the value of my attribute
|
||||
int count = reader.getAttributeAsInteger("count");
|
||||
int count = reader.getAttribute<long>("count");
|
||||
|
||||
std::vector<DocumentObject*> values;
|
||||
values.reserve(count);
|
||||
@@ -2850,7 +2850,7 @@ void PropertyLinkSubList::Restore(Base::XMLReader& reader)
|
||||
bool restoreLabel = false;
|
||||
for (int i = 0; i < count; i++) {
|
||||
reader.readElement("Link");
|
||||
std::string name = reader.getName(reader.getAttribute("obj"));
|
||||
std::string name = reader.getName(reader.getAttribute<const char*>("obj"));
|
||||
// In order to do copy/paste it must be allowed to have defined some
|
||||
// referenced objects in XML which do not exist anymore in the new
|
||||
// document. Thus, we should silently ignore this.
|
||||
@@ -2860,17 +2860,17 @@ void PropertyLinkSubList::Restore(Base::XMLReader& reader)
|
||||
values.push_back(child);
|
||||
shadows.emplace_back();
|
||||
auto& shadow = shadows.back();
|
||||
shadow.oldName = importSubName(reader, reader.getAttribute("sub"), restoreLabel);
|
||||
shadow.oldName = importSubName(reader, reader.getAttribute<const char*>("sub"), restoreLabel);
|
||||
if (reader.hasAttribute(ATTR_SHADOWED) && !IGNORE_SHADOW) {
|
||||
shadow.newName =
|
||||
importSubName(reader, reader.getAttribute(ATTR_SHADOWED), restoreLabel);
|
||||
importSubName(reader, reader.getAttribute<const char*>(ATTR_SHADOWED), restoreLabel);
|
||||
SubNames.push_back(shadow.newName);
|
||||
}
|
||||
else {
|
||||
SubNames.push_back(shadow.oldName);
|
||||
if (reader.hasAttribute(ATTR_SHADOW) && !IGNORE_SHADOW) {
|
||||
shadow.newName =
|
||||
importSubName(reader, reader.getAttribute(ATTR_SHADOW), restoreLabel);
|
||||
importSubName(reader, reader.getAttribute<const char*>(ATTR_SHADOW), restoreLabel);
|
||||
}
|
||||
}
|
||||
if (reader.hasAttribute(ATTR_MAPPED)) {
|
||||
@@ -4232,20 +4232,20 @@ void PropertyXLink::Restore(Base::XMLReader& reader)
|
||||
reader.readElement("XLink");
|
||||
std::string stampAttr, file;
|
||||
if (reader.hasAttribute("stamp")) {
|
||||
stampAttr = reader.getAttribute("stamp");
|
||||
stampAttr = reader.getAttribute<const char*>("stamp");
|
||||
}
|
||||
if (reader.hasAttribute("file")) {
|
||||
file = reader.getAttribute("file");
|
||||
file = reader.getAttribute<const char*>("file");
|
||||
}
|
||||
|
||||
setFlag(LinkAllowPartial,
|
||||
reader.hasAttribute("partial") && reader.getAttributeAsInteger("partial"));
|
||||
reader.hasAttribute("partial") && reader.getAttribute<bool>("partial"));
|
||||
std::string name;
|
||||
if (file.empty()) {
|
||||
name = reader.getName(reader.getAttribute("name"));
|
||||
name = reader.getName(reader.getAttribute<const char*>("name"));
|
||||
}
|
||||
else {
|
||||
name = reader.getAttribute("name");
|
||||
name = reader.getAttribute<const char*>("name");
|
||||
}
|
||||
|
||||
assert(getContainer()->isDerivedFrom<App::DocumentObject>());
|
||||
@@ -4275,35 +4275,35 @@ void PropertyXLink::Restore(Base::XMLReader& reader)
|
||||
auto& subname = subs.back();
|
||||
shadows.emplace_back();
|
||||
auto& shadow = shadows.back();
|
||||
shadow.oldName = importSubName(reader, reader.getAttribute("sub"), restoreLabel);
|
||||
shadow.oldName = importSubName(reader, reader.getAttribute<const char*>("sub"), restoreLabel);
|
||||
if (reader.hasAttribute(ATTR_SHADOWED) && !IGNORE_SHADOW) {
|
||||
subname = shadow.newName =
|
||||
importSubName(reader, reader.getAttribute(ATTR_SHADOWED), restoreLabel);
|
||||
importSubName(reader, reader.getAttribute<const char*>(ATTR_SHADOWED), restoreLabel);
|
||||
}
|
||||
else {
|
||||
subname = shadow.oldName;
|
||||
if (reader.hasAttribute(ATTR_SHADOW) && !IGNORE_SHADOW) {
|
||||
shadow.newName =
|
||||
importSubName(reader, reader.getAttribute(ATTR_SHADOW), restoreLabel);
|
||||
importSubName(reader, reader.getAttribute<const char*>(ATTR_SHADOW), restoreLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (reader.hasAttribute("count")) {
|
||||
int count = reader.getAttributeAsInteger("count");
|
||||
int count = reader.getAttribute<long>("count");
|
||||
subs.resize(count);
|
||||
shadows.resize(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
reader.readElement("Sub");
|
||||
shadows[i].oldName = importSubName(reader, reader.getAttribute("value"), restoreLabel);
|
||||
shadows[i].oldName = importSubName(reader, reader.getAttribute<const char*>("value"), restoreLabel);
|
||||
if (reader.hasAttribute(ATTR_SHADOWED) && !IGNORE_SHADOW) {
|
||||
subs[i] = shadows[i].newName =
|
||||
importSubName(reader, reader.getAttribute(ATTR_SHADOWED), restoreLabel);
|
||||
importSubName(reader, reader.getAttribute<const char*>(ATTR_SHADOWED), restoreLabel);
|
||||
}
|
||||
else {
|
||||
subs[i] = shadows[i].oldName;
|
||||
if (reader.hasAttribute(ATTR_SHADOW) && !IGNORE_SHADOW) {
|
||||
shadows[i].newName =
|
||||
importSubName(reader, reader.getAttribute(ATTR_SHADOW), restoreLabel);
|
||||
importSubName(reader, reader.getAttribute<const char*>(ATTR_SHADOW), restoreLabel);
|
||||
}
|
||||
}
|
||||
if (reader.hasAttribute(ATTR_MAPPED)) {
|
||||
@@ -5128,8 +5128,8 @@ void PropertyXLinkSubList::Restore(Base::XMLReader& reader)
|
||||
{
|
||||
reader.readElement("XLinkSubList");
|
||||
setFlag(LinkAllowPartial,
|
||||
reader.hasAttribute("partial") && reader.getAttributeAsInteger("partial"));
|
||||
int count = reader.getAttributeAsInteger("count");
|
||||
reader.hasAttribute("partial") && reader.getAttribute<bool>("partial"));
|
||||
int count = reader.getAttribute<long>("count");
|
||||
atomic_change guard(*this, false);
|
||||
_Links.clear();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
@@ -5789,11 +5789,11 @@ void PropertyXLinkContainer::Save(Base::Writer& writer) const
|
||||
void PropertyXLinkContainer::Restore(Base::XMLReader& reader)
|
||||
{
|
||||
reader.readElement("XLinks");
|
||||
auto count = reader.getAttributeAsUnsigned("count");
|
||||
auto count = reader.getAttribute<unsigned long>("count");
|
||||
_XLinkRestores = std::make_unique<std::vector<RestoreInfo>>(count);
|
||||
|
||||
if (reader.hasAttribute("hidden")) {
|
||||
std::istringstream iss(reader.getAttribute("hidden"));
|
||||
std::istringstream iss(reader.getAttribute<const char*>("hidden"));
|
||||
int index;
|
||||
while (iss >> index) {
|
||||
if (index >= 0 && index < static_cast<int>(count)) {
|
||||
@@ -5803,18 +5803,18 @@ void PropertyXLinkContainer::Restore(Base::XMLReader& reader)
|
||||
}
|
||||
|
||||
if (reader.hasAttribute("docs")) {
|
||||
auto docCount = reader.getAttributeAsUnsigned("docs");
|
||||
auto docCount = reader.getAttribute<unsigned long>("docs");
|
||||
_DocMap.clear();
|
||||
for (unsigned i = 0; i < docCount; ++i) {
|
||||
reader.readElement("DocMap");
|
||||
auto index = reader.getAttributeAsUnsigned("index");
|
||||
auto index = reader.getAttribute<unsigned long>("index");
|
||||
if (index >= count) {
|
||||
FC_ERR(propertyName(this) << " invalid document map entry");
|
||||
continue;
|
||||
}
|
||||
auto& info = _XLinkRestores->at(index);
|
||||
info.docName = reader.getAttribute("name");
|
||||
info.docLabel = reader.getAttribute("label");
|
||||
info.docName = reader.getAttribute<const char*>("name");
|
||||
info.docLabel = reader.getAttribute<const char*>("label");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -277,13 +277,13 @@ void PropertyPythonObject::restoreObject(Base::XMLReader& reader)
|
||||
try {
|
||||
PropertyContainer* parent = this->getContainer();
|
||||
if (reader.hasAttribute("object")) {
|
||||
if (strcmp(reader.getAttribute("object"), "yes") == 0) {
|
||||
if (strcmp(reader.getAttribute<const char*>("object"), "yes") == 0) {
|
||||
Py::Object obj = Py::asObject(parent->getPyObject());
|
||||
this->object.setAttr("__object__", obj);
|
||||
}
|
||||
}
|
||||
if (reader.hasAttribute("vobject")) {
|
||||
if (strcmp(reader.getAttribute("vobject"), "yes") == 0) {
|
||||
if (strcmp(reader.getAttribute<const char*>("vobject"), "yes") == 0) {
|
||||
Py::Object obj = Py::asObject(parent->getPyObject());
|
||||
this->object.setAttr("__vobject__", obj);
|
||||
}
|
||||
@@ -335,15 +335,15 @@ void PropertyPythonObject::Restore(Base::XMLReader& reader)
|
||||
{
|
||||
reader.readElement("Python");
|
||||
if (reader.hasAttribute("file")) {
|
||||
std::string file(reader.getAttribute("file"));
|
||||
std::string file(reader.getAttribute<const char*>("file"));
|
||||
reader.addFile(file.c_str(), this);
|
||||
}
|
||||
else {
|
||||
bool load_json = false;
|
||||
bool load_pickle = false;
|
||||
bool load_failed = false;
|
||||
std::string buffer = reader.getAttribute("value");
|
||||
if (reader.hasAttribute("encoded") && strcmp(reader.getAttribute("encoded"), "yes") == 0) {
|
||||
std::string buffer = reader.getAttribute<const char*>("value");
|
||||
if (reader.hasAttribute("encoded") && strcmp(reader.getAttribute<const char*>("encoded"), "yes") == 0) {
|
||||
buffer = Base::base64_decode(buffer);
|
||||
}
|
||||
else {
|
||||
@@ -358,15 +358,15 @@ void PropertyPythonObject::Restore(Base::XMLReader& reader)
|
||||
start = buffer.begin();
|
||||
end = buffer.end();
|
||||
if (reader.hasAttribute("module") && reader.hasAttribute("class")) {
|
||||
Py::Module mod(PyImport_ImportModule(reader.getAttribute("module")), true);
|
||||
Py::Module mod(PyImport_ImportModule(reader.getAttribute<const char*>("module")), true);
|
||||
if (mod.isNull()) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
PyObject* cls = mod.getAttr(reader.getAttribute("class")).ptr();
|
||||
PyObject* cls = mod.getAttr(reader.getAttribute<const char*>("class")).ptr();
|
||||
if (!cls) {
|
||||
std::stringstream s;
|
||||
s << "Module " << reader.getAttribute("module") << " has no class "
|
||||
<< reader.getAttribute("class");
|
||||
s << "Module " << reader.getAttribute<const char*>("module") << " has no class "
|
||||
<< reader.getAttribute<const char*>("class");
|
||||
throw Py::AttributeError(s.str());
|
||||
}
|
||||
if (PyType_Check(cls)) {
|
||||
|
||||
@@ -123,7 +123,7 @@ void PropertyInteger::Restore(Base::XMLReader& reader)
|
||||
// read my Element
|
||||
reader.readElement("Integer");
|
||||
// get the value of my Attribute
|
||||
setValue(reader.getAttributeAsInteger("value"));
|
||||
setValue(reader.getAttribute<long>("value"));
|
||||
}
|
||||
|
||||
Property* PropertyInteger::Copy() const
|
||||
@@ -250,7 +250,7 @@ void PropertyPath::Restore(Base::XMLReader& reader)
|
||||
// read my Element
|
||||
reader.readElement("Path");
|
||||
// get the value of my Attribute
|
||||
setValue(reader.getAttribute("value"));
|
||||
setValue(reader.getAttribute<const char*>("value"));
|
||||
}
|
||||
|
||||
Property* PropertyPath::Copy() const
|
||||
@@ -420,18 +420,18 @@ void PropertyEnumeration::Restore(Base::XMLReader& reader)
|
||||
// read my Element
|
||||
reader.readElement("Integer");
|
||||
// get the value of my Attribute
|
||||
long val = reader.getAttributeAsInteger("value");
|
||||
long val = reader.getAttribute<long>("value");
|
||||
|
||||
aboutToSetValue();
|
||||
|
||||
if (reader.hasAttribute("CustomEnum")) {
|
||||
reader.readElement("CustomEnumList");
|
||||
int count = reader.getAttributeAsInteger("count");
|
||||
int count = reader.getAttribute<long>("count");
|
||||
std::vector<std::string> values(count);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
reader.readElement("Enum");
|
||||
values[i] = reader.getAttribute("value");
|
||||
values[i] = reader.getAttribute<const char*>("value");
|
||||
}
|
||||
|
||||
reader.readEndElement("CustomEnumList");
|
||||
@@ -844,12 +844,12 @@ void PropertyIntegerList::Restore(Base::XMLReader& reader)
|
||||
// read my Element
|
||||
reader.readElement("IntegerList");
|
||||
// get the value of my Attribute
|
||||
int count = reader.getAttributeAsInteger("count");
|
||||
int count = reader.getAttribute<long>("count");
|
||||
|
||||
std::vector<long> values(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
reader.readElement("I");
|
||||
values[i] = reader.getAttributeAsInteger("v");
|
||||
values[i] = reader.getAttribute<long>("v");
|
||||
}
|
||||
|
||||
reader.readEndElement("IntegerList");
|
||||
@@ -965,12 +965,12 @@ void PropertyIntegerSet::Restore(Base::XMLReader& reader)
|
||||
// read my Element
|
||||
reader.readElement("IntegerSet");
|
||||
// get the value of my Attribute
|
||||
int count = reader.getAttributeAsInteger("count");
|
||||
int count = reader.getAttribute<long>("count");
|
||||
|
||||
std::set<long> values;
|
||||
for (int i = 0; i < count; i++) {
|
||||
reader.readElement("I");
|
||||
values.insert(reader.getAttributeAsInteger("v"));
|
||||
values.insert(reader.getAttribute<long>("v"));
|
||||
}
|
||||
|
||||
reader.readEndElement("IntegerSet");
|
||||
@@ -1066,7 +1066,7 @@ void PropertyFloat::Restore(Base::XMLReader& reader)
|
||||
// read my Element
|
||||
reader.readElement("Float");
|
||||
// get the value of my Attribute
|
||||
setValue(reader.getAttributeAsFloat("value"));
|
||||
setValue(reader.getAttribute<double>("value"));
|
||||
}
|
||||
|
||||
Property* PropertyFloat::Copy() const
|
||||
@@ -1355,7 +1355,7 @@ void PropertyFloatList::Save(Base::Writer& writer) const
|
||||
void PropertyFloatList::Restore(Base::XMLReader& reader)
|
||||
{
|
||||
reader.readElement("FloatList");
|
||||
string file(reader.getAttribute("file"));
|
||||
string file(reader.getAttribute<const char*>("file"));
|
||||
|
||||
if (!file.empty()) {
|
||||
// initiate a file read
|
||||
@@ -1537,22 +1537,22 @@ void PropertyString::Restore(Base::XMLReader& reader)
|
||||
auto obj = freecad_cast<DocumentObject*>(getContainer());
|
||||
if (obj && &obj->Label == this) {
|
||||
if (reader.hasAttribute("restore")) {
|
||||
int restore = reader.getAttributeAsInteger("restore");
|
||||
int restore = reader.getAttribute<long>("restore");
|
||||
if (restore == 1) {
|
||||
aboutToSetValue();
|
||||
_cValue = reader.getAttribute("value");
|
||||
_cValue = reader.getAttribute<const char*>("value");
|
||||
hasSetValue();
|
||||
}
|
||||
else {
|
||||
setValue(reader.getName(reader.getAttribute("value")));
|
||||
setValue(reader.getName(reader.getAttribute<const char*>("value")));
|
||||
}
|
||||
}
|
||||
else {
|
||||
setValue(reader.getAttribute("value"));
|
||||
setValue(reader.getAttribute<const char*>("value"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
setValue(reader.getAttribute("value"));
|
||||
setValue(reader.getAttribute<const char*>("value"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1692,7 +1692,7 @@ void PropertyUUID::Restore(Base::XMLReader& reader)
|
||||
// read my Element
|
||||
reader.readElement("Uuid");
|
||||
// get the value of my Attribute
|
||||
setValue(reader.getAttribute("value"));
|
||||
setValue(reader.getAttribute<const char*>("value"));
|
||||
}
|
||||
|
||||
Property* PropertyUUID::Copy() const
|
||||
@@ -1808,12 +1808,12 @@ void PropertyStringList::Restore(Base::XMLReader& reader)
|
||||
// read my Element
|
||||
reader.readElement("StringList");
|
||||
// get the value of my Attribute
|
||||
int count = reader.getAttributeAsInteger("count");
|
||||
int count = reader.getAttribute<long>("count");
|
||||
|
||||
std::vector<std::string> values(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
reader.readElement("String");
|
||||
values[i] = reader.getAttribute("value");
|
||||
values[i] = reader.getAttribute<const char*>("value");
|
||||
}
|
||||
|
||||
reader.readEndElement("StringList");
|
||||
@@ -1969,12 +1969,12 @@ void PropertyMap::Restore(Base::XMLReader& reader)
|
||||
// read my Element
|
||||
reader.readElement("Map");
|
||||
// get the value of my Attribute
|
||||
int count = reader.getAttributeAsInteger("count");
|
||||
int count = reader.getAttribute<long>("count");
|
||||
|
||||
std::map<std::string, std::string> values;
|
||||
for (int i = 0; i < count; i++) {
|
||||
reader.readElement("Item");
|
||||
values[reader.getAttribute("key")] = reader.getAttribute("value");
|
||||
values[reader.getAttribute<const char*>("key")] = reader.getAttribute<const char*>("value");
|
||||
}
|
||||
|
||||
reader.readEndElement("Map");
|
||||
@@ -2064,7 +2064,7 @@ void PropertyBool::Restore(Base::XMLReader& reader)
|
||||
// read my Element
|
||||
reader.readElement("Bool");
|
||||
// get the value of my Attribute
|
||||
string b = reader.getAttribute("value");
|
||||
string b = reader.getAttribute<const char*>("value");
|
||||
(b == "true") ? setValue(true) : setValue(false);
|
||||
}
|
||||
|
||||
@@ -2193,7 +2193,7 @@ void PropertyBoolList::Restore(Base::XMLReader& reader)
|
||||
// read my Element
|
||||
reader.readElement("BoolList");
|
||||
// get the value of my Attribute
|
||||
string str = reader.getAttribute("value");
|
||||
string str = reader.getAttribute<const char*>("value");
|
||||
boost::dynamic_bitset<> bitset(str);
|
||||
setValues(bitset);
|
||||
}
|
||||
@@ -2360,7 +2360,7 @@ void PropertyColor::Restore(Base::XMLReader& reader)
|
||||
// read my Element
|
||||
reader.readElement("PropertyColor");
|
||||
// get the value of my Attribute
|
||||
unsigned long rgba = reader.getAttributeAsUnsigned("value");
|
||||
unsigned long rgba = reader.getAttribute<unsigned long>("value");
|
||||
setValue(rgba);
|
||||
}
|
||||
|
||||
@@ -2436,7 +2436,7 @@ void PropertyColorList::Restore(Base::XMLReader& reader)
|
||||
{
|
||||
reader.readElement("ColorList");
|
||||
if (reader.hasAttribute("file")) {
|
||||
std::string file(reader.getAttribute("file"));
|
||||
std::string file(reader.getAttribute<const char*>("file"));
|
||||
|
||||
if (!file.empty()) {
|
||||
// initiate a file read
|
||||
@@ -2690,20 +2690,20 @@ void PropertyMaterial::Restore(Base::XMLReader& reader)
|
||||
reader.readElement("PropertyMaterial");
|
||||
// get the value of my Attribute
|
||||
aboutToSetValue();
|
||||
_cMat.ambientColor.setPackedValue(reader.getAttributeAsUnsigned("ambientColor"));
|
||||
_cMat.diffuseColor.setPackedValue(reader.getAttributeAsUnsigned("diffuseColor"));
|
||||
_cMat.specularColor.setPackedValue(reader.getAttributeAsUnsigned("specularColor"));
|
||||
_cMat.emissiveColor.setPackedValue(reader.getAttributeAsUnsigned("emissiveColor"));
|
||||
_cMat.shininess = (float)reader.getAttributeAsFloat("shininess");
|
||||
_cMat.transparency = (float)reader.getAttributeAsFloat("transparency");
|
||||
_cMat.ambientColor.setPackedValue(reader.getAttribute<unsigned long>("ambientColor"));
|
||||
_cMat.diffuseColor.setPackedValue(reader.getAttribute<unsigned long>("diffuseColor"));
|
||||
_cMat.specularColor.setPackedValue(reader.getAttribute<unsigned long>("specularColor"));
|
||||
_cMat.emissiveColor.setPackedValue(reader.getAttribute<unsigned long>("emissiveColor"));
|
||||
_cMat.shininess = (float)reader.getAttribute<double>("shininess");
|
||||
_cMat.transparency = (float)reader.getAttribute<double>("transparency");
|
||||
if (reader.hasAttribute("image")) {
|
||||
_cMat.image = reader.getAttribute("image");
|
||||
_cMat.image = reader.getAttribute<const char*>("image");
|
||||
}
|
||||
if (reader.hasAttribute("imagePath")) {
|
||||
_cMat.imagePath = reader.getAttribute("imagePath");
|
||||
_cMat.imagePath = reader.getAttribute<const char*>("imagePath");
|
||||
}
|
||||
if (reader.hasAttribute("uuid")) {
|
||||
_cMat.uuid = reader.getAttribute("uuid");
|
||||
_cMat.uuid = reader.getAttribute<const char*>("uuid");
|
||||
}
|
||||
hasSetValue();
|
||||
}
|
||||
@@ -3232,9 +3232,9 @@ void PropertyMaterialList::Restore(Base::XMLReader& reader)
|
||||
{
|
||||
reader.readElement("MaterialList");
|
||||
if (reader.hasAttribute("file")) {
|
||||
std::string file(reader.getAttribute("file"));
|
||||
std::string file(reader.getAttribute<const char*>("file"));
|
||||
if (reader.hasAttribute("version")) {
|
||||
formatVersion = static_cast<Format>(reader.getAttributeAsInteger("version"));
|
||||
formatVersion = static_cast<Format>(reader.getAttribute<long>("version"));
|
||||
}
|
||||
|
||||
if (!file.empty()) {
|
||||
|
||||
@@ -790,24 +790,24 @@ void StringHasher::Restore(Base::XMLReader& reader)
|
||||
{
|
||||
clear();
|
||||
reader.readElement("StringHasher");
|
||||
_hashes->SaveAll = reader.getAttributeAsInteger("saveall") != 0L;
|
||||
_hashes->Threshold = static_cast<int>(reader.getAttributeAsInteger("threshold"));
|
||||
_hashes->SaveAll = reader.getAttribute<long>("saveall") != 0L;
|
||||
_hashes->Threshold = reader.getAttribute<int>("threshold");
|
||||
|
||||
bool newTag = false;
|
||||
if (reader.hasAttribute("new") && reader.getAttributeAsInteger("new") > 0) {
|
||||
if (reader.hasAttribute("new") && reader.getAttribute<bool>("new")) {
|
||||
reader.readElement("StringHasher2");
|
||||
newTag = true;
|
||||
}
|
||||
|
||||
if (reader.hasAttribute("file")) {
|
||||
const char* file = reader.getAttribute("file");
|
||||
const char* file = reader.getAttribute<const char*>("file");
|
||||
if (*file != '\0') {
|
||||
reader.addFile(file, this);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
std::size_t count = reader.getAttributeAsUnsigned("count");
|
||||
std::size_t count = reader.getAttribute<unsigned long>("count");
|
||||
if (newTag) {
|
||||
try {
|
||||
restoreStreamNew(reader.beginCharStream(), count);
|
||||
@@ -826,15 +826,15 @@ void StringHasher::Restore(Base::XMLReader& reader)
|
||||
for (std::size_t i = 0; i < count; ++i) {
|
||||
reader.readElement("Item");
|
||||
StringIDRef sid;
|
||||
long id = reader.getAttributeAsInteger("id");
|
||||
long id = reader.getAttribute<long>("id");
|
||||
bool hashed = reader.hasAttribute("hash");
|
||||
if (hashed || reader.hasAttribute("data")) {
|
||||
const char* value =
|
||||
hashed ? reader.getAttribute("hash") : reader.getAttribute("data");
|
||||
hashed ? reader.getAttribute<const char*>("hash") : reader.getAttribute<const char*>("data");
|
||||
sid = new StringID(id, QByteArray::fromBase64(value), StringID::Flag::Hashed);
|
||||
}
|
||||
else {
|
||||
sid = new StringID(id, QByteArray(reader.getAttribute("text")));
|
||||
sid = new StringID(id, QByteArray(reader.getAttribute<const char*>("text")));
|
||||
}
|
||||
insert(sid);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user