void UmlClass::uml2cpp(bool rec) { if (isCppExternal()) set_CppDecl(CppSettings::externalClassDecl()); else { QCString st = CppSettings::classStereotype(stereotype()); UmlItem * pack = parent()->parent(); while (pack->kind() != aPackage) pack = pack->parent(); if ((st == "stereotype") || (st == "metaclass") || (pack->stereotype() == "profile")) { set_CppDecl(""); return; } if (st == "enum") set_CppDecl(CppSettings::enumDecl()); else if (st == "union") set_CppDecl(CppSettings::unionDecl()); else if (st == "struct") set_CppDecl(CppSettings::structDecl()); else if (st == "typedef") set_CppDecl(CppSettings::typedefDecl()); else if (st == "ignored") { set_CppDecl(""); return; } else set_CppDecl(CppSettings::classDecl()); if (rec) { const QVector<UmlItem> ch = children(); unsigned n = ch.size(); for (unsigned i = 0; i != n; i += 1) ch[i]->uml2cpp(rec); } if (parent()->kind() == aClassView) { // not nested UmlArtifact * art = artifact(); art->set_CppSource(CppSettings::sourceContent()); art->set_CppHeader(CppSettings::headerContent()); } } }
void UmlPackage::reverse_main(const Q3CString & type, Q3CString comment) { // do not lost main ! Lex::mark(); UmlOperation::skip_body(); UmlArtifact * cp; #ifdef ROUNDTRIP bool roundtrip = FALSE; if ((cp = UmlArtifact::get_main()) != 0) { roundtrip = TRUE; cp->set_usefull(); } else #endif if ((cp = UmlBaseArtifact::create(get_deploymentview(0), "main")) == 0) { UmlCom::trace("<font face=helvetica><b>cannot create <i>artifact main</i></b></font><br><hr>"); return; } if (! comment.isEmpty()) { unsigned start = 0; do { comment.insert(start, "//"); start = comment.find('\n', start + 2) + 1; } while (start != 0); comment.append("\n\n"); } comment.append(type); comment.append(" main("); comment.append(Lex::region()); comment.append("\n"); #ifdef ROUNDTRIP if (roundtrip) { if (cp->cppSource() != comment) cp->set_CppSource(comment); return; } #endif cp->set_Stereotype("source"); cp->set_CppSource(comment); cp->set_CppHeader(0); }
UmlArtifact * UmlArtifact::made(UmlDeploymentView * depl_view, const Q3CString & s) { UmlArtifact * art = UmlBaseArtifact::create(depl_view, s); if (art == 0) { Q3CString msg = "can't create artifact " + s + " in " + depl_view->name() + "<br>\n"; UmlCom::trace(msg); throw 0; } UmlCom::trace("add artifact " + s + "<br>\n"); art->set_Stereotype("source"); art->set_CppHeader(CppSettings::headerContent()); art->set_CppSource(CppSettings::sourceContent()); art->set_JavaSource(JavaSettings::sourceContent()); return art; }
void UmlClass::need_artifact(const WrapperStr & nmsp) { if (parent()->kind() == aClassView) { UmlArtifact * cp; if ((cp = associatedArtifact()) == 0) { // search artifact #ifdef ROUNDTRIP if ((cp = Package::get_artifact()) != 0) { cp->addAssociatedClass(this); return; } #endif WrapperStr name = Package::get_fname(); int index; if (name.isEmpty()) { // defined in a source rather than a header // will create it own artifact name = this->name(); index = name.find('<'); if (index != -1) name = name.left(index); } UmlDeploymentView * cpv = ((UmlPackage *) parent()->parent())->get_deploymentview(nmsp); const QVector<UmlItem*> & children = cpv->children(); int n = (int) children.count(); for (index = 0; index != n; index += 1) { if ((children[index]->name() == name) && (children[index]->kind() == anArtifact)) { cp = (UmlArtifact *) children[index]; break; } } if (cp == 0) { // does not exist, create associated artifact if ((cp = UmlBaseArtifact::create(cpv, name)) == 0) { #ifdef REVERSE UmlCom::trace(WrapperStr("<font face=helvetica><b>cannot create artifact <i>") + Lex::quote(name) + "</i> under <i>" + Lex::quote(cpv->name()) + "</b></font><br>"); UmlCom::message(""); throw 0; #else QMessageBox::critical(0, "Fatal Error", WrapperStr("<font face=helvetica><b>cannot create artifact <i>") + Lex::quote(name) + "</i> under <i>" + Lex::quote(cpv->Name()) + "</b></font><br>"); QApplication::exit(1); #endif } cp->set_Stereotype("source"); cp->set_CppHeader(CppSettings::headerContent()); } cp->addAssociatedClass(this); } // source needed ? if (need_source() && cp->cppSource().isEmpty()) cp->set_CppSource(CppSettings::sourceContent()); } }