From b6aefe3e510766001415cf711fbf21ae465e4657 Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Thu, 9 Apr 2015 16:31:49 +0200 Subject: added enum type support for serialization. --- src/plugins/xml/XmlOutput.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src') 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 transformStructType(Handle parent, } return structType; } + +static Rooted transformEnumType(Handle parent, + Handle e, TransformParams &P) +{ + // create an xml element for the enum type itself. + Rooted enumType{new Element(P.mgr, parent, "enum")}; + addNameAttribute(e, enumType->getAttributes()); + // add all entries. + for (std::string &name : e->names()) { + Rooted enumEntry{new Element(P.mgr, enumType, "entry")}; + enumType->addChild(enumEntry); + Rooted enumName{new Text(P.mgr, enumEntry, name)}; + enumEntry->addChild(enumName); + } + return enumType; +} + Rooted transformTypesystem(Handle parent, Handle t, TransformParams &P) { @@ -532,6 +549,8 @@ Rooted transformTypesystem(Handle parent, if (tp->isa(&RttiTypes::StructType)) { type = transformStructType(typesystem, "struct", "field", tp.cast(), P); + } else if (tp->isa(&RttiTypes::EnumType)) { + type = transformEnumType(typesystem, tp.cast(), P); } else { P.logger.warning(std::string("Type ") + tp->getName() + " can not be serialized, because it is neither a " -- cgit v1.2.3