diff options
author | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2015-04-09 16:48:40 +0200 |
---|---|---|
committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2016-04-25 22:19:35 +0200 |
commit | 07f5bd313bd08aa8c0193c832b9219f72f2704f7 (patch) | |
tree | 6c28f685d29a98186062466667f15ea3955c6f37 /src | |
parent | b6aefe3e510766001415cf711fbf21ae465e4657 (diff) |
added support for typesystem constants in serialization.
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/xml/XmlOutput.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/plugins/xml/XmlOutput.cpp b/src/plugins/xml/XmlOutput.cpp index e67ec19..80b3af5 100644 --- a/src/plugins/xml/XmlOutput.cpp +++ b/src/plugins/xml/XmlOutput.cpp @@ -514,6 +514,23 @@ static Rooted<Element> transformEnumType(Handle<Element> parent, return enumType; } +static Rooted<Element> transformConstant(Handle<Element> parent, + Handle<Typesystem> t, + Handle<Constant> c, TransformParams &P) +{ + // create an xml element for the constant. + Rooted<Element> constant{new Element(P.mgr, parent, "constant")}; + addNameAttribute(c, constant->getAttributes()); + // add the type reference + { + std::string typeRef = getTypeRef(t, c->getType()); + constant->getAttributes().emplace("type", typeRef); + } + // add the value + constant->getAttributes().emplace("value", toString(c->getValue(), P)); + return constant; +} + Rooted<Element> transformTypesystem(Handle<Element> parent, Handle<Typesystem> t, TransformParams &P) { @@ -560,6 +577,11 @@ Rooted<Element> transformTypesystem(Handle<Element> parent, typesystem->addChild(type); } } + // transform all constants. + for (auto c : t->getConstants()) { + Rooted<Element> constant = transformConstant(typesystem, t, c, P); + typesystem->addChild(constant); + } // return the transformed Ontology. return typesystem; } |