void UmlRelation::generate_implements(const char *& sep, QTextOStream & f, const Q3ValueList<UmlActualParameter> & actuals, const Q3CString & cl_stereotype) { switch (relationKind()) { default: return; case aGeneralisation: case aRealization: if (javaDecl().isEmpty()) return; UmlClass * role_type = roleType(); const Q3CString & other_stereotype = role_type->java_stereotype(); if ((other_stereotype == "interface") || (other_stereotype == "@interface")) { if ((cl_stereotype == "union") || (cl_stereotype == "enum_pattern")) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>an <i>") + cl_stereotype + "</i> cannot inherits</b></font><br>"); incr_warning(); } else { f << sep; sep = ", "; const char * p = javaDecl(); while (*p) { if (!strncmp(p, "${type}", 7)) { role_type->write(f); p += 7; if (!actuals.isEmpty()) { Q3ValueList<UmlActualParameter>::ConstIterator ita; bool used = FALSE; for (ita = actuals.begin(); ita != actuals.end(); ++ita) { if ((*ita).superClass() == role_type) { used = TRUE; (*ita).generate(f); } } if (used) { f << ">"; } } } else if (*p == '@') manage_alias(p, f); else f << *p++; } } } } }
void UmlOperation::change(Context & ctx) { if (ctx.onOperation() && ctx.match_stereotype(stereotype())) { if (ctx.cpp()) { const Q3CString & c = cppDecl(); if (!c.isEmpty() && ctx.match(c)) { if (!set_CppDecl(ctx.replace(c))) ctx.err(); } const Q3CString & f = cppDef(); if (!f.isEmpty() && ctx.match(f)) { if (!set_CppDef(ctx.replace(f))) ctx.err(); } } if (ctx.java()) { const Q3CString & c = javaDecl(); if (!c.isEmpty() && ctx.match(c)) { if (!set_JavaDecl(ctx.replace(c))) ctx.err(); } } if (ctx.php()) { const Q3CString & c = phpDecl(); if (!c.isEmpty() && ctx.match(c)) { if (!set_PhpDecl(ctx.replace(c))) ctx.err(); } } if (ctx.python()) { const Q3CString & c = pythonDecl(); if (!c.isEmpty() && ctx.match(c)) { if (!set_PythonDecl(ctx.replace(c))) ctx.err(); } } if (ctx.idl()) { const Q3CString & c = idlDecl(); if (!c.isEmpty() && ctx.match(c)) { if (!set_IdlDecl(ctx.replace(c))) ctx.err(); } } } }
void UmlClass::generate() { if (! managed) { managed = TRUE; if (!isJavaExternal() && !javaDecl().isEmpty()) { if (associatedArtifact() != 0) associatedArtifact()->generate(); else if ((children().size() != 0) && verbose()) UmlCom::trace(QCString("<hr><font face=helvetica><i> ") + name() + " : </i> does not have associated <i>artifact</i></font><br>"); } } }
void UmlRelation::change(Context & ctx) { if (ctx.onRelation() && ctx.match_stereotype(stereotype())) { if (ctx.cpp()) { const QByteArray & c = cppDecl(); if (!c.isEmpty() && ctx.match(c)) { if (!set_CppDecl(ctx.replace(c))) ctx.err(); } } if (ctx.java()) { const QByteArray & c = javaDecl(); if (!c.isEmpty() && ctx.match(c)) { if (!set_JavaDecl(ctx.replace(c))) ctx.err(); } } if (ctx.php()) { const QByteArray & c = phpDecl(); if (!c.isEmpty() && ctx.match(c)) { if (!set_PhpDecl(ctx.replace(c))) ctx.err(); } } if (ctx.python()) { const QByteArray & c = pythonDecl(); if (!c.isEmpty() && ctx.match(c)) { if (!set_PythonDecl(ctx.replace(c))) ctx.err(); } } if (ctx.idl()) { const QByteArray & c = idlDecl(); if (!c.isEmpty() && ctx.match(c)) { if (!set_IdlDecl(ctx.replace(c))) ctx.err(); } } } }
void UmlClass::write(QTextOStream & f) { if (isJavaExternal()) { QCString s = javaDecl().stripWhiteSpace(); int index; if ((index = s.find("${name}")) != -1) s.replace(index, 7, name()); else if ((index = s.find("${Name}")) != -1) s.replace(index, 7, capitalize(name())); else if ((index = s.find("${NAME}")) != -1) s.replace(index, 7, name().upper()); else if ((index = s.find("${nAME}")) != -1) s.replace(index, 7, name().lower()); f << s; } else { UmlClass * toplevel = this; UmlItem * p; QCString s2; while ((p = toplevel->parent())->kind() == aClass) { toplevel = (UmlClass *) p; s2 = dot + p->name() + s2; } UmlArtifact * cp = toplevel->associatedArtifact(); UmlPackage * pack = (UmlPackage *) ((cp != 0) ? (UmlItem *) cp : (UmlItem *) toplevel)->package(); if (pack != UmlArtifact::generation_package()) { QCString s = pack->javaPackage(); if (! s.isEmpty() && (s != "java.lang") && (s.left(10) != "java.lang.")) { s += s2; if (JavaSettings::isForcePackagePrefixGeneration() || !UmlArtifact::generated_one()->is_imported(s, name())) f << s << '.'; } } else if (! s2.isEmpty()) f << s2.mid(1) << '.'; f << name(); } }
void UmlAttribute::write_java_type(FileOut & out) { Q3CString s = javaDecl(); int index; remove_comments(s); // remove keywords not linked to the type if ((index = s.find("${visibility}")) != -1) s.replace(index, 13, " "); if ((index = s.find("${static}")) != -1) s.replace(index, 9, " "); if ((index = s.find("${final}")) != -1) s.replace(index, 8, " "); if ((index = s.find("${transient}")) != -1) s.replace(index, 12, " "); if ((index = s.find("${volatile}")) != -1) s.replace(index, 11, " "); if ((index = s.find("${value}")) != -1) s.replace(index, 8, " "); if ((index = s.find("${@}")) != -1) s.replace(index, 4, " "); UmlTypeSpec t = type(); if (t.type == 0) t.explicit_type = JavaSettings::type(t.explicit_type); write_type(out, t, s, "${name}", "${type}"); }
void UmlRelation::write_relation_as_attribute(FileOut & out) { UmlRelation * first = side(TRUE); Q3CString s; UmlClass * base; if ((first->parent()->stereotype() == "stereotype") && (first->roleType()->stereotype() == "metaclass")) { if (this != first) return; base = first->roleType(); s = "base_" + base->name(); } else { base = 0; switch (_lang) { case Uml: s = roleName(); break; case Cpp: if (cppDecl().isEmpty()) return; s = true_name(roleName(), cppDecl()); break; default: // Java if (javaDecl().isEmpty()) return; s = true_name(roleName(), javaDecl()); } } out.indent(); out << "<ownedAttribute xmi:type=\"uml:Property\" name=\"" << s << '"'; out.id(this); if (base != 0) out.ref(first, "association", "EXT_"); else { write_visibility(out); write_scope(out); if (isReadOnly()) out << " isReadOnly=\"true\""; if (isDerived()) { out << " isDerived=\"true\""; if (isDerivedUnion()) out << " isDerivedUnion=\"true\""; } if (isOrdered()) out << " isOrdered=\"true\""; if (isUnique()) out << " isUnique=\"true\""; if (first->_assoc_class != 0) out.ref(first->_assoc_class, "association"); else out.ref(first, "association", "ASSOC_"); out << " aggregation=\""; if (this == first) { parent()->memo_relation(this); if (_gen_eclipse) { switch (relationKind()) { case anAggregation: case aDirectionalAggregation: out << "shared"; break; case anAggregationByValue: case aDirectionalAggregationByValue: out << "composite"; break; default: out << "none"; } } else out << "none"; } else if (_gen_eclipse) out << "none"; else { switch (relationKind()) { case anAggregation: case aDirectionalAggregation: out << "shared"; break; case anAggregationByValue: case aDirectionalAggregationByValue: out << "composite"; break; default: out << "none"; } } out << '"'; } out << ">\n"; out.indent(+1); out.indent(); out << "<type xmi:type=\"uml:Class\""; if (base != 0) { if (! base->propertyValue("metaclassPath", s)) s = (_uml_20) ? "http://schema.omg.org/spec/UML/2.0/uml.xml" : "http://schema.omg.org/spec/UML/2.1/uml.xml"; out << " href=\"" << s << '#' << base->name() << '"'; } else out.idref(roleType()); out << "/>\n"; write_multiplicity(out, multiplicity(), this); write_default_value(out, defaultValue(), this); write_constraint(out); write_annotation(out); write_description_properties(out); out.indent(-1); out.indent(); out << "</ownedAttribute>\n"; unload(); }
void UmlExtraClassMember::generate_enum_member(QTextOStream & f, Q3CString) { f << javaDecl(); }
void UmlExtraClassMember::generate_enum_pattern_item(QTextOStream & f, int &, const Q3CString &, Q3CString) { f << javaDecl(); }
void UmlExtraClassMember::generate(QTextOStream & f, const Q3CString &, Q3CString) { f << javaDecl(); }
void UmlRelation::generate(QTextOStream & f, const Q3CString & cl_stereotype, Q3CString indent) { switch (relationKind()) { case aDependency: case aGeneralisation: case aRealization: break; default: if (!javaDecl().isEmpty()) { if (cl_stereotype == "enum_pattern") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>an <i>enum_pattern</i> cannot have relation</b></font><br>"); incr_warning(); return; } const char * p = javaDecl(); const char * pp = 0; Q3CString s; while ((*p == ' ') || (*p == '\t')) indent += *p++; f << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; f << indent; } if (*p == '\n') { f << *p++; if (*p) f << indent; } else if (*p == '@') manage_alias(p, f); else if (*p != '$') f << *p++; else if (!strncmp(p, "${comment}", 10)) manage_comment(p, pp, JavaSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${visibility}", 13)) { p += 13; generate_visibility(f, cl_stereotype); } else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) f << "static "; } else if (!strncmp(p, "${final}", 8)) { p += 8; if (isReadOnly()) f << "final "; } else if (!strncmp(p, "${transient}", 12)) { p += 12; if (isJavaTransient()) f << "transient "; } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) f << "volatile "; } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(f); } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f << JavaSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${name}", 7)) { p += 7; f << roleName(); } else if (!strncmp(p, "${inverse_name}", 15)) { p += 15; switch (relationKind()) { case anAssociation: case anAggregation: case anAggregationByValue: f << side(side(TRUE) != this)->roleName(); default: break; } } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; Q3CString m = multiplicity(); if (*m != '[') f << "[]"; else { for (unsigned index = 0; index != m.length(); index += 1) { switch (m.at(index)) { case '[': f << '['; break; case ']': f << ']'; default: break; } } } } else if (!strncmp(p, "${value}", 8)) { if (!defaultValue().isEmpty()) { if (need_equal(p, defaultValue())) f << " = "; f << defaultValue(); } p += 8; } else if (!strncmp(p, "${association}", 14)) { p += 14; UmlClass::write(f, association()); } else if (!strncmp(p, "${@}", 4)) { p += 4; if (pp != 0) f << "${@}"; else if (! javaAnnotations().isEmpty()) { pp =p; p = javaAnnotations(); } } else // strange f << *p++; } f << '\n'; } } }
void UmlOperation::html(QByteArray, unsigned int, unsigned int) { define(); fw.write("<table><tr><td><div class=\"element\">Operation <b>"); writeq(name()); fw.write("</b></div></td></tr></table>"); QByteArray s = description(); if (! s.isEmpty()) { fw.write("<p>"); if (! javaDecl().isEmpty()) gen_java_decl(s, TRUE); else if (! phpDecl().isEmpty()) gen_php_decl(s, TRUE); else if (! pythonDecl().isEmpty()) gen_python_decl(s, TRUE); else gen_cpp_decl(s, TRUE); fw.write("<br /></p>"); } fw.write("<p>Declaration :</p><ul>"); fw.write("<li>Uml : "); gen_uml_decl(); fw.write("</li>"); s = cppDecl(); if (!s.isEmpty()) { fw.write("<li>C++ : "); gen_cpp_decl(s, FALSE); fw.write("</li>"); } s = javaDecl(); if (!s.isEmpty()) { fw.write("<li>Java : "); gen_java_decl(s, FALSE); fw.write("</li>"); } s = phpDecl(); if (!s.isEmpty()) { fw.write("<li>Php : "); gen_php_decl(s, FALSE); fw.write("</li>"); } s = pythonDecl(); if (!s.isEmpty()) { fw.write("<li>Python : "); gen_python_decl(s, FALSE); fw.write("</li>"); } fw.write("</ul>"); annotation_constraint(); write_properties(); unload(FALSE, FALSE); }
void UmlClass::generate(QTextOStream & f, QCString indent) { QVector<UmlItem> ch = children(); const QValueList<UmlActualParameter> actuals = this->actuals(); const unsigned sup = ch.size(); const QCString & stereotype = java_stereotype(); bool an_enum_pattern = (stereotype == "enum_pattern"); bool an_enum = (stereotype == "enum"); unsigned index; const char * p = javaDecl(); const char * pp = 0; const char * sep; while ((*p == ' ') || (*p == '\t')) indent += *p++; f << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; f << indent; } if (*p == '\n') { f << *p++; if (*p && strncmp(p, "${members}", 10) && strncmp(p, "${items}", 8) && strncmp(p, "${cases}", 8)) f << indent; } else if (*p == '@') manage_alias(p, f); else if (*p != '$') f << *p++; else if (!strncmp(p, "${comment}", 10)) manage_comment(p, pp, JavaSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${public}", 9)) { p += 9; if (visibility() == PublicVisibility) f << "public "; } else if (!strncmp(p, "${visibility}", 13)) { p += 13; generate_visibility(f, ""); } else if (!strncmp(p, "${final}", 8)) { p += 8; if (isJavaFinal()) f << "final "; } else if (!strncmp(p, "${abstract}", 11)) { p += 11; if (isAbstract()) f << "abstract "; } else if (! strncmp(p, "${name}", 7)) { p += 7; f << name(); generate_formals(f); } else if (!strncmp(p, "${@}", 4)) { p += 4; if (pp != 0) f << "${@}"; else if (! javaAnnotations().isEmpty()) { pp = p; p = javaAnnotations(); } } else if (an_enum_pattern) { if (!strncmp(p, "${members}", 10)) { p += 10; int current_value = 0; QCString name = this->name(); for (index = 0; index != sup; index += 1) if ((ch[index]->kind() != aNcRelation) && !((UmlClassItem *) ch[index])->javaDecl().isEmpty()) ((UmlClassItem *) ch[index])-> generate_enum_pattern_item(f, current_value, name, indent); if (*p == '}') f << indent; } else if (!strncmp(p, "${cases}", 8)) { p += 8; for (index = 0; index != sup; index += 1) if ((ch[index]->kind() != aNcRelation) && !((UmlClassItem *) ch[index])->javaDecl().isEmpty()) ((UmlClassItem *) ch[index])->generate_enum_pattern_case(f, indent); } else // strange f << *p++; } else if (! strncmp(p, "${extends}", 10)) { p += 10; // extends sep = " extends "; for (index = 0; index != sup; index += 1) { UmlItem * x = ch[index]; if (x->kind() == aRelation) ((UmlRelation *) x)->generate_extends(sep, f, actuals, stereotype); } } else if (! strncmp(p, "${implements}", 13)) { p += 13; if (stereotype != "interface") { // implements sep = " implements "; for (index = 0; index != sup; index += 1) { UmlItem * x = ch[index]; if (x->kind() == aRelation) ((UmlRelation *) x)->generate_implements(sep, f, actuals, stereotype); } } } else if (! strncmp(p, "${members}", 10)) { p += 10; // members if (an_enum) { for (index = 0; index != sup; index += 1) { if (ch[index]->kind() != aNcRelation) { UmlClassItem * it = (UmlClassItem *)ch[index]; if (! it->javaDecl().isEmpty()) it->generate_enum_member(f, indent); } } } else { for (index = 0; index != sup; index += 1) { UmlItem * it = ch[index]; if (it->kind() == aClass) { if (! ((UmlClass *) it)->javaDecl().isEmpty()) { ((UmlClass *) it)->generate(f, indent + " "); f << '\n'; } } else if ((it->kind() != aNcRelation) && !((UmlClassItem *) it)->javaDecl().isEmpty()) ((UmlClassItem *) it)->generate(f, stereotype, indent); } } if (*p == '}') f << indent; } else if (an_enum && ! strncmp(p, "${items}", 8)) { p += 8; // enums items BooL first = TRUE; for (index = 0; index != sup; index += 1) { if (ch[index]->kind() != aNcRelation) { UmlClassItem * it = (UmlClassItem *)ch[index]; if (! it->javaDecl().isEmpty()) it->generate_enum_item(f, indent, first); } } if (*p == '}') f << indent; } else // strange f << *p++; } }
void UmlClass::gen_html(QCString pfix, unsigned int rank, unsigned int level) { UmlCom::message(name()); QCString s; s = description(); if (isActive()) fw.write("<p>Active class</p>\n"); if (!s.isEmpty()) { fw.write("<p>"); if (! javaDecl().isEmpty()) gen_java_decl(s, TRUE); else if (! phpDecl().isEmpty()) gen_php_decl(s, TRUE); else if (! pythonDecl().isEmpty()) gen_python_decl(s, TRUE); else gen_cpp_decl(s, TRUE); fw.write("<br /></p>\n"); } if (!cppDecl().isEmpty() || !javaDecl().isEmpty() || !phpDecl().isEmpty() || !pythonDecl().isEmpty()) { fw.write("<p>Declaration :</p><ul>\n"); s = cppDecl(); if (!s.isEmpty()) { fw.write("<li>C++ : "); gen_cpp_decl(s, FALSE); fw.write("</li>"); } s = javaDecl(); if (!s.isEmpty()) { fw.write("<li>Java : "); gen_java_decl(s, FALSE); fw.write("</li>"); } s = phpDecl(); if (!s.isEmpty()) { fw.write("<li>Php : "); gen_php_decl(s, FALSE); fw.write("</li>"); } s = pythonDecl(); if (!s.isEmpty()) { fw.write("<li>Python : "); gen_python_decl(s, FALSE); fw.write("</li>"); } fw.write("</ul>"); } if (subClasses.size() != 0) { sort(subClasses); fw.write("<p>Directly inherited by : "); for (unsigned i = 0; i != subClasses.size(); i += 1) { subClasses.elementAt(i)->write(); fw.write(' '); } fw.write("</p>\n"); } write_dependencies(); annotation_constraint(); bool p = FALSE; UmlItem * x; if ((x = associatedArtifact()) != 0) { p = TRUE; fw.write("<p>Artifact : "); x->write(); } const QVector<UmlComponent> comps = associatedComponents(); if (comps.size() != 0) { if (p) fw.write(", Component(s) :"); else { p = TRUE; fw.write("<p>Component(s) :"); } for (unsigned i = 0; i != comps.size(); i += 1) { fw.write(' '); comps[i]->write(); } } if ((x = associatedDiagram()) != 0) { if (p) fw.write(", Diagram : "); else { p = TRUE; fw.write("<p>Diagram : "); } x->write(); } if (p) fw.write("</p>\n"); if (parent()->kind() == aClass) { fw.write("<p>nested in "); parent()->write(); fw.write("</p>\n"); } write_properties(); // const QVector<UmlItem> ch = children(); if (ch.size() != 0) { if (stereotype() == "enum_pattern") { p = FALSE; for (unsigned i = 0; i != ch.size(); i += 1) { if (ch[i]->kind() == anAttribute) { if (!p) { p = TRUE; fw.write("<div class=\"sub\">\n<p>Items :</p><ul>\n"); } fw.write("<li>"); writeq(ch[i]->name()); fw.write("</li>\n"); } } if (p) fw.write("</ul>\n</div>\n"); } else { fw.write("<div class=\"sub\">\n"); if (stereotype() == "enum") { unsigned i; p = FALSE; for (i = 0; i != ch.size(); i += 1) { if ((ch[i]->kind() == anAttribute) && (ch[i]->stereotype() != "attribute")) { if (!p) { p = TRUE; fw.write("<p>Items :</p><ul>\n"); } fw.write("<li>"); writeq(ch[i]->name()); fw.write("</li>\n"); } } if (p) fw.write("</ul>\n"); s = ""; for (i = 0; i != ch.size(); i += 1) if ((ch[i]->kind() != anAttribute) || (ch[i]->stereotype() == "attribute")) ch[i]->html(s, 0, 0); } else if (flat) write_children(pfix, rank, level); else { // non flat s = ""; for (unsigned i = 0; i != ch.size(); i += 1) ch[i]->html(s, 0, 0); } fw.write("</div>\n"); } } sort(*inherited_opers); bool already = FALSE; for (unsigned i = 0; i != inherited_opers->size(); i += 1) { if (already) fw.write(", "); else { already = TRUE; fw.write("<p>All public operations : "); } inherited_opers->elementAt(i)->write(); fw.write(' '); } if (already) fw.write("</p>\n"); }
const WrapperStr & UmlBaseOperation::javaDef() { return javaDecl(); }
const QCString & UmlBaseOperation::javaDef() { return javaDecl(); }
void UmlRelation::html(QByteArray, unsigned int, unsigned int) { bool extension; switch (relationKind()) { case aGeneralisation: case aRealization: case aDependency: return; case aDirectionalAssociation: extension = (parent()->stereotype() == "stereotype") && (roleType()->stereotype() == "metaclass"); break; default: extension = FALSE; } define(); if (extension) fw.write("<table><tr><td><div class=\"element\">Extension</div></td></tr></table>"); else { fw.write("<table><tr><td><div class=\"element\">Relation <b>"); writeq(name()); fw.write("</b></div></td></tr></table>"); } QByteArray s = description(); if (!s.isEmpty()) { fw.write("<p>"); if (! javaDecl().isEmpty()) gen_java_decl(s, TRUE); else if (! phpDecl().isEmpty()) gen_php_decl(s, TRUE); else if (! pythonDecl().isEmpty()) gen_python_decl(s); else gen_cpp_decl(s, TRUE); fw.write("<br /></p>"); } if (extension) { fw.write("<p>Extend "); roleType()->write(); fw.write("</p>"); } else { fw.write("<p>Declaration :</p><ul>"); fw.write("<li>Uml : "); gen_uml_decl(); fw.write("</li>"); s = cppDecl(); if (!s.isEmpty()) { fw.write("<li>C++ : "); gen_cpp_decl(s, FALSE); fw.write("</li>"); } s = javaDecl(); if (!s.isEmpty()) { fw.write("<li>Java : "); gen_java_decl(s, FALSE); fw.write("</li>"); } s = phpDecl(); if (!s.isEmpty()) { fw.write("<li>Php : "); gen_php_decl(s, FALSE); fw.write("</li>"); } s = pythonDecl(); if (!s.isEmpty()) { fw.write("<li>Python : "); gen_python_decl(s); fw.write("</li>"); } fw.write("</ul>"); } annotation_constraint(); write_properties(); unload(FALSE, FALSE); }
bool UmlAttribute::write_if_needed(FileOut & out) { switch (_lang) { case Uml: parent()->write(out); out.indent(); out << "<UML:Attribute name=\"" << name() << '"'; break; case Cpp: if (cppDecl().isEmpty()) return FALSE; parent()->write(out); out.indent(); out << "<UML:Attribute name=\"" << true_name(cppDecl()) << '"'; break; default: // Java if (javaDecl().isEmpty()) return FALSE; parent()->write(out); out.indent(); out << "<UML:Attribute name=\"" << true_name(javaDecl()) << '"'; break; } out.id(this); switch (_lang) { case Uml: write_visibility(out); break; case Cpp: write_visibility(out, (cppVisibility() == DefaultVisibility) ? visibility() : cppVisibility()); break; default: // Java if (javaDecl().find("${visibility}") != -1) write_visibility(out, visibility()); break; } write_scope(out); out << ">\n"; out.indent(+1); const UmlTypeSpec & t = type(); if ((t.type != 0) || !t.explicit_type.isEmpty()) { out.indent(); out << "<UML:StructuralFeature.type>\n"; out.indent(); out << "\t<UML:DataType"; switch (_lang) { case Uml: if (t.type != 0) out.idref(t.type); else out.idref_datatype(t.explicit_type); break; case Cpp: write_cpp_type(out); break; default: // java write_java_type(out); } out << "/>\n"; out.indent(); out << "</UML:StructuralFeature.type>\n"; } write_stereotype(out); write_annotation(out); write_description_properties(out); out.indent(-1); out.indent(); out << "</UML:Attribute>\n"; unload(); return TRUE; }
bool UmlOperation::write_if_needed(FileOut & out) { QCString decl; switch (_lang) { case Uml: parent()->write(out); out.indent(); out << "<UML:Operation name=\""; out.quote(name()); break; case Cpp: decl = cppDecl(); if (decl.isEmpty()) return FALSE; remove_comments(decl); parent()->write(out); out.indent(); out << "<UML:Operation name=\""; out.quote(true_name(cppDecl())); break; default: // Java decl = javaDecl(); if (decl.isEmpty()) return FALSE; remove_comments(decl); parent()->write(out); out.indent(); out << "<UML:Operation name=\""; out.quote(true_name(javaDecl())); break; } out << '"'; out.id(this); switch (_lang) { case Uml: write_visibility(out); break; case Cpp: write_visibility(out, (cppVisibility() == DefaultVisibility) ? visibility() : cppVisibility()); break; default: // Java if (javaDecl().find("${visibility}") != -1) write_visibility(out, visibility()); break; } write_scope(out); out << " isAbstract=\"" << ((isAbstract()) ? "true" : "false") << "\">\n"; out.indent(+1); write_stereotype(out); write_annotation(out); write_description_properties(out); out.indent(); out << "<UML:BehavioralFeature.parameter>\n"; out.indent(+1); write_return_type(out, decl); if (_lang == Uml) write_uml_params(out); else write_cpp_java_params(out, decl); out.indent(-1); out.indent(); out << "</UML:BehavioralFeature.parameter>\n"; out.indent(-1); out.indent(); out << "</UML:Operation>\n"; unload(); return TRUE; }
void UmlOperation::import(File & f) { if (scanning) { f.skipBlock(); return; } QByteArray s; UmlTypeSpec t; for (;;) { switch (f.read(s)) { case -1: f.eof(); throw 0; case ')': set_ReturnType(t); return; case ATOM: break; default: f.syntaxError(s); } // atom if (s == "parameters") { f.read("("); f.read("list"); f.read("Parameters"); importParameters(f); } else if (s == "result") { if (f.read(s) != STRING) f.syntaxError(s, "return type"); t.explicit_type = s; } else if (s == "quidu") { if (f.read(s) != STRING) f.syntaxError(s, "wrong quidu"); if (UmlClass::replaceType(t, s, "${type}")) { switch (((UmlClass *) parent())->language()) { case Cplusplus: case AnsiCplusplus: case VCplusplus: set_CppDecl(replace(cppDecl(), "${type}", s)); set_CppDef(replace(cppDef(), "${type}", s)); break; case Oracle8: break; case Corba: set_IdlDecl(replace(idlDecl(), "${type}", s)); break; case Java: set_JavaDecl(replace(javaDecl(), "${type}", s)); break; default: break; } } } else if (s == "exceptions") importExceptions(f); else if (s == "opExportControl") set_Visibility(f.readVisibility()); else f.skipNextForm(); } }
void UmlOperation::generate(QTextStream & f, const WrapperStr & cl_stereotype, WrapperStr indent) { if (!javaDecl().isEmpty()) { const char * p = javaDecl(); const char * pp = 0; const char * afterparam = 0; const Q3ValueList<UmlParameter> & params = this->params(); unsigned rank; const char * body_indent = strstr(p, "${body}"); if (body_indent != 0) { while ((body_indent != p) && ((body_indent[-1] == ' ') || (body_indent[-1] == '\t'))) body_indent -= 1; } // manage old style indent while ((*p == ' ') || (*p == '\t')) indent += *p++; f << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; f << indent; } if (*p == '\n') { f << *p++; if (p == body_indent) p = generate_body(f, indent, p); else if (*p) f << indent; } else if (*p == '{') { if (afterparam != 0) { if (cl_stereotype == "@interface") { if (strstr(afterparam, "default") != 0) afterparam = 0; else { f << ";"; p = bypass_body(p); continue; } } else if (isAbstract() || (cl_stereotype == "interface")) { f << ";"; p = bypass_body(p); continue; } } f << '{'; p += 1; } else if (*p == '@') manage_alias(p, f); else if (*p != '$') { if (p == body_indent) p = generate_body(f, indent, p); else f << *p++; } else if (!strncmp(p, "${comment}", 10)) manage_comment(p, pp, JavaSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${visibility}", 13)) { p += 13; generate_visibility(f, cl_stereotype); } else if (!strncmp(p, "${final}", 8)) { p += 8; if (isJavaFinal()) f << "final "; } else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) f << "static "; } else if (!strncmp(p, "${abstract}", 11)) { p += 11; if (isAbstract() && (cl_stereotype != "interface") && (cl_stereotype != "@interface")) f << "abstract "; } else if (!strncmp(p, "${synchronized}", 15)) { p += 15; if (isJavaSynchronized()) f << "synchronized "; } else if (!strncmp(p, "${type}", 7)) { p += 7; UmlClass::write(f, returnType()); } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; // get/set relation with multiplicity > 1 f << JavaSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${name}", 7)) { p += 7; f << compute_name(); } else if (!strncmp(p, "${(}", 4)) { p += 4; f << '('; } else if (!strncmp(p, "${)}", 4)) { p += 4; f << ')'; afterparam = p; } else if (sscanf(p, "${t%u}", &rank) == 1) { if (!generate_type(params, rank, f)) param_error(parent()->name(), name(), rank); p = strchr(p, '}') + 1; } else if (sscanf(p, "${p%u}", &rank) == 1) { if (!generate_var(params, rank, f)) param_error(parent()->name(), name(), rank); p = strchr(p, '}') + 1; } else if (!strncmp(p, "${throws}", 9)) { p += 9; const char * sep; const Q3ValueList<UmlTypeSpec> & exceptions = this->exceptions(); Q3ValueList<UmlTypeSpec>::ConstIterator it; for (it = exceptions.begin(), sep = " throws "; it != exceptions.end(); ++it, sep = ", ") { f << sep; UmlClass::write(f, *it); } } else if (!strncmp(p, "${staticnl}", 11)) { p += 11; if (isClassMember()) { f << '\n'; if (*p) f << indent; } else f << ' '; } else if (!strncmp(p, "${body}", 7) && (pp == 0)) // not in comment p = generate_body(f, indent, p); else if (!strncmp(p, "${association}", 14)) { p += 14; UmlClassMember * m; if (((m = getOf()) != 0) && (m->kind() == aRelation)) UmlClass::write(f, ((UmlRelation *) m)->association()); else if (((m = setOf()) != 0) && (m->kind() == aRelation)) UmlClass::write(f, ((UmlRelation *) m)->association()); } else if (!strncmp(p, "${@}", 4)) { p += 4; if (pp != 0) f << "${@}"; else if (! javaAnnotations().isEmpty()) { pp = p; p = javaAnnotations(); } } else f << *p++; } f << '\n'; } }
void UmlOperation::importParameters(File & f) { QByteArray s; unsigned rank = 0; const char * sep = ""; QByteArray doc = description(); for (;;) { switch (f.read(s)) { case ')': if (doc != description()) set_Description(doc); return; case '(': // a parameter break; default: f.syntaxError(s); } f.read("object"); f.read("Parameter"); UmlParameter p; QByteArray ti; ti = QString("${t%1}").arg(rank).toLatin1(); if (f.read(p.name) != STRING) f.syntaxError(s, "parameter's name"); QByteArray id; QByteArray ste; QByteArray p_doc; QHash<QByteArray, QByteArray*> prop; int k; for (;;) { k = f.readDefinitionBeginning(s, id, ste, p_doc, prop); if (k == ')') break; if (s == "type") { if (f.read(s) != STRING) f.syntaxError(s, "parameter type"); switch (((UmlClass *) parent())->language()) { case Corba: if (strncmp(s, "in ", 3) == 0) { p.dir = InputDirection; s = s.mid(3); } else if (strncmp(s, "out ", 4) == 0) { p.dir = OutputDirection; s = s.mid(4); } else if (strncmp(s, "inout ", 6) == 0) { p.dir = InputOutputDirection; s = s.mid(6); } else { QByteArray err = "<br>'" + s + "' : wrong parameter direction, in " + f.context(); UmlCom::trace(err); p.dir = InputOutputDirection; } break; default: // !!!!!!!!!!!!! p.dir = InputOutputDirection; } p.type.explicit_type = s; } else if (s == "quidu") { if (f.read(s) != STRING) f.syntaxError(s, "wrong quidu"); if (UmlClass::replaceType(p.type, s, ti)) ti = s; } else f.skipNextForm(); } QByteArray d; int index; switch (((UmlClass *) parent())->language()) { case Cplusplus: case AnsiCplusplus: case VCplusplus: s= QString("%1%2 ${p%3}").arg(sep).arg((const char *) ti).arg(rank).toLatin1(); if ((index = (d = cppDecl()).indexOf("${)}")) != -1) //set_CppDecl(d.insert(index, s));//[jasa] original line set_CppDecl(d.insert(index, (const char *)s)); //[jasa] fix ambiguous call if ((index = (d = cppDef()).indexOf("${)}")) != -1) set_CppDef(d.insert(index, (const char *)s)); //[jasa] fix ambiguous call break; case Oracle8: break; case Corba: if ((index = (d = idlDecl()).indexOf("${)}")) != -1) { s = QString("%1${d%2} %3 ${p%4}").arg( sep).arg(rank).arg((const char *) ti).arg(rank).toLatin1(); set_IdlDecl(d.insert(index, (const char *)s)); //[jasa] fix ambiguous call } break; case Java: if ((index = (d = javaDecl()).indexOf("${)}")) != -1) { s = QString("%s%s ${p%u}").arg( sep).arg( (const char *) ti).arg( rank).toLatin1(); set_JavaDecl(d.insert(index, (const char *)s)); //[jasa] } break; default: break; } addParameter(rank++, p); sep = ", "; } }
bool UmlClass::write_if_needed(FileOut & out) { // even if the class doen't have children parent()->write(out); if ((stereotype() == "actor") || ((parent()->kind() != aClassView) && (parent()->kind() != aClass))) // force it to be an actor write_actor(out); else { switch (_lang) { case Cpp: if (cppDecl().isEmpty()) return FALSE; break; case Java: if (javaDecl().isEmpty()) return FALSE; default: break; } bool interf = (stereotype() == "interface"); out.indent(); out << ((interf) ? "<UML:Interface name=\"" : "<UML:Class name=\""); out.quote(name()); out << '"'; out.id(this); out << " visibility=\"public\" isAbstract=\"" << ((isAbstract()) ? "true" : "false") << "\" isActive=\"false\" >\n"; out.indent(+1); if (! interf) write_stereotype(out); write_annotation(out); write_description_properties(out); const QVector<UmlItem*> ch = children(); unsigned n = ch.size(); bool used = FALSE; bool haveRel = FALSE; for (unsigned i = 0; i != n; i += 1) { switch (ch[i]->kind()) { case aNcRelation: break; case aRelation: haveRel = TRUE; break; default: used |= ch[i]->write_if_needed(out); } } if (used) { out.indent(-1); out.indent(); out << "</UML:Classifier.feature>\n"; } out.indent(-1); out.indent(); out << ((interf) ? "</UML:Interface>\n" : "</UML:Class>\n"); if (haveRel) { for (unsigned i = 0; i != n; i += 1) if (ch[i]->kind() == aRelation) used |= ch[i]->write_if_needed(out); } } unload(); return TRUE; }
const QByteArray & UmlBaseOperation::javaDef() { return javaDecl(); }
void UmlClass::write(FileOut & out) { QCString st = stereotype(); if (st == "metaclass") return; bool is_actor = (st == "actor"); bool is_enum = (st == "enum"); bool is_stereotype = (st == "stereotype") && (parent()->parent()->kind() == aPackage) && (parent()->parent()->stereotype() == "profile"); if (!is_actor) { switch (_lang) { case Cpp: if (cppDecl().isEmpty()) return; break; case Java: if (javaDecl().isEmpty()) return; default: break; } } const char * k = (parent()->kind() == aClass) ? "nestedClassifier" : ((!_uml_20) ? "packagedElement" : ((is_stereotype) ? "ownedStereotype" : "ownedMember")); bool is_assoc_class = (_assoc != 0); out.indent(); out << "<" << k << " xmi:type=\"uml:" << ((is_actor) ? "Actor" : ((is_assoc_class) ? "AssociationClass" : ((st == "interface") ? "Interface" : ((is_enum) ?"Enumeration" : ((is_stereotype) ? "Stereotype" : "Class"))))) << "\" name=\""; out.quote(name()); out << '"'; out.id(this); write_visibility(out); if (isAbstract()) out << " isAbstract=\"true\""; if (isActive()) out << " isActive=\"true\""; out << ">\n"; if (is_assoc_class) _assoc->write_ends(out); out.indent(+1); write_constraint(out); write_annotation(out); write_description_properties(out); if (_gen_extension && (st == "typedef")) { const UmlTypeSpec & base = baseType(); if ((base.type != 0) || !base.explicit_type.isEmpty()) { out.indent(); out << "<xmi:Extension extender=\"Bouml\">\n"; out.indent(); out << "\t<typedef>\n"; out.indent(+2); UmlItem::write_type(out, base, "base"); out.indent(-2); out.indent(); out << "\t</typedef>\n"; out.indent(); out << "</xmi:Extension>\n"; } } write_formals(out); write_actuals(out); const QVector<UmlItem> ch = children(); unsigned n = ch.size(); unsigned i; for (i = 0; i != n; i += 1) ch[i]->write(out); if (is_stereotype) { QCString path; if (propertyValue("stereotypeIconPath", path) && !path.isEmpty()) { out.indent(); out << "<icon xmi:type=\"uml:Image\""; out.id_prefix(this, "Icon_"); out << " location=\"" << path << "\"/>\n"; } } out.indent(-1); out.indent(); out << "</" << k << ">\n"; if (is_stereotype) for (i = 0; i != n; i += 1) if (ch[i]->kind() == aRelation) ((UmlRelation *) ch[i])->write_extension(out); unload(); }
void UmlOperation::write(FileOut & out) { WrapperStr decl; switch (_lang) { case Uml: out.indent(); out << "<ownedOperation xmi:type=\"uml:Operation\" name=\""; out.quote((const char *)name()); //[jasa] ambiguous call break; case Cpp: decl = cppDecl(); if (decl.isEmpty()) return; remove_comments(decl); out.indent(); out << "<ownedOperation xmi:type=\"uml:Operation\" name=\""; out.quote((const char *)true_name(name(), cppDecl())); //[jasa] ambiguous call break; default: // Java decl = javaDecl(); if (decl.isEmpty()) return; remove_comments(decl); out.indent(); out << "<ownedOperation xmi:type=\"uml:Operation\" name=\""; out.quote((const char *)true_name(name(), javaDecl())); //[jasa] ambiguous call break; } out << '"'; out.id(this); write_visibility(out); write_scope(out); if ((_lang == Cpp) && isCppConst()) out << " isQuery=\"true\""; out << " isAbstract=\"" << ((isAbstract()) ? "true" : "false") << "\">\n"; out.indent(+1); write_constraint(out); write_annotation(out); write_description_properties(out); write_exceptions(out); write_return_type(out, decl); if (_lang == Uml) write_uml_params(out); else write_cpp_java_params(out, decl); out.indent(-1); out.indent(); out << "</ownedOperation>\n"; unload(); }