From: konrad Date: Fri, 24 Dec 2010 22:21:46 +0000 (+0000) Subject: fix inheritance of classes X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=6fe9814fa16b6dd1b59c3eddecbfe0e9735157bb;p=web%2Fkonrad%2Fpack.git fix inheritance of classes git-svn-id: https://silmor.de/svn/softmagic/pack/trunk@668 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/phpbase/db.php b/phpbase/db.php index 3709102..becc0e9 100644 --- a/phpbase/db.php +++ b/phpbase/db.php @@ -477,6 +477,7 @@ abstract class DbEngine $res=$this->select($tab,"*","1=1"); foreach($res as $row){ foreach($cols as $col){ + if(!array_key_exists($col,$row))continue; $val=$row[$col]; $ret.="value $col ".$this->escapeBackup($tab,$col,$val)."\n"; } diff --git a/phpbase/object.php b/phpbase/object.php index ea4a937..bd3dd0a 100644 --- a/phpbase/object.php +++ b/phpbase/object.php @@ -11,6 +11,15 @@ class WObject { protected function __construct(){} + + ///base for deserialization + static protected function fromXmlHelper($data,$xml,$elem){} + + ///base for serialization + protected function toXmlHelper($xml,$root){} + + ///base for property array + public function propertyArray(){return array();} /**helper function that returns only the elements directly beneith the one given as $root*/ public static function elementsByTagName($root,$tag) diff --git a/qtbase/include/object.h b/qtbase/include/object.h index 5949283..00af35d 100644 --- a/qtbase/include/object.h +++ b/qtbase/include/object.h @@ -30,6 +30,12 @@ class WObject:public WHelper { protected: WObject(){} + WObject(const WObject&){} + WObject(const QDomElement&){} + virtual ~WObject(){} + virtual QDomElement toXml(QDomDocument&,QString name="Object"); + virtual WObject& operator=(const WObject&){return *this;} + virtual void toXml(QDomDocument&,QDomElement&){} }; /**this exception is thrown if the deserialization of an object fails on the XML parser level*/ diff --git a/qtbase/src/object.cpp b/qtbase/src/object.cpp index eb0f93d..49f3dcd 100644 --- a/qtbase/src/object.cpp +++ b/qtbase/src/object.cpp @@ -12,8 +12,13 @@ #include "WObject" -//do at least something useful #include "Nullable" +#include + +QDomElement WObject::toXml(QDomDocument&doc,QString name) +{ + return doc.createElement(name); +} static int itype0= qRegisterMetaType >()+ diff --git a/woc/php/phpclass.cpp b/woc/php/phpclass.cpp index 1a9f0a1..c8bf7df 100644 --- a/woc/php/phpclass.cpp +++ b/woc/php/phpclass.cpp @@ -143,7 +143,7 @@ QString WocPHPClass::classPropertiesList(const WocClass&cls) { QString code; QStringList k=cls.propertyNames(); - code+="public function propertyArray(){\n\treturn array("; + code+="public function propertyArray(){\n\treturn array_merge(parent::propertyArray(),array("; for(int i=0;i"; @@ -164,7 +164,7 @@ QString WocPHPClass::classPropertiesList(const WocClass&cls) code+="$this->prop_"+k[i]; } } - code+=");\n}\n"; + code+="));\n}\n"; return code; } @@ -401,12 +401,16 @@ QString WocPHPClass::classSerializers(const WocClass&cls) //toXml function: code+="public function toXml($xml,$elementname=\""+cls.name()+"\"){\n"; code+="\t$root=$xml->createElement($elementname);\n"; + code+="\t$this->toXmlHelper($xml,$root);\n"; + code+="\treturn $root;\n}\n"; + //toXmlHelper function: + code+="protected function toXmlHelper($xml,$root){\n"; + code+="\tparent::toXmlHelper($xml,$root);\n"; //add properties QStringList p=cls.propertyNames(); for(int j=0;j\n\n"; + hcd="#include \""+cls.baseClass(m_lang,m_prefix+"O")+"\"\n#include \n\n"; QStringList k=cls.propertyNames(); for(int i=0;i