////
//generate code
QString code="class "+cna+" extends "+cls.baseClass()+"{\n\n";
+ tf.write(code.toAscii());
+
+ //enums
+ tf.write(classEnums(cls).toAscii());
+
+ //properties
+ tf.write(classProperties(cls).toAscii());
+
+ //mappings
+ tf.write(classMappings(cls).toAscii());
- //implement enums
+ //serializers
+ tf.write(classSerializers(cls).toAscii());
+
+ //de-serializer
+ tf.write(classDeserializers(cls,cn).toAscii());
+
+ //end of class
+ code="\n//end of class\n};\n";
+ tf.write(code.toAscii());
+
+ tf.write(PHPEND);
+ tf.close();
+}
+
+QString WocPHPServerOut::classEnums(const WocClass&cls)
+{
+ QString code;
QStringList k=cls.enumTypes();
for(int i=0;i<k.size();i++){
code+="//enum "+k[i]+"\n";
for(int j=0;j<ev.size();j++)
code+="const "+ev[j].first+"="+QString::number(ev[j].second)+";\n";
}
-
- //implement properties
- k=cls.propertyNames();
+ return code;
+}
+
+QString WocPHPServerOut::classProperties(const WocClass&cls)
+{
+ QString code;
+ QStringList k=cls.propertyNames();
for(int i=0;i<k.size();i++){
code+="\nprotected $prop_"+k[i]+";\n";
//generate validator
- code+="static public function validate"+k[i]+"($value){\n";
- if(cls.propertyIsEnum(k[i])){
- QList<QPair<QString,int> >ev=cls.enumValues(cls.propertyPlainType(k[i]));
- code+="\tif(is_numeric($value)){\n\t\t$value=$value+0;\n";
- for(int j=0;j<ev.size();j++){
- code+="\t\tif($value=="+QString::number(ev[j].second)+")return true;\n";
- }
- code+="\t\treturn false;\n\t}else{\n";
- for(int j=0;j<ev.size();j++){
- code+="\t\tif($value==\""+ev[j].first+"\")return true;\n";
- }
- code+="\t\treturn false;\n\t}\n";
- }else
- if(cls.propertyIsInt(k[i]))
- code+="\treturn is_numeric($value);\n";
- else
- if(cls.propertyIsString(k[i]))
- code+="\treturn true;\n";//TODO: special handling for astring
- else
- if(cls.propertyIsObject(k[i]))
- code+="\treturn is_a($value,\"WO"+cls.propertyPlainType(k[i])+"\");\n";
- else{
- qDebug("Warning: unable to generate validator for class %s property %s: unknown type.",cls.name().toAscii().data(),k[i].toAscii().data());
- code+="\treturn false;\n";
- }
- code+="}\n";
+ code+=classPropertyValidator(cls,k[i]);
//generic getter
code+="public function get_"+k[i]+"(){return $this->prop_"+k[i]+";}\n";
+ //is it a list?
if(cls.propertyIsList(k[i])){
//lists...
//getters
- if(cls.propertyIsString(k[i]))code+="public function getstrlist_"+k[i]+"(){return $this->prop_"+k[i]+";}\n";
- else
- if(cls.propertyIsInt(k[i])){
- code+="public function getstrlist_"+k[i]+"(){\n";
- code+="\t$ret=array();\n\tforeach($this->prop_"+k[i]+" as $p)$ret[]=\"\".$p;\n";
- code+="\treturn $ret;\n}\n";
- }else
- if(cls.propertyIsEnum(k[i])){
- code+="public function getstrlist_"+k[i]+"(){\n";
- code+="\t$ret=array();\n";
- code+="\tforeach($this->prop_"+k[i]+" as $p)switch($p){\n";
- QList<QPair<QString,int> > ev=cls.enumValues(cls.propertyPlainType(k[i]));
- for(int j=0;j<ev.size();j++){
- code+="\t\tcase "+QString::number(ev[j].second)+":$ret[]=\""+ev[j].first+"\";break;\n";
- }
- code+="\t\tdefault:$ret[]=null;break;\n\t}\n\treturn $ret;\n}\n";
- }
+ code+=classPropertyListGetters(cls,k[i]);
//setters
- code+="public function clear_"+k[i]+"(){$this->prop_"+k[i]+"=array();}\n";
- QString acode;//body of add_ function, see below
- code+="public function set_"+k[i]+"(array $values){\n";
- if(cls.propertyIsEnum(k[i])){
- QList<QPair<QString,int> >ev=cls.enumValues(cls.propertyPlainType(k[i]));
- code+="\t$prop=array();\n";
- code+="\tforeach($values as $value){\n";
- code+="\t\tif(is_numeric($value)){\n\t\t\t$value=$value+0;\n";
- acode+="\tif(is_numeric($value)){\n\t\t$value=$value+0;\n";
- for(int j=0;j<ev.size();j++){
- code+="\t\t\tif($value=="+QString::number(ev[j].second)+"){\n";
- code+="\t\t\t\t$prop[]="+QString::number(ev[j].second)+";\n";
- code+="\t\t\t}else\n";
- acode+="\t\tif($value=="+QString::number(ev[j].second)+"){\n";
- acode+="\t\t\t$this->prop_"+k[i]+"[]="+QString::number(ev[j].second)+";\n";
- acode+="\t\t\treturn true;\n\t\t}\n";
- }
- code+="\t\t\treturn false;\n\t\t}else{\n";
- acode+="\t\treturn false;\n\t}else{\n";
- for(int j=0;j<ev.size();j++){
- code+="\t\t\tif($value==\""+ev[j].first+"\"){\n";
- code+="\t\t\t\t$prop[]="+QString::number(ev[j].second)+";\n";
- code+="\n\t\t\t}else\n";
- acode+="\t\tif($value==\""+ev[j].first+"\"){\n";
- acode+="\t\t\t$this->prop_"+k[i]+"[]="+QString::number(ev[j].second)+";\n";
- acode+="\t\t\treturn true;\n\t\t}\n";
- }
- code+="\t\t\treturn false;\n\t\t}\n\t}\n";
- code+="\t$this->prop_"+k[i]+"=$prop;\n";
- code+="\treturn true;\n";
- acode+="\t\treturn false;\n\t}\n";
- }else
- if(cls.propertyIsInt(k[i])){
- code+="\t$prop=array();\n\tforeach($values as $value)\n";
- code+="\t\tif(is_numeric($value)){\n\t\t\t$prop=0+$value;\n\t\t}else return false;\n";
- code+="\t$this->prop_"+k[i]+"=$prop;\n\treturn true;\n";
- acode+="\tif(is_numeric($value)){\n";
- acode+="\t\t$this->prop_"+k[i]+"=0+$value;\n\t\treturn true;\n\t}else return false;\n";
- }else
- if(cls.propertyIsString(k[i])){
- code+="\t$prop=array();\n\tforeach($values as $value)$prop[]=\"\".$value;\n";
- code+="\t$this->prop_"+k[i]+"=$prop;\n\treturn true;\n";
- //TODO: special handling for astring
- acode+="\t$this->prop_"+k[i]+"[]=\"\".$value;\n\treturn true;\n";
- }else
- if(cls.propertyIsObject(k[i])){
- code+="\t$prop=array();\n\tforeach($values as $value)\n";
- code+="\t\tif(is_a($value,\"WO"+cls.propertyPlainType(k[i])+"\"))\n";
- code+="\t\t\t$prop[]=$value;\n";
- code+="\t\telse return false;\n";
- code+="\t$this->prop_"+k[i]+"=$prop;\n";
- code+="\treturn true;\n";
- acode+="\tif(is_a($value,\"WO"+cls.propertyPlainType(k[i])+"\")){\n";
- acode+="\t\t$this->prop_"+k[i]+"[]=$value;\n";
- acode+="\t\treturn true;\n";
- acode+="\t}else return false;\n";
- }else{
- qDebug("Warning: unable to generate setter for class %s property %s: unknown type.",cls.name().toAscii().data(),k[i].toAscii().data());
- code+="\treturn false;\n";
- }
- code+="}\n";
- code+="public function add_"+k[i]+"($value){\n"+acode+"}\n";
+ code+=classPropertyListSetters(cls,k[i]);
}else{
//non-lists...
//getters
- if(cls.propertyIsString(k[i]))code+="public function getstr_"+k[i]+"(){return $this->prop_"+k[i]+";}\n";
- else
- if(cls.propertyIsInt(k[i]))code+="public function getstr_"+k[i]+"(){return \"\".$this->prop_"+k[i]+";}\n";
- else
- if(cls.propertyIsEnum(k[i])){
- code+="public function getstr_"+k[i]+"(){\n\tswitch($this->prop_"+k[i]+"){\n";
- QList<QPair<QString,int> > ev=cls.enumValues(cls.propertyPlainType(k[i]));
- for(int j=0;j<ev.size();j++){
- code+="\t\tcase "+QString::number(ev[j].second)+":return \""+ev[j].first+"\";\n";
- }
- code+="\t\tdefault:return null;\n\t}\n}\n";
- }
+ code+=classPropertyScalarGetters(cls,k[i]);
//setter
- code+="public function set_"+k[i]+"($value){\n";
- if(cls.propertyIsEnum(k[i])){
- QList<QPair<QString,int> >ev=cls.enumValues(cls.propertyPlainType(k[i]));
- code+="\tif(is_numeric($value)){\n\t\t$value=$value+0;\n";
- for(int j=0;j<ev.size();j++){
- code+="\t\tif($value=="+QString::number(ev[j].second)+"){\n";
- code+="\t\t\t$this->prop_"+k[i]+"="+QString::number(ev[j].second)+";\n";
- code+="\t\t\treturn true;\n\t\t}\n";
- }
- code+="\t\treturn false;\n\t}else{\n";
- for(int j=0;j<ev.size();j++){
- code+="\t\tif($value==\""+ev[j].first+"\"){\n";
- code+="\t\t\t$this->prop_"+k[i]+"="+QString::number(ev[j].second)+";\n";
- code+="\t\t\treturn true;\n\t\t}\n";
- }
- code+="\t\treturn false;\n\t}\n";
- }else
- if(cls.propertyIsInt(k[i]))
- code+="\tif(is_numeric($value)){\n\t\t$this->prop_"+k[i]+"=0+$value;\n\t\treturn true;\n\t}else return false;\n";
- else
- if(cls.propertyIsString(k[i]))
- code+="\t$this->prop_"+k[i]+"=\"\".$value;\n\treturn true;\n";
- //TODO: special handling for astring
- else
- if(cls.propertyIsObject(k[i])){
- code+="\tif(is_a($value,\"WO"+cls.propertyPlainType(k[i])+"\")){\n";
- code+="\t\t$this->prop_"+k[i]+"=$value;\n";
- code+="\t\treturn true;\n";
- }else{
- qDebug("Warning: unable to generate setter for class %s property %s: unknown type.",cls.name().toAscii().data(),k[i].toAscii().data());
- code+="\treturn false;\n";
- }
- code+="}\n";
+ code+=classPropertyScalarSetters(cls,k[i]);
+ }
+ }
+
+ return code;
+}
+
+QString WocPHPServerOut::classPropertyValidator(const WocClass&cls,QString prop)
+{
+ QString code;
+ code+="static public function validate"+prop+"($value){\n";
+ if(cls.propertyIsEnum(prop)){
+ QList<QPair<QString,int> >ev=cls.enumValues(cls.propertyPlainType(prop));
+ code+="\tif(is_numeric($value)){\n\t\t$value=$value+0;\n";
+ for(int j=0;j<ev.size();j++){
+ code+="\t\tif($value=="+QString::number(ev[j].second)+")return true;\n";
+ }
+ code+="\t\treturn false;\n\t}else{\n";
+ for(int j=0;j<ev.size();j++){
+ code+="\t\tif($value==\""+ev[j].first+"\")return true;\n";
}
+ code+="\t\treturn false;\n\t}\n";
+ }else
+ if(cls.propertyIsInt(prop))
+ code+="\treturn is_numeric($value);\n";
+ else
+ if(cls.propertyIsString(prop))
+ code+="\treturn true;\n";//TODO: special handling for astring
+ else
+ if(cls.propertyIsObject(prop))
+ code+="\treturn is_a($value,\"WO"+cls.propertyPlainType(prop)+"\");\n";
+ else{
+ qDebug("Warning: unable to generate validator for class %s property %s: unknown type.",cls.name().toAscii().data(),prop.toAscii().data());
+ code+="\treturn false;\n";
}
+ code+="}\n";
- //TODO: implement mappings
+ return code;
+}
+
+QString WocPHPServerOut::classPropertyListGetters(const WocClass&cls,QString prop)
+{
+ QString code;
+ if(cls.propertyIsString(prop))code+="public function getstrlist_"+prop+"(){return $this->prop_"+prop+";}\n";
+ else
+ if(cls.propertyIsInt(prop)){
+ code+="public function getstrlist_"+prop+"(){\n";
+ code+="\t$ret=array();\n\tforeach($this->prop_"+prop+" as $p)$ret[]=\"\".$p;\n";
+ code+="\treturn $ret;\n}\n";
+ }else
+ if(cls.propertyIsEnum(prop)){
+ code+="public function getstrlist_"+prop+"(){\n";
+ code+="\t$ret=array();\n";
+ code+="\tforeach($this->prop_"+prop+" as $p)switch($p){\n";
+ QList<QPair<QString,int> > ev=cls.enumValues(cls.propertyPlainType(prop));
+ for(int j=0;j<ev.size();j++){
+ code+="\t\tcase "+QString::number(ev[j].second)+":$ret[]=\""+ev[j].first+"\";break;\n";
+ }
+ code+="\t\tdefault:$ret[]=null;break;\n\t}\n\treturn $ret;\n}\n";
+ }
- //implement serializers
- k=cls.serializers();
+ return code;
+}
+
+QString WocPHPServerOut::classPropertyListSetters(const WocClass&cls,QString prop)
+{
+ QString code;
+ code+="public function clear_"+prop+"(){$this->prop_"+prop+"=array();}\n";
+ QString acode;//body of add_ function, see below
+ code+="public function set_"+prop+"(array $values){\n";
+ if(cls.propertyIsEnum(prop)){
+ QList<QPair<QString,int> >ev=cls.enumValues(cls.propertyPlainType(prop));
+ code+="\t$prop=array();\n";
+ code+="\tforeach($values as $value){\n";
+ code+="\t\tif(is_numeric($value)){\n\t\t\t$value=$value+0;\n";
+ acode+="\tif(is_numeric($value)){\n\t\t$value=$value+0;\n";
+ for(int j=0;j<ev.size();j++){
+ code+="\t\t\tif($value=="+QString::number(ev[j].second)+"){\n";
+ code+="\t\t\t\t$prop[]="+QString::number(ev[j].second)+";\n";
+ code+="\t\t\t}else\n";
+ acode+="\t\tif($value=="+QString::number(ev[j].second)+"){\n";
+ acode+="\t\t\t$this->prop_"+prop+"[]="+QString::number(ev[j].second)+";\n";
+ acode+="\t\t\treturn true;\n\t\t}\n";
+ }
+ code+="\t\t\treturn false;\n\t\t}else{\n";
+ acode+="\t\treturn false;\n\t}else{\n";
+ for(int j=0;j<ev.size();j++){
+ code+="\t\t\tif($value==\""+ev[j].first+"\"){\n";
+ code+="\t\t\t\t$prop[]="+QString::number(ev[j].second)+";\n";
+ code+="\n\t\t\t}else\n";
+ acode+="\t\tif($value==\""+ev[j].first+"\"){\n";
+ acode+="\t\t\t$this->prop_"+prop+"[]="+QString::number(ev[j].second)+";\n";
+ acode+="\t\t\treturn true;\n\t\t}\n";
+ }
+ code+="\t\t\treturn false;\n\t\t}\n\t}\n";
+ code+="\t$this->prop_"+prop+"=$prop;\n";
+ code+="\treturn true;\n";
+ acode+="\t\treturn false;\n\t}\n";
+ }else
+ if(cls.propertyIsInt(prop)){
+ code+="\t$prop=array();\n\tforeach($values as $value)\n";
+ code+="\t\tif(is_numeric($value)){\n\t\t\t$prop=0+$value;\n\t\t}else return false;\n";
+ code+="\t$this->prop_"+prop+"=$prop;\n\treturn true;\n";
+ acode+="\tif(is_numeric($value)){\n";
+ acode+="\t\t$this->prop_"+prop+"=0+$value;\n\t\treturn true;\n\t}else return false;\n";
+ }else
+ if(cls.propertyIsString(prop)){
+ code+="\t$prop=array();\n\tforeach($values as $value)$prop[]=\"\".$value;\n";
+ code+="\t$this->prop_"+prop+"=$prop;\n\treturn true;\n";
+ //TODO: special handling for astring
+ acode+="\t$this->prop_"+prop+"[]=\"\".$value;\n\treturn true;\n";
+ }else
+ if(cls.propertyIsObject(prop)){
+ code+="\t$prop=array();\n\tforeach($values as $value)\n";
+ code+="\t\tif(is_a($value,\"WO"+cls.propertyPlainType(prop)+"\"))\n";
+ code+="\t\t\t$prop[]=$value;\n";
+ code+="\t\telse return false;\n";
+ code+="\t$this->prop_"+prop+"=$prop;\n";
+ code+="\treturn true;\n";
+ acode+="\tif(is_a($value,\"WO"+cls.propertyPlainType(prop)+"\")){\n";
+ acode+="\t\t$this->prop_"+prop+"[]=$value;\n";
+ acode+="\t\treturn true;\n";
+ acode+="\t}else return false;\n";
+ }else{
+ qDebug("Warning: unable to generate setter for class %s property %s: unknown type.",cls.name().toAscii().data(),prop.toAscii().data());
+ code+="\treturn false;\n";
+ }
+ code+="}\n";
+ code+="public function add_"+prop+"($value){\n"+acode+"}\n";
+
+ return code;
+}
+
+QString WocPHPServerOut::classPropertyScalarGetters(const WocClass&cls,QString prop)
+{
+ QString code;
+ if(cls.propertyIsString(prop))code+="public function getstr_"+prop+"(){return $this->prop_"+prop+";}\n";
+ else
+ if(cls.propertyIsInt(prop))code+="public function getstr_"+prop+"(){return \"\".$this->prop_"+prop+";}\n";
+ else
+ if(cls.propertyIsEnum(prop)){
+ code+="public function getstr_"+prop+"(){\n\tswitch($this->prop_"+prop+"){\n";
+ QList<QPair<QString,int> > ev=cls.enumValues(cls.propertyPlainType(prop));
+ for(int j=0;j<ev.size();j++){
+ code+="\t\tcase "+QString::number(ev[j].second)+":return \""+ev[j].first+"\";\n";
+ }
+ code+="\t\tdefault:return null;\n\t}\n}\n";
+ }
+
+ return code;
+}
+
+QString WocPHPServerOut::classPropertyScalarSetters(const WocClass&cls,QString prop)
+{
+ QString code;
+ code+="public function set_"+prop+"($value){\n";
+ if(cls.propertyIsEnum(prop)){
+ QList<QPair<QString,int> >ev=cls.enumValues(cls.propertyPlainType(prop));
+ code+="\tif(is_numeric($value)){\n\t\t$value=$value+0;\n";
+ for(int j=0;j<ev.size();j++){
+ code+="\t\tif($value=="+QString::number(ev[j].second)+"){\n";
+ code+="\t\t\t$this->prop_"+prop+"="+QString::number(ev[j].second)+";\n";
+ code+="\t\t\treturn true;\n\t\t}\n";
+ }
+ code+="\t\treturn false;\n\t}else{\n";
+ for(int j=0;j<ev.size();j++){
+ code+="\t\tif($value==\""+ev[j].first+"\"){\n";
+ code+="\t\t\t$this->prop_"+prop+"="+QString::number(ev[j].second)+";\n";
+ code+="\t\t\treturn true;\n\t\t}\n";
+ }
+ code+="\t\treturn false;\n\t}\n";
+ }else
+ if(cls.propertyIsInt(prop))
+ code+="\tif(is_numeric($value)){\n\t\t$this->prop_"+prop+"=0+$value;\n\t\treturn true;\n\t}else return false;\n";
+ else
+ if(cls.propertyIsString(prop))
+ code+="\t$this->prop_"+prop+"=\"\".$value;\n\treturn true;\n";
+ //TODO: special handling for astring
+ else
+ if(cls.propertyIsObject(prop)){
+ code+="\tif(is_a($value,\"WO"+cls.propertyPlainType(prop)+"\")){\n";
+ code+="\t\t$this->prop_"+prop+"=$value;\n";
+ code+="\t\treturn true;\n";
+ }else{
+ qDebug("Warning: unable to generate setter for class %s property %s: unknown type.",cls.name().toAscii().data(),prop.toAscii().data());
+ code+="\treturn false;\n";
+ }
+ code+="}\n";
+
+ return code;
+}
+
+QString WocPHPServerOut::classSerializers(const WocClass&cls)
+{
+ QString code;
+ QStringList k=cls.serializers();
for(int i=0;i<k.size();i++){
//toString function (wraps toXml)
code+="\npublic function toString"+k[i]+"(){\n\t$xml=new DomDocument;\n";
code+="\t$xml->appendChild($this->toXml"+k[i]+"($xml));\n\treturn $xml->saveXml();\n}\n";
//toXml function:
- code+="public function toXml"+k[i]+"($xml){\n";
- code+="\t$root=$xml->createElement(\""+cls.name()+"\");\n";
+ code+="public function toXml"+k[i]+"($xml,$elementname=\""+cls.name()+"\"){\n";
+ code+="\t$root=$xml->createElement($elementname);\n";
code+="\t$root->setAttribute(\"serialization-mode\",\""+k[i]+"\");\n";
//add properties
QStringList p=cls.serializerProperties(k[i]);
//return result
code+="\treturn $root;\n}\n";
}
-
- //implement de-serializer
+ return code;
+}
+
+QString WocPHPServerOut::classDeserializers(const WocClass&cls,QString cn)
+{
+ QString code;
+ QStringList k;
code+="\nstatic public function fromString($txt){\n\t$xml=new DomDocument;\n";
code+="\tif(!$xml->loadXml(trim($txt)))";
- code+="\n\t\tthrow WobXmlException(\"Unable to deserialize object of type "+cn+".\");";
+ code+="\n\t\tthrow WobXmlException(\"Unable to deserialize object of type "+cn+": invalid XML.\");";
code+="\n\treturn self::fromXml($xml,$xml->documentElement);\n}\n";
code+="static public function fromXml($xml,$elem){\n\t$data=array();\n";
k=cls.propertyNames();
for(int i=0;i<k.size();i++){
- //TODO: scan properties
- code+="\t??\n";
+ //scan properties
+ if(cls.propertyIsList(k[i])){
+ code+="\t$data[\""+k[i]+"\"]=array();\n";
+ code+="\tforeach($elem->elementsByTagName(\""+k[i]+"\") as $el){\n";
+ if(cls.propertyIsObject(k[i])){
+ code+="\t\t$data[\""+k[i]+"\"][]=WO"+cls.propertyPlainType(k[i])+"::fromXml($xml,$el);\n";
+ }else{
+ code+="\t\t$data[\""+k[i]+"\"][]=$el->textContent;\n";
+ }
+ code+="\t}\n";
+ }else{
+ if(cls.propertyIsObject(k[i])){
+ code+="\tforeach($elem->elementsByTagName(\""+k[i]+"\") as $el){\n";
+ code+="\t\t$data[\""+k[i]+"\"]=WO"+cls.propertyPlainType(k[i])+"::fromXml($xml,$el);\n";
+ code+="\t}\n";
+ }else
+ if(cls.propertyIsAttribute(k[i])){
+ code+="\tif($elem->hasAttribute(\""+k[i]+"\"))\n";
+ code+="\t\t$data[\""+k[i]+"\"]=$elem->getAttribute(\""+k[i]+"\");\n";
+ }else{
+ code+="\tforeach($elem->elementsByTagName(\""+k[i]+"\") as $el){\n";
+ code+="\t\t$data[\""+k[i]+"\"]=$elem->textContent;\n";
+ code+="\t}\n";
+ }
+ }
+ }
+ code+="\treturn new "+cn+"($data);\n}\n";
+ return code;
+}
+
+QString WocPHPServerOut::classMappings(const WocClass&cls)
+{
+ //implement mappings
+ QString code;
+ QStringList k=cls.mappingTables();
+ for(int i=0;i<k.size();i++){
+ code+="\nstatic public function fromTable"+k[i]+"($table){\n\t$data=array();\n";
+ QList<QPair<QString,QString> >map=cls.mapping(k[i]);
+ for(int j=0;j<map.size();j++){
+ code+="\t$data[\""+map[j].second+"\"]=$table->"+map[j].first+";\n";
+ }
+ code+="\treturn new WO"+cls.name()+"($data);\n}\n";
}
- code+="\treturn $ret;\n}\n";
- //end of class
- code+="\n//end of class\n};\n";
-
-
- tf.write(code.toAscii());
- tf.write(PHPEND);
- tf.close();
+ return code;
}
QString WocPHPServerOut::propertyToXml(const WocClass&cls,QString pt)
//is it a class?
if(cls.propertyIsObject(prop)){
QString code="\tforeach($this->get_"+prop+"() as $o)\n\t\t";
- code+="$root->appendChild($o->toXml"+var+"($xml));\n";
+ code+="$root->appendChild($o->toXml"+var+"($xml,\""+prop+"\"));\n";
return code;
}else{
//there is no way to create lists of attributes, hence we always create elements
return "\t$root->appendChild($xml->createElement(\""+prop+"\",xq($this->getstr_"+prop+"())));\n";
//is it a class?
if(cls.propertyIsObject(prop))
- return "\t$root->appendChild($this->get_"+prop+"()->toXml"+var+"($xml));\n";
+ return "\t$root->appendChild($this->get_"+prop+"()->toXml"+var+"($xml,\""+prop+"\"));\n";
//anything else?
qDebug("Warning: end of WocPHPServerOut::propertyToXml - this code should not be reachable.");
return "//internal generator error!\n";
void WocPHPServerOut::newTransaction(const WocTransaction&)
{
+ //TODO: implement transaction
}