From e06319c7261d4189e8bcef16ed50b9739e6e13a5 Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Wed, 27 Nov 2013 18:30:37 +0100 Subject: [PATCH] add more convenient deserializers for Qt based classes --- woc/qt/qtclass.cpp | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/woc/qt/qtclass.cpp b/woc/qt/qtclass.cpp index 26ae801..d22c98b 100644 --- a/woc/qt/qtclass.cpp +++ b/woc/qt/qtclass.cpp @@ -348,6 +348,14 @@ void WocQtClass::classDeserializer(const WocClass&cls,MFile&hdr,MFile&src,QStrin } } scd+="}\n"; + hcd+="\t///create "+cn+" from XML (inverse of toXml)\n"; + hcd+="\tstatic "+cn+" fromXml(const QDomElement&);\n"; + scd+=cn+" "+cn+"::fromXml(const QDomElement&root){return "+cn+"(root);}\n"; + hcd+="\t///create "+cn+" from XML formatted string (inverse of toString)\n"; + hcd+="\tstatic "+cn+" fromString(const QString&);\n"; + scd+=cn+" "+cn+"::fromString(const QString&txt)\n{\n\tQDomDocument doc;\n"; + scd+="\tif(!doc.setContent(txt))return "+cn+"();\n"; + scd+="\telse return "+cn+"(doc.documentElement());\n}\n"; hcd+="\t/// destructor: deletes this copy of the object\n"; hcd+="\tvirtual ~"+cn+"(){}\n"; -- 1.7.2.5