[Uml-devel] kdesdk/umbrello/umbrello/codegenerators
Sebastian Stein
seb_stein at gmx.de
Mon Jul 12 23:39:14 UTC 2004
CVS commit by sstein:
fix bug #84656: SQL code generation misplaces comments
M +35 -9 sqlwriter.cpp 1.11
M +1 -1 sqlwriter.h 1.8
--- kdesdk/umbrello/umbrello/codegenerators/sqlwriter.h #1.7:1.8
@@ -60,5 +60,5 @@ private:
* Prints out attributes as columns in the table
*/
- void printAttributes(QTextStream& sql, UMLAttributeList attributeList, bool first);
+ void printAttributes(QTextStream& sql, UMLAttributeList attributeList);
};
--- kdesdk/umbrello/umbrello/codegenerators/sqlwriter.cpp #1.10:1.11
@@ -130,22 +130,48 @@ void SQLWriter::writeAttributes(UMLClass
}
- bool first = true;
- printAttributes(sql, atpub, first);
- printAttributes(sql, atprot, first);
- printAttributes(sql, atpriv, first);
+ printAttributes(sql, atpub);
+ printAttributes(sql, atprot);
+ printAttributes(sql, atpriv);
}
-void SQLWriter::printAttributes(QTextStream& sql, UMLAttributeList attributeList, bool first) {
+void SQLWriter::printAttributes(QTextStream& sql, UMLAttributeList attributeList) {
+ bool first = true;
+ QString attrDoc = "";
UMLAttribute* at;
- for (at=attributeList.first();at;at=attributeList.next()) {
- if (!first) {
- sql <<","<<endl;
+
+ for (at=attributeList.first();at;at=attributeList.next())
+ {
+ // print , after attribute
+ if (first == false) {
+ sql <<",";
} else {
first = false;
}
+
+ // print documentation/comment of last attribute at end of line
+ if (attrDoc.isEmpty() == false)
+ {
+ sql << " -- " << attrDoc << endl;
+ } else {
+ sql << endl;
+ }
+
+ // write the attribute
sql << "\t" << cleanName(at->getName()) << " " << at->getTypeName() << " "
- << (at->getDoc().isEmpty()?QString(""):at->getDoc())
<< (at->getInitialValue().isEmpty()?QString(""):QString(" DEFAULT ")+at->getInitialValue());
+
+ // now get documentation/comment of current attribute
+ attrDoc = at->getDoc();
}
+
+ // print documentation/comment at end of line
+ if (attrDoc.isEmpty() == false)
+ {
+ sql << " -- " << attrDoc << endl;
+ } else {
+ sql << endl;
+ }
+
+ return;
}
More information about the umbrello-devel
mailing list