summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 {