summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-04-09 16:31:49 +0200
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2016-04-25 22:19:35 +0200
commitb6aefe3e510766001415cf711fbf21ae465e4657 (patch)
tree0ea757e041a2c30b21f60204a93f5d69510aa2e7 /src/plugins
parent353b2fa76fba37b3ff0b73e23a2e422897ef876a (diff)
added enum type support for serialization.
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/xml/XmlOutput.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/plugins/xml/XmlOutput.cpp b/src/plugins/xml/XmlOutput.cpp
index 734c3a5..e67ec19 100644
--- a/src/plugins/xml/XmlOutput.cpp
+++ b/src/plugins/xml/XmlOutput.cpp
@@ -497,6 +497,23 @@ Rooted<Element> transformStructType(Handle<Element> parent,
}
return structType;
}
+
+static Rooted<Element> transformEnumType(Handle<Element> parent,
+ Handle<EnumType> e, TransformParams &P)
+{
+ // create an xml element for the enum type itself.
+ Rooted<Element> enumType{new Element(P.mgr, parent, "enum")};
+ addNameAttribute(e, enumType->getAttributes());
+ // add all entries.
+ for (std::string &name : e->names()) {
+ Rooted<Element> enumEntry{new Element(P.mgr, enumType, "entry")};
+ enumType->addChild(enumEntry);
+ Rooted<Text> enumName{new Text(P.mgr, enumEntry, name)};
+ enumEntry->addChild(enumName);
+ }
+ return enumType;
+}
+
Rooted<Element> transformTypesystem(Handle<Element> parent,
Handle<Typesystem> t, TransformParams &P)
{
@@ -532,6 +549,8 @@ Rooted<Element> transformTypesystem(Handle<Element> parent,
if (tp->isa(&RttiTypes::StructType)) {
type = transformStructType(typesystem, "struct", "field",
tp.cast<StructType>(), P);
+ } else if (tp->isa(&RttiTypes::EnumType)) {
+ type = transformEnumType(typesystem, tp.cast<EnumType>(), P);
} else {
P.logger.warning(std::string("Type ") + tp->getName() +
" can not be serialized, because it is neither a "