void UmlRelation::compute_dependency(Q3PtrList<CppRefType> & dependencies, const Q3CString & cl_stereotype, bool all_in_h) { if (cl_stereotype == "enum") return; switch (relationKind()) { case aDependency: if (stereotype() == "friend") break; CppRefType::add(roleType(), dependencies, cppDecl() != "#include in source", roleType()->isCppExternal()); break; case aGeneralisation: case aRealization: CppRefType::add(roleType(), dependencies, TRUE); break; default: Q3CString decl = cppDecl(); int index; if ((index = decl.find("${static}")) != -1) decl.remove((unsigned) index, 9); if ((index = decl.find("${mutable}")) != -1) decl.remove((unsigned) index, 10); if ((index = decl.find("${volatile}")) != -1) decl.remove((unsigned) index, 11); if ((index = decl.find("${const}")) != -1) decl.remove((unsigned) index, 8); if ((index = decl.find("${multiplicity}")) != -1) decl.remove((unsigned) index, 15); if ((index = decl.find("${name}")) != -1) decl.remove((unsigned) index, 7); if ((index = decl.find("${inverse_name}")) != -1) decl.remove((unsigned) index, 15); if ((index = decl.find("${value}")) != -1) decl.remove((unsigned) index, 8); if ((index = decl.find("${h_value}")) != -1) decl.remove((unsigned) index, 10); if ((index = decl.find("${stereotype}")) != -1) decl.replace((unsigned) index, 13, CppSettings::relationAttributeStereotype(stereotype())); if ((index = decl.find("${association}")) != -1) { decl.replace((unsigned) index, 14, association().toString()); } replace_alias(decl); UmlTypeSpec type; type.type = roleType(); UmlClassMember::compute_dependency(dependencies, decl, type, all_in_h); } }
void UmlAttribute::write_cpp_type(FileOut & out) { // note : doesn't manage function/operation pointer Q3CString s = cppDecl(); int index; remove_comments(s); // remove keywords not linked to the type if ((index = s.find("${static}")) != -1) s.replace(index, 9, " "); if ((index = s.find("${mutable}")) != -1) s.replace(index, 10, (isCppMutable()) ? "mutable " : ""); if ((index = s.find("${volatile}")) != -1) s.replace(index, 11, (isVolatile()) ? "volatile " : ""); if ((index = s.find("${value}")) != -1) s.replace(index, 8, " "); if ((index = s.find("${h_value}")) != -1) s.replace(index, 10, " "); // replace keywords linked to the type if ((index = s.find("${const}")) != -1) s.replace(index, 8, isReadOnly() ? "const" : ""); UmlTypeSpec t = type(); if (t.type == 0) t.explicit_type = CppSettings::type(t.explicit_type); write_type(out, t, s, "${name}", "${type}"); }
void UmlClass::generate_def(QTextStream & f, WrapperStr indent, bool h, WrapperStr templates, WrapperStr cl_names, WrapperStr, WrapperStr) { QLOG_INFO() << "generating definition"; //QsLogging::Logger::instance(). if (! cppDecl().isEmpty()) { WrapperStr template1; WrapperStr template2; WrapperStr templates_tmplop; WrapperStr cl_names_tmplop; get_template_prefixes(template1, template2); templates_tmplop = templates + "template<>\n"; templates += template1; cl_names_tmplop = cl_names + "::" + name()/* true_name */; cl_names = cl_names_tmplop + template2; QVector<UmlItem*> ch = children(); for (int index = 0; index != ch.size(); index += 1) if (ch[index]->kind() != aNcRelation) ((UmlClassItem *) ch[index]) ->generate_def(f, indent, h, templates, cl_names, templates_tmplop, cl_names_tmplop); } }
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 (!isCppExternal() && !cppDecl().isEmpty()) { if (associatedArtifact() == 0) { if (verbose()) UmlCom::trace(Q3CString("<hr><font face=helvetica><i> ") + name() + " : </i> does not have associated <i>artifact</i></font><br>"); } else if (cppDecl().isEmpty()) { if (verbose()) UmlCom::trace(Q3CString("<hr><font face=helvetica>class <i>") + name() + "</i> has an empty C++ definition</font><br>"); } else associatedArtifact()->generate(); } } }
void UmlOperation::defaultDef() { if (cppDecl().isEmpty()) set_CppDecl(CppSettings::operationDecl()); if (isAbstract()) set_CppDef(""); else if (cppDef().isEmpty()) set_CppDef(CppSettings::operationDef()); setUsed(); }
void UmlExtraClassMember::generate_decl(aVisibility &, QTextStream & f_h, const Q3CString &, Q3CString indent, BooL & first, bool) { first = FALSE; const char * p = cppDecl(); if (*p != '#') f_h << indent; f_h << p; }
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::generate_def(QTextOStream & f, Q3CString indent, bool h) { if (! cppDecl().isEmpty()) { Q3PtrVector<UmlItem> ch = children(); Q3CString templates; Q3CString cl_names; Q3CString templates_tmplop; Q3CString cl_names_tmplop; spec(templates, cl_names, templates_tmplop, cl_names_tmplop); for (unsigned index = 0; index != ch.size(); index += 1) if (ch[index]->kind() != aNcRelation) ((UmlClassItem *) ch[index]) ->generate_def(f, indent, h, templates, cl_names, templates_tmplop, cl_names_tmplop); } }
void UmlClass::generate_def(QTextStream & f, WrapperStr indent, bool h) { if (! cppDecl().isEmpty()) { QVector<UmlItem*> ch = children(); WrapperStr templates; WrapperStr cl_names; WrapperStr templates_tmplop; WrapperStr cl_names_tmplop; spec(templates, cl_names, templates_tmplop, cl_names_tmplop); for (int index = 0; index != ch.size(); index += 1) if (ch[index]->kind() != aNcRelation) ((UmlClassItem *) ch[index]) ->generate_def(f, indent, h, templates, cl_names, templates_tmplop, cl_names_tmplop); } }
void UmlOperation::setParams(const char * s) { QByteArray d; int index; d = cppDecl(); if (((index = d.indexOf("${(}")) != -1) && (d.mid(index + 4, 4) == "${)}")) { d.insert(d.indexOf("${(}") + 4, s); set_CppDecl(d); } d = cppDef(); if (((index = d.indexOf("${(}")) != -1) && (d.mid(index + 4, 4) == "${)}")) { d.insert(d.indexOf("${(}") + 4, s); set_CppDef(d); } }
void UmlOperation::rename_jdk5() { QCString s; bool changed = FALSE; bool javasettings = (parent()->name() == "JavaSettings"); s = cppDecl(); if (rename(s, FALSE, javasettings)) { changed = TRUE; set_CppDecl(s); } s = cppDef(); if (rename(s, FALSE, javasettings)) { changed = TRUE; set_CppDef(s); } s = cppBody(); if (rename(s, FALSE, javasettings)) { changed = TRUE; set_CppBody(s); } s = javaDef(); if (rename(s, TRUE, javasettings)) { changed = TRUE; set_JavaDef(s); } s = javaBody(); if (rename(s, TRUE, javasettings)) { changed = TRUE; set_JavaBody(s); } if (changed) UmlCom::trace(parent()->name() + "::" + name() + " upgraded to take into account the rename of 'enum' to 'enum pattern'<br>\n"); }
void UmlAttribute::compute_dependency(Q3PtrList<CppRefType> & dependency, const Q3CString & cl_stereotype, bool all_in_h) { if ((cl_stereotype == "enum") || (cl_stereotype == "typedef")) return; Q3CString decl = cppDecl(); int index; if ((index = decl.find("${static}")) != -1) decl.remove((unsigned) index, 9); if ((index = decl.find("${mutable}")) != -1) decl.remove((unsigned) index, 10); if ((index = decl.find("${volatile}")) != -1) decl.remove((unsigned) index, 11); if ((index = decl.find("${const}")) != -1) decl.remove((unsigned) index, 8); if ((index = decl.find("${multiplicity}")) != -1) decl.remove((unsigned) index, 15); if ((index = decl.find("${value}")) != -1) decl.remove((unsigned) index, 8); if ((index = decl.find("${h_value}")) != -1) decl.remove((unsigned) index, 10); if ((index = decl.find("${name}")) != -1) decl.remove((unsigned) index, 7); if ((index = decl.find("${stereotype}")) != -1) decl.replace((unsigned) index, 13, CppSettings::relationAttributeStereotype(stereotype())); replace_alias(decl); if (!UmlClassMember::compute_dependency(dependency, decl, type(), all_in_h)) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>type missing for attribute <i>") + name() + "</i></b></font><br>"); incr_error(); } }
void UmlClass::generate_def(QTextOStream & f, Q3CString indent, bool h, Q3CString templates, Q3CString cl_names, Q3CString, Q3CString) { if (! cppDecl().isEmpty()) { Q3CString template1; Q3CString template2; Q3CString templates_tmplop; Q3CString cl_names_tmplop; get_template_prefixes(template1, template2); templates_tmplop = templates + "template<>\n"; templates += template1; cl_names_tmplop = cl_names + "::" + name()/* true_name */; cl_names = cl_names_tmplop + template2; Q3PtrVector<UmlItem> ch = children(); for (unsigned index = 0; index != ch.size(); index += 1) if (ch[index]->kind() != aNcRelation) ((UmlClassItem *) ch[index]) ->generate_def(f, indent, h, templates, cl_names, templates_tmplop, cl_names_tmplop); } }
void UmlOperation::setType(UmlClass * type, const char * s) { UmlTypeSpec t; t.type = type; set_ReturnType(t); static const QByteArray sep = " \t\n\r"; QByteArray d; int typeindex; int nameindex; d = cppDecl(); if (((typeindex = d.indexOf("${type}")) != -1) && ((nameindex = d.indexOf("${name}", typeindex + 7)) != -1)) { while (sep.indexOf(d[nameindex - 1]) != -1) nameindex -= 1; d.replace(typeindex, nameindex - typeindex, s); set_CppDecl(d); } if (! isAbstract()) { d = cppDef(); if (((typeindex = d.indexOf("${type}")) != -1) && ((nameindex = d.indexOf("${class}", typeindex + 7)) != -1)) { while (sep.indexOf(d[nameindex - 1]) != -1) nameindex -= 1; d.replace(typeindex, nameindex - typeindex, s); set_CppDef(d); } } }
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 UmlAttribute::generate_decl(aVisibility & current_visibility, QTextOStream & f_h, const Q3CString & cl_stereotype, Q3CString indent, BooL & first, bool last) { if (cl_stereotype == "typedef") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>a <i>typedef</i> cannot have attribute</b></font><br>"); incr_warning(); return; } const char * p = cppDecl(); const char * pp = 0; bool in_enum = (cl_stereotype == "enum"); if (!in_enum) generate_visibility(current_visibility, f_h, first, indent); first = FALSE; while ((*p == ' ') || (*p == '\t')) indent += *p++; if (*p != '#') f_h << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; if (*p != '#') f_h << indent; } if (*p == '\n') { f_h << *p++; if (*p && (*p != '#')) f_h << indent; } else if (*p == '@') manage_alias(p, f_h); else if (*p != '$') f_h << *p++; else if (!strncmp(p, "${comment}", 10)) manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${name}", 7)) { p += 7; f_h << name(); } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; const Q3CString & m = multiplicity(); if (!m.isEmpty() && (*((const char *) m) == '[')) f_h << m; else f_h << '[' << m << ']'; } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f_h << CppSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${value}", 8) || !strncmp(p, "${h_value}", 10)) { const char * pb = p; p += (p[2] == 'h') ? 10 : 8; if (in_enum) { if (!defaultValue().isEmpty()) { if (need_equal(pb, defaultValue())) f_h << " = "; f_h << defaultValue(); } if (last) { if (*p == ',') p += 1; } else if (*p != ',') f_h << ','; } else if ((p[-8] == 'h') && isClassMember() && !defaultValue().isEmpty()) { if (need_equal(pb, defaultValue())) f_h << " = "; f_h << defaultValue(); } } else if (in_enum) // strange f_h << *p++; else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) f_h << "static "; } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) f_h << "const "; } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) f_h << "volatile "; } else if (!strncmp(p, "${mutable}", 10)) { p += 10; if (isCppMutable()) f_h << "mutable "; } else if (!strncmp(p, "${type}", 7)) { p += 7; UmlClass::write(f_h, type()); //f_h << CppSettings::Type(Type().Type()); } else // strange f_h << *p++; } f_h << '\n'; }
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; }
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 UmlRelation::generate_def(QTextStream & f, WrapperStr indent, bool h, WrapperStr templates, WrapperStr cl_names, WrapperStr, WrapperStr) { if (isClassMember() && !cppDecl().isEmpty()) { UmlClass * cl = (UmlClass *) parent(); if ((!templates.isEmpty() || (cl->name().find('<') != -1)) ? h : !h) { const char * p = cppDecl(); const char * pp = 0; while ((*p == ' ') || (*p == '\t')) p += 1; bool re_template = !templates.isEmpty() && insert_template(p, f, indent, templates); if (*p != '#') f << indent; const char * pname = name_spec(p); for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (re_template) f << templates; if (*p == 0) break; if (*p != '#') f << indent; } if (*p == '\n') { f << toLocale(p); if (*p && (*p != '#')) f << indent; } else if (*p == '@') manage_alias(p, f); else if (*p != '$') { if (p == pname) f << cl_names << "::"; f << toLocale(p); } else if (!strncmp(p, "${comment}", 10)) { if (!manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment()) && re_template) f << templates; } else if (!strncmp(p, "${description}", 14)) { if (!manage_description(p, pp) && re_template) f << templates; } else if (!strncmp(p, "${static}", 9)) { p += 9; } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) f << "const "; } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) f << "volatile "; } else if (!strncmp(p, "${mutable}", 10)) { p += 10; } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(f); } else if (!strncmp(p, "${name}", 7)) { p += 7; if (*pname == '$') f << cl_names << "::"; 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; const WrapperStr & m = multiplicity(); if (!m.isEmpty() && (*((const char *) m) == '[')) f << m; else f << '[' << m << ']'; } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f << CppSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${value}", 8)) { if (!defaultValue().isEmpty()) { if (need_equal(p, defaultValue())) f << " = "; f << defaultValue(); } p += 8; } else if (!strncmp(p, "${h_value}", 10)) p += 10; else if (!strncmp(p, "${association}", 14)) { p += 14; UmlClass::write(f, association()); } else // strange f << toLocale(p); } f << '\n'; } } }
void UmlRelation::generate_decl(aVisibility & current_visibility, QTextStream & f_h, const WrapperStr & cl_stereotype, WrapperStr indent, BooL & first, bool) { switch (relationKind()) { case aDependency: if (stereotype() == "friend") { Q3ValueList<UmlFormalParameter> formals = roleType()->formals(); if (! formals.isEmpty()) { const char * sep = " template <"; Q3ValueList<UmlFormalParameter>::ConstIterator it; for (it = formals.begin(); it != formals.end(); ++it) { f_h << sep << (*it).type() << ' ' << (*it).name(); sep = ", "; } f_h << "> "; } else f_h << " "; f_h << "friend " << roleType()->cpp_stereotype() << " "; roleType()->write(f_h, FALSE); f_h << ";\n"; first = FALSE; } break; case aGeneralisation: case aRealization: break; default: if (!cppDecl().isEmpty()) { if (cl_stereotype == "enum") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>an <i>enum</i> cannot have relation</b></font><br>"); incr_warning(); return; } if (cl_stereotype == "typedef") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>a <i>typedef</i> cannot have relation</b></font><br>"); incr_warning(); return; } generate_visibility(current_visibility, f_h, first, indent); first = FALSE; const char * p = cppDecl(); const char * pp = 0; WrapperStr s; while ((*p == ' ') || (*p == '\t')) indent += toLocale(p); if (*p != '#') f_h << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; if (*p != '#') f_h << indent; } if (*p == '\n') { f_h << toLocale(p); if (*p && (*p != '#')) f_h << indent; } else if (*p == '@') manage_alias(p, f_h); else if (*p != '$') f_h << toLocale(p); else if (!strncmp(p, "${comment}", 10)) manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) f_h << "static "; } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) f_h << "const "; } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) f_h << "volatile "; } else if (!strncmp(p, "${mutable}", 10)) { p += 10; if (isCppMutable()) f_h << "mutable "; } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(f_h); } else if (!strncmp(p, "${name}", 7)) { p += 7; f_h << roleName(); } else if (!strncmp(p, "${inverse_name}", 15)) { p += 15; switch (relationKind()) { case anAssociation: case anAggregation: case anAggregationByValue: f_h << side(side(TRUE) != this)->roleName(); default: break; } } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; const WrapperStr & m = multiplicity(); if (!m.isEmpty() && (*((const char *) m) == '[')) f_h << m; else f_h << '[' << m << ']'; } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f_h << CppSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${value}", 8)) p += 8; else if (!strncmp(p, "${h_value}", 10)) { if (!defaultValue().isEmpty() && isClassMember()) { if (need_equal(p, defaultValue())) f_h << " = "; f_h << defaultValue(); } p += 10; } else if (!strncmp(p, "${association}", 14)) { p += 14; UmlClass::write(f_h, association()); } else // strange f_h << toLocale(p); } f_h << '\n'; } } }
void UmlRelation::generate_inherit(const char *& sep, QTextStream & f_h, const Q3ValueList<UmlActualParameter> & actuals, const WrapperStr & cl_stereotype) { switch (relationKind()) { default: break; case aGeneralisation: case aRealization: if ((cl_stereotype == "union") || (cl_stereotype == "enum")) { write_trace_header(); UmlCom::trace(WrapperStr(" <font color=\"red\"><b>an <i>") + cl_stereotype + "</i> cannot inherits</b></font><br>"); incr_warning(); return; } else if (cl_stereotype == "typedef") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>a <i>typedef</i> cannot inherits</b></font><br>"); incr_warning(); return; } UmlClass * role_type = roleType(); const WrapperStr & other_stereotype = role_type->stereotype(); if ((other_stereotype == "union") || (other_stereotype == "enum")) { write_trace_header(); UmlCom::trace(WrapperStr(" <font color=\"red\"><b>cannot inherits an <i>") + other_stereotype + "</i></b></font><br>"); incr_warning(); return; } f_h << sep; sep = ", "; if (cppVirtualInheritance()) f_h << "virtual "; aVisibility visibility = (cppVisibility() == DefaultVisibility) ? this->visibility() : cppVisibility(); switch (visibility) { case PublicVisibility: case PackageVisibility: f_h << "public "; break; case ProtectedVisibility: f_h << "protected "; break; default: f_h << "private "; } const char * p = cppDecl(); while (*p) { if (!strncmp(p, "${type}", 7)) { role_type->write(f_h, FALSE, 0, actuals); p += 7; } else if (*p == '@') manage_alias(p, f_h); else f_h << toLocale(p); } } }
void UmlClassMember::setComment(Q3CString s) { set_Description(((cppDecl().find("${description}") != -1) ? "// " : " ") + s); }
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); }
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"); }
void UmlClass::compute_dependency(Q3PtrList<CppRefType> & dependencies, const Q3CString &, bool all_in_h) { Q3PtrVector<UmlItem> ch = children(); const Q3CString stereotype = cpp_stereotype(); bool a_typedef = (stereotype == "typedef"); bool an_enum = (stereotype == "enum"); const Q3ValueList<UmlFormalParameter> formals = this->formals(); const Q3ValueList<UmlActualParameter> actuals = this->actuals(); if (!formals.isEmpty()) // template class, force depend in h all_in_h = TRUE; for (unsigned index = 0; index != ch.size(); index += 1) { if (ch[index]->kind() != aNcRelation) { UmlClassItem * it = (UmlClassItem *) ch[index]; if (! it->cppDecl().isEmpty()) it->compute_dependency(dependencies, stereotype, all_in_h); } } if (an_enum && (!formals.isEmpty() || !actuals.isEmpty())) { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b><i>template enum</i></b></font><br>"); incr_warning(); } else if (a_typedef && !formals.isEmpty()) { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b><i>template typedef</i></b></font><br>"); incr_warning(); } else { Q3ValueList<UmlFormalParameter>::ConstIterator itf; for (itf = formals.begin(); itf != formals.end(); ++itf) CppRefType::remove((*itf).name(), dependencies); Q3ValueList<UmlActualParameter>::ConstIterator ita; for (ita = actuals.begin(); ita != actuals.end(); ++ita) UmlClassMember::compute_dependency(dependencies, "${type}", (*ita).value(), all_in_h); if (a_typedef) { Q3CString decl = cppDecl(); int index; remove_comments(decl); if ((index = decl.find("${name}")) != -1) decl.remove((unsigned) index, 7); replace_alias(decl); UmlClassMember::compute_dependency(dependencies, decl, baseType(), all_in_h); } } if ((associatedArtifact() == 0) || (associatedArtifact()->associatedClasses().count() == 1)) CppRefType::remove(this, dependencies); else CppRefType::force_ref(this, dependencies); }
void UmlClass::generate_decl(QTextOStream & f_h, Q3CString indent) { context.append(this); bool removed = FALSE; Q3PtrVector<UmlItem> ch = children(); const unsigned sup = ch.size(); const Q3CString & stereotype = cpp_stereotype(); bool a_typedef = (stereotype == "typedef"); bool an_enum = (stereotype == "enum"); const Q3ValueList<UmlFormalParameter> formals = this->formals(); const Q3ValueList<UmlActualParameter> actuals = this->actuals(); unsigned index; const char * p = cppDecl(); const char * pp = 0; const char * sep; bool nestedp = parent()->kind() == aClass; if (nestedp) indent += " "; while ((*p == ' ') || (*p == '\t')) indent += *p++; if (*p != '#') f_h << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; if (*p != '#') f_h << indent; } if (*p == '\n') { f_h << *p++; if (*p && (*p != '#') && strncmp(p, "${members}", 10) && strncmp(p, "${items}", 8)) f_h << indent; } else if (*p == '@') manage_alias(p, f_h); else if (*p != '$') f_h << *p++; else if (!strncmp(p, "${comment}", 10)) manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (! strncmp(p, "${name}", 7)) { p += 7; f_h << name(); } else if (a_typedef) { if (!strncmp(p, "${type}", 7)) { p += 7; UmlClass::write(f_h, baseType(), FALSE); UmlClass * cl = baseType().type; if ((cl != 0) && !actuals.isEmpty()) { Q3ValueList<UmlActualParameter>::ConstIterator ita; BooL need_space = FALSE; for (ita = actuals.begin(); ita != actuals.end(); ++ita) if ((*ita).superClass() == cl) if (! (*ita).generate(f_h, need_space)) // no specified value break; if (need_space) f_h << " >"; else f_h << '>'; } } else // strange f_h << *p++; } else if (an_enum) { if (!strncmp(p, "${items}", 8)) { p += 8; // items declaration aVisibility current_visibility = DefaultVisibility; unsigned max = sup - 1; BooL first = TRUE; for (index = 0; index < sup; index += 1) { UmlItem * it = ch[index]; switch (it->kind()) { case aClass: case aNcRelation: break; default: if (! ((UmlClassItem *) it)->cppDecl().isEmpty()) ((UmlClassItem *) it)->generate_decl(current_visibility, f_h, stereotype, indent, first, index == max); } } if (*p == '}') f_h << indent; } else // strange f_h << *p++; } else if (! strncmp(p, "${template}", 11)) { p += 11; // template if (!formals.isEmpty()) { sep = "template<"; const char * sep2 = "<"; BooL need_space = FALSE; Q3ValueList<UmlFormalParameter>::ConstIterator itf; for (itf = formals.begin(); itf != formals.end(); ++itf) (*itf).generate(f_h, sep, sep2, need_space); f_h << ((need_space) ? " >\n" : ">\n"); if (nestedp) f_h << indent; } else if (name().find('<') != -1) { f_h << "template<>\n"; if (nestedp) f_h << indent; } } else if (! strncmp(p, "${inherit}", 10)) { p += 10; // inherit sep = " : "; for (index = 0; index != sup; index += 1) { UmlItem * x = ch[index]; if ((x->kind() == aRelation) && !((UmlRelation *) ch[index])->cppDecl().isEmpty()) ((UmlRelation *) x)->generate_inherit(sep, f_h, actuals, stereotype); } } else if (! strncmp(p, "${members}", 10)) { p += 10; // members declaration aVisibility current_visibility; current_visibility = ((stereotype == "struct") || (stereotype == "union")) ? PublicVisibility : DefaultVisibility; unsigned last = sup - 1; BooL first = TRUE; for (index = 0; index != sup; index += 1) { UmlItem * it = ch[index]; if ((it->kind() != aNcRelation) && ! ((UmlClassItem *) it)->cppDecl().isEmpty()) ((UmlClassItem *) it)->generate_decl(current_visibility, f_h, stereotype, indent, first, index == last); } if (*p == '}') f_h << indent; } else if (!strncmp(p, "${inlines}", 10)) { p += 10; context.removeLast(); removed = TRUE; if (! nestedp) { // inline operations definition // template class members Q3CString templates; Q3CString cl_names; Q3CString templates_tmplop; Q3CString cl_names_tmplop; spec(templates, cl_names, templates_tmplop, cl_names_tmplop); for (index = 0; index != sup; index += 1) if (ch[index]->kind() != aNcRelation) ((UmlClassItem *) ch[index]) ->generate_def(f_h, indent, TRUE, templates, cl_names, templates_tmplop, cl_names_tmplop); } if (*p == '\n') p += 1; } else // strange f_h << *p++; } if (! removed) context.removeLast(); }
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 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 UmlClass::write(QTextOStream & f, bool with_formals, BooL * is_template, const Q3ValueList<UmlActualParameter> & actuals) { if (context.findRef(this) == -1) { if (parent()->kind() == aClass) { if (context.findRef((UmlClass *) parent()) == -1) { // parent cannot have formals, but may have actuals ((UmlClass *) parent())->write(f, FALSE, 0, actuals); f << "::"; } } else { UmlArtifact * cp = associatedArtifact(); Q3CString nasp = ((UmlPackage *) ((cp != 0) ? (UmlItem *) cp : (UmlItem *) this)->package()) ->cppNamespace(); if (CppSettings::isForceNamespacePrefixGeneration() || (nasp != UmlArtifact::generation_package()->cppNamespace())) f << nasp << "::"; } } Q3CString s; if (isCppExternal()) { s = cppDecl(); int index = s.find('\n'); s = (index == -1) ? s.stripWhiteSpace() : s.left(index).stripWhiteSpace(); 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()); } else s = name(); // true_name if (! s.isEmpty()){ f << s; if (is_template != 0) *is_template = (s.at(s.length() - 1) == '>'); } else if (is_template != 0) *is_template = FALSE; if (with_formals) { Q3ValueList<UmlFormalParameter> formals = this->formals(); if (! formals.isEmpty()) { const char * sep = "<"; Q3ValueList<UmlFormalParameter>::ConstIterator it; for (it = formals.begin(); it != formals.end(); ++it) { f << sep << (*it).name(); sep = ", "; } f << '>'; if (is_template != 0) *is_template = TRUE; } } else if (!actuals.isEmpty()) { Q3ValueList<UmlActualParameter>::ConstIterator ita; BooL need_space = FALSE; bool used = FALSE; for (ita = actuals.begin(); ita != actuals.end(); ++ita) { if ((*ita).superClass() == this) { used = TRUE; (*ita).generate(f, need_space); } } if (used) { if (need_space) f << " >"; else f << '>'; if (is_template != 0) *is_template = TRUE; } } }