summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <daniel.goodliffe@pressassociation.com>2015-01-07 12:32:55 +0000
committerDan Goodliffe <daniel.goodliffe@pressassociation.com>2015-01-07 12:32:55 +0000
commita5d646deae167491caf88785640beaee5c2058f9 (patch)
treed4fbfdb949ca3fbcbfd82f30ed4721414df75d93
parentAdd support, tests and test data for struct roots (diff)
downloadslicer-a5d646deae167491caf88785640beaee5c2058f9.tar.bz2
slicer-a5d646deae167491caf88785640beaee5c2058f9.tar.xz
slicer-a5d646deae167491caf88785640beaee5c2058f9.zip
Fix xml serializer modeltreeiterateroot to work the same as iterate element part
-rw-r--r--slicer/xml/serializer.cpp26
-rw-r--r--slicer/xml/serializer.h3
2 files changed, 18 insertions, 11 deletions
diff --git a/slicer/xml/serializer.cpp b/slicer/xml/serializer.cpp
index 85fe99e..f7281b3 100644
--- a/slicer/xml/serializer.cpp
+++ b/slicer/xml/serializer.cpp
@@ -218,23 +218,27 @@ namespace Slicer {
mp->GetValue(new XmlAttributeValueTarget(n, name));
}
else if (mp) {
- auto element = n->add_child(name);
- auto typeIdPropName = mp->GetTypeIdProperty();
- auto typeId = mp->GetTypeId();
- if (typeId && typeIdPropName) {
- element->set_attribute(*typeIdPropName, *typeId);
- mp = mp->GetSubclassModelPart(*typeId);
- }
- mp->GetValue(new XmlContentValueTarget(element));
- mp->OnEachChild(boost::bind(&XmlSerializer::ModelTreeIterate, element, _1, _2, _3));
+ ModelTreeProcessElement(n->add_child(name), mp);
+ }
+ }
+
+ void
+ XmlSerializer::ModelTreeProcessElement(xmlpp::Element * element, ModelPartPtr mp)
+ {
+ auto typeIdPropName = mp->GetTypeIdProperty();
+ auto typeId = mp->GetTypeId();
+ if (typeId && typeIdPropName) {
+ element->set_attribute(*typeIdPropName, *typeId);
+ mp = mp->GetSubclassModelPart(*typeId);
}
+ mp->GetValue(new XmlContentValueTarget(element));
+ mp->OnEachChild(boost::bind(&XmlSerializer::ModelTreeIterate, element, _1, _2, _3));
}
void
XmlSerializer::ModelTreeIterateRoot(xmlpp::Document * doc, const std::string & name, ModelPartPtr mp)
{
- auto root = doc->create_root_node(name);
- mp->OnEachChild(boost::bind(&XmlSerializer::ModelTreeIterate, root, _1, _2, _3));
+ ModelTreeProcessElement(doc->create_root_node(name), mp);
}
XmlFileSerializer::XmlFileSerializer(const boost::filesystem::path & p) :
diff --git a/slicer/xml/serializer.h b/slicer/xml/serializer.h
index 4e37eed..5b738ca 100644
--- a/slicer/xml/serializer.h
+++ b/slicer/xml/serializer.h
@@ -9,6 +9,9 @@ namespace Slicer {
protected:
static void ModelTreeIterate(xmlpp::Element *, const std::string &, ModelPartPtr mp, HookCommonPtr hp);
static void ModelTreeIterateRoot(xmlpp::Document *, const std::string &, ModelPartPtr mp);
+
+ private:
+ static void ModelTreeProcessElement(xmlpp::Element * n, ModelPartPtr mp);
};
class XmlFileSerializer : public XmlSerializer {