From 5bfde97c13821a6eecf0828c39c5f0f35552776e Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Thu, 16 Apr 2015 01:06:25 +0200 Subject: Made all functions in XMLOutput static and added TODO regarding restructuring the code --- src/plugins/xml/XmlOutput.cpp | 68 ++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/src/plugins/xml/XmlOutput.cpp b/src/plugins/xml/XmlOutput.cpp index fc86350..e1703c4 100644 --- a/src/plugins/xml/XmlOutput.cpp +++ b/src/plugins/xml/XmlOutput.cpp @@ -27,6 +27,9 @@ namespace ousia { namespace xml { +// TODO: Use impl class to avoid having to pass so many parameters to static +// functions (like e.g. in UniqueIdTransformation.cpp) + /** * Wrapper structure for transformation parameters. */ @@ -409,8 +412,8 @@ static Rooted transformAnnotationClass(Handle parent, return annotationClass; } -Rooted transformOntology(Handle parent, Handle o, - TransformParams &P) +static Rooted transformOntology(Handle parent, + Handle o, TransformParams &P) { // only transform this ontology if it was not transformed already. if (o->getLocation().getSourceId() != P.documentId) { @@ -462,7 +465,8 @@ Rooted transformOntology(Handle parent, Handle o, * Typesystem transformation functions. */ -std::string getTypeRef(Handle referencing, Handle referenced) +static std::string getTypeRef(Handle referencing, + Handle referenced) { std::string typeRef; if (referencing != referenced->getTypesystem() && @@ -476,11 +480,11 @@ std::string getTypeRef(Handle referencing, Handle referenced) return typeRef; } -Rooted transformStructTypeEntry(Handle parent, - const std::string &tagName, - Handle t, - Handle a, - TransformParams &P) +static Rooted transformStructTypeEntry(Handle parent, + const std::string &tagName, + Handle t, + Handle a, + TransformParams &P) { // create an xml element for the attribute. Rooted attribute{new Element(P.mgr, parent, tagName)}; @@ -500,10 +504,11 @@ Rooted transformStructTypeEntry(Handle parent, return attribute; } -Rooted transformStructType(Handle parent, - const std::string &structTagName, - const std::string &fieldTagName, - Handle t, TransformParams &P) +static Rooted transformStructType(Handle parent, + const std::string &structTagName, + const std::string &fieldTagName, + Handle t, + TransformParams &P) { // create an xml element for the struct type itself. Rooted structType{new Element(P.mgr, parent, structTagName)}; @@ -556,8 +561,9 @@ static Rooted transformConstant(Handle parent, return constant; } -Rooted transformTypesystem(Handle parent, - Handle t, TransformParams &P) +static Rooted transformTypesystem(Handle parent, + Handle t, + TransformParams &P) { // do not transform the system typesystem. if (t->isa(&RttiTypes::SystemTypesystem)) { @@ -615,9 +621,8 @@ Rooted transformTypesystem(Handle parent, * DocumentEntity attributes transform functions. */ -std::map transformAttributes(const std::string &name, - DocumentEntity *entity, - TransformParams &P) +static std::map transformAttributes( + const std::string &name, DocumentEntity *entity, TransformParams &P) { // copy the attributes. Variant attrs = entity->getAttributes(); @@ -642,8 +647,8 @@ std::map transformAttributes(const std::string &name, return xmlAttrs; } -void addNameAttribute(Handle n, - std::map &attrs) +static void addNameAttribute(Handle n, + std::map &attrs) { // copy the name attribute. if (!n->getName().empty()) { @@ -655,9 +660,8 @@ void addNameAttribute(Handle n, * StructureNode transform functions. */ -void transformChildren(DocumentEntity *parentEntity, Handle parent, - - TransformParams &P) +static void transformChildren(DocumentEntity *parentEntity, + Handle parent, TransformParams &P) { ManagedVector fieldDescs = parentEntity->getDescriptor()->getFieldDescriptors(); @@ -706,22 +710,24 @@ void transformChildren(DocumentEntity *parentEntity, Handle parent, } } -Rooted transformStructuredEntity(Handle parent, - Handle s, - TransformParams &P) +static Rooted transformStructuredEntity(Handle parent, + Handle s, + TransformParams &P) { // create the XML element itself. Rooted elem{new Element{ P.mgr, parent, s->getDescriptor()->getName(), transformAttributes(s->getName(), s.get(), P), s->getDescriptor()->getParent().cast()->getName()}}; + attachId(elem, s); + // then transform the children. transformChildren(s.get(), elem, P); return elem; } -Rooted transformAnchor(Handle parent, Handle a, - TransformParams &P) +static Rooted transformAnchor(Handle parent, Handle a, + TransformParams &P) { Rooted elem; if (a->isStart()) { @@ -757,7 +763,7 @@ Rooted transformAnchor(Handle parent, Handle a, * Primitive transform functions. */ -std::string toString(Variant v, TransformParams &P) +static std::string toString(Variant v, TransformParams &P) { if (v.isString()) { return v.asString(); @@ -766,8 +772,10 @@ std::string toString(Variant v, TransformParams &P) } } -Rooted transformPrimitive(Handle parent, Handle type, - Handle p, TransformParams &P) +static Rooted transformPrimitive(Handle parent, + Handle type, + Handle p, + TransformParams &P) { // transform the primitive content. Variant content = p->getContent(); -- cgit v1.2.3