From faac56702e0a4c92ee76e44ad5d6f68767b3d4ca Mon Sep 17 00:00:00 2001 From: konrad Date: Tue, 3 Feb 2009 15:56:58 +0000 Subject: [PATCH] woc now also translates DB preset values git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@262 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- woc/phpout.cpp | 17 ++++++++++++++++- woc/processor.cpp | 36 +++++++++++++++++++++++++++++++++--- woc/processor.h | 6 +++++- 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/woc/phpout.cpp b/woc/phpout.cpp index 0a2b8fb..6ea8a2f 100644 --- a/woc/phpout.cpp +++ b/woc/phpout.cpp @@ -122,7 +122,22 @@ void WocPHPServerOut::newTable(const WocTable&tbl) code+="\n\t);\n"; if(tbl.inBackup())code+="\t$this->backup[]=\""+tbl.name()+"\";\n"; //write presets - + QList >presets=tbl.presets(); + if(presets.size()>0){ + code+="\t$this->preset[\""+tbl.name()+"\"]=array("; + for(int i=0;i"+presets[i][k[j]]; + } + code+=")"; + } + code+="\n\t);\n"; + } + //write m_schema.write(code.toAscii()); diff --git a/woc/processor.cpp b/woc/processor.cpp index cb44b7f..a25ee18 100644 --- a/woc/processor.cpp +++ b/woc/processor.cpp @@ -279,7 +279,7 @@ WocTable::WocTable(const QDomElement&tbl) m_valid=false; return; } - if(haveColumn(cl.name)){ + if(hasColumn(cl.name)){ qDebug("Error: double definition of column %s in table %s.",cl.name.toAscii().data(),m_name.toAscii().data()); m_valid=false; return; @@ -307,7 +307,7 @@ WocTable::WocTable(const QDomElement&tbl) m_valid=false; return; } - if(!woc->table(fgn[0]).haveColumn(fgn[1])){ + if(!woc->table(fgn[0]).hasColumn(fgn[1])){ qDebug("Error: table %s column %s: foreign key target table/column %s does not exist",m_name.toAscii().data(),cl.name.toAscii().data(),cl.foreign.toAscii().data()); m_valid=false; return; @@ -332,6 +332,7 @@ WocTable::WocTable(const QDomElement&tbl) } m_columns.append(cl); } + //Foreign getter methods nl=tbl.elementsByTagName("Foreign"); for(int i=0;ips; + QDomNodeList nl2=el.elementsByTagName("V"); + for(int j=0;j0)m_presets.append(ps); + } + //sanity checks //check we have any columns at all if(m_columns.size()==0){ @@ -411,7 +441,7 @@ QString WocTable::columnDefault(QString c)const return ""; } -bool WocTable::haveColumn(QString c)const +bool WocTable::hasColumn(QString c)const { for(int i=0;i +#include #include #include @@ -40,6 +41,7 @@ class WocTable QString name()const{return m_name;} bool inBackup()const{return m_backup;} + bool hasColumn(QString)const; QStringList columns()const; QStringList primaryColumns()const; QString columnType(QString)const; @@ -47,7 +49,6 @@ class WocTable bool columnIsPrimary(QString)const; bool columnHasDefault(QString)const; QString columnDefault(QString)const; - bool haveColumn(QString)const; bool columnIsForeign(QString)const; QString columnForeign(QString)const; bool columnIsIndexed(QString)const; @@ -58,6 +59,8 @@ class WocTable QStringList foreigns()const; QString foreignQuery(QString)const; bool haveForeign(QString)const; + + QList > presets()const{return m_presets;} private: bool m_valid,m_backup; QString m_name; @@ -68,6 +71,7 @@ class WocTable }; QListm_columns; QList >m_foreign; + QList >m_presets; }; class WocOutput:public QObject -- 1.7.2.5