add more convenient deserializers for Qt based classes
authorKonrad Rosenbaum <konrad@silmor.de>
Wed, 27 Nov 2013 17:30:37 +0000 (18:30 +0100)
committerKonrad Rosenbaum <konrad@silmor.de>
Wed, 27 Nov 2013 17:30:37 +0000 (18:30 +0100)
woc/qt/qtclass.cpp

index 26ae801..d22c98b 100644 (file)
@@ -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";