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 UmlRelation::generate_implements(const char *& sep, QTextStream & f, const Q3CString & cl_stereotype) { switch (relationKind()) { default: return; case aGeneralisation: case aRealization: if (phpDecl().isEmpty()) return; UmlClass * role_type = roleType(); const Q3CString & other_stereotype = role_type->php_stereotype(); if (other_stereotype == "interface") { if (cl_stereotype == "union") { 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 = phpDecl(); while (*p) { if (!strncmp(p, "${type}", 7)) { role_type->write(f); p += 7; } else if (*p == '@') manage_alias(p, f); else f << *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 UmlOperation::generate_require_onces(QTextStream & f, WrapperStr & made) { WrapperStr s = phpDecl(); if (!s.isEmpty()) { UmlArtifact * art = ((UmlClass *) parent())->assocArtifact(); returnType().generate_require_onces(f, made, art); int index1 = s.find("${(}"); if (index1 == -1) return; index1 += 4; int index2 = s.find("${)}", index1); if (index2 == -1) return; s = s.mid((unsigned) index1, (unsigned)(index2 - index1)); const Q3ValueList<UmlParameter> & params = this->params(); Q3ValueListConstIterator<UmlParameter> it; unsigned rank; char ti[16]; strcpy(ti, "${p"); for (it = params.begin(), rank = 0; it != params.end(); ++it, rank += 1) { sprintf(ti + 3, "%u}", rank); if (s.find(ti) != -1) (*it).type.generate_require_onces(f, made, art); } } }
void UmlAttribute::generate(QTextStream & f, const WrapperStr & st, WrapperStr indent, int & enum_item_rank) { if (!phpDecl().isEmpty()) { const char * p = phpDecl(); const char * pp = 0; 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, PhpSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${visibility}", 13)) { p += 13; generate_visibility(f); } else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) f << "static "; } else if (!strncmp(p, "${type}", 7)) { p += 7; UmlClass::write(f, type()); } else if (!strncmp(p, "${name}", 7)) { p += 7; if ((st != "enum") && !isReadOnly()) f << "$"; f << name(); } else if (!strncmp(p, "${var}", 6)) { p += 6; if ((st != "enum") && !isReadOnly() && !isClassMember() && (visibility() == PackageVisibility)) f << "var "; } else if (!strncmp(p, "${value}", 8)) { if (!defaultValue().isEmpty()) { if (need_equal(p, defaultValue())) f << " = "; f << defaultValue(); } else if (st == "enum") f << " = " << enum_item_rank; p += 8; } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) f << "const "; } else f << *p++; } f << '\n'; } enum_item_rank += 1; }
void UmlAttribute::generate_require_onces(QTextStream & f, WrapperStr & made) { if (!phpDecl().isEmpty()) type().generate_require_onces(f, made, ((UmlClass *) parent())->assocArtifact()); }
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); }
const WrapperStr & UmlBaseOperation::phpDef() { return phpDecl(); }
void UmlExtraClassMember::generate(QTextOStream & f, const QCString &, QCString, int &) { f << phpDecl(); }
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 UmlOperation::generate(QTextStream & f, const WrapperStr & cl_stereotype, WrapperStr indent, int &) { if (!phpDecl().isEmpty()) { const char * p = phpDecl(); 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 (isAbstract() || (cl_stereotype == "interface")) { f << ";"; break; } else { 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, PhpSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${visibility}", 13)) { p += 13; generate_visibility(f); } else if (!strncmp(p, "${final}", 8)) { p += 8; if (isPhpFinal()) 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")) f << "abstract "; } 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 (sscanf(p, "${v%u}", &rank) == 1) { if (!generate_init(params, rank, f)) param_error(parent()->name(), name(), rank); p = strchr(p, '}') + 1; } 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, "${type}", 7)) { p += 7; UmlClass::write(f, returnType()); } else f << *p++; } f << '\n'; } }
const QCString & UmlBaseOperation::phpDef() { return phpDecl(); }
void UmlRelation::generate_extends(const char *& sep, QTextStream & f, const Q3CString & cl_stereotype) { switch (relationKind()) { default: return; case aGeneralisation: case aRealization: if (phpDecl().isEmpty()) return; UmlClass * role_type = roleType(); const Q3CString & other_stereotype = role_type->php_stereotype(); if ((cl_stereotype == "interface") || (cl_stereotype == "@interface")) { if ((other_stereotype != "interface") && (other_stereotype != "@interface")) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>cannot extends a <i>") + other_stereotype + "</i></b></font><br>"); incr_warning(); return; } } else if ((other_stereotype != "interface") && (other_stereotype != "@interface")) { if (cl_stereotype == "union") { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>an <i>") + cl_stereotype + "</i> cannot extends</b></font><br>"); incr_warning(); return; } else if ((other_stereotype == "union") || (other_stereotype == "enum")) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>cannot extends an <i>") + other_stereotype + "</i></b></font><br>"); incr_warning(); return; } else if (*sep == ',') { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>extend several classes</b></font><br>"); incr_warning(); return; } } else return; // here the code is legal f << sep; sep = ", "; const char * p = phpDecl(); while (*p) { if (!strncmp(p, "${type}", 7)) { role_type->write(f); p += 7; } else if (*p == '@') manage_alias(p, f); else f << *p++; } } }
void UmlRelation::generate_require_onces(QTextStream & f, Q3CString & made) { if (!phpDecl().isEmpty()) roleType()->generate_require_onces(f, made, ((UmlClass *) parent())->assocArtifact()); }
void UmlRelation::generate(QTextStream & f, const Q3CString &, Q3CString indent, int &) { switch (relationKind()) { case aDependency: case aGeneralisation: case aRealization: break; default: if (!phpDecl().isEmpty()) { const char * p = phpDecl(); 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, PhpSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${visibility}", 13)) { p += 13; generate_visibility(f); } else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) f << "static "; } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(f); } else if (!strncmp(p, "${name}", 7)) { p += 7; if (!isReadOnly()) f << "$"; f << roleName(); } else if (!strncmp(p, "${inverse_name}", 15)) { p += 15; switch (relationKind()) { case anAssociation: case anAggregation: case anAggregationByValue: { UmlRelation * inverse = side(side(TRUE) != this); if (!inverse->isReadOnly()) f << "$"; f << inverse->roleName(); } default: break; } } else if (!strncmp(p, "${var}", 6)) { p += 6; if (!isReadOnly() && !isClassMember() && (visibility() == PackageVisibility)) f << "var "; } else if (!strncmp(p, "${value}", 8)) { if (!defaultValue().isEmpty()) { if (need_equal(p, defaultValue())) f << " = "; f << defaultValue(); } p += 8; } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) f << "const "; } else f << *p++; } f << '\n'; } } }
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); }