bool Type::operator<(Type const& other) const { // Compares two types and returns true if this type is less than the other, // by doing a name comparison and a recursive comparison of the generics. if (qualified_name() != other.qualified_name()) { return qualified_name()->string() < other.qualified_name()->string(); } Generic* g1 = generics(); Generic* g2 = other.generics(); while (true) { if (!g1 && g2) { return true; } if (g1 && !g2) { return false; } if (!g1 && !g2) { return false; } if (!g1->type()->equals(g2->type())) { return *g1->type() < *g2->type(); } g1 = g1->next(); g2 = g2->next(); } return false; }
bool Type::equals(Type const* other) const { // Make sure the classes are equal if (clazz() != other->clazz()) { return false; } if (other->name() != name()) { return false; } // Make sure the generic parameters are the same Generic* g1 = generics(); Generic* g2 = other->generics(); while (g1 && g2) { if (!g1->type()->equals(g2->type())) { return false; } g1 = g1->next(); g2 = g2->next(); } return true; }
void UmlClass::gen_php_decl(QCString s, bool descr) { QCString st = PhpSettings::classStereotype(stereotype()); if (st == "ignored") return; const char * p = bypass_comment(s); UmlRelation * extend = 0; while (*p != 0) { if (!strncmp(p, "${comment}", 10)) p += 10; else if (!strncmp(p, "${description}", 14)) p += 14; else if (!strncmp(p, "${visibility}", 13)) { p += 13; UmlItem::write(visibility(), phpLanguage); fw.write(' '); } else if (!strncmp(p, "${final}", 8)) { p += 8; if (isPhpFinal()) fw.write("final "); } else if (!strncmp(p, "${abstract}", 11)) { p += 11; if (isAbstract()) fw.write("abstract "); } else if (!strncmp(p, "${name}", 7)) { p += 7; writeq(name()); generics(); } else if (!strncmp(p, "${extends}", 10)) { p += 10; const QVector<UmlItem> ch = children(); for (unsigned i = 0; i != ch.size(); i += 1) { if (ch[i]->kind() == aRelation) { UmlRelation * rel = (UmlRelation *) ch[i]; aRelationKind k = rel->relationKind(); if (((k == aGeneralisation) || (k == aRealization)) && (!rel->phpDecl().isEmpty()) && ((st == "interface") || (PhpSettings::classStereotype(rel->roleType()->stereotype()) != "interface"))) { extend = rel; fw.write(" extends "); rel->roleType()->write(); break; } } } } else if (!strncmp(p, "${implements}", 13)) { p += 13; const QVector<UmlItem> ch = children(); const char * sep = " implements "; for (unsigned i = 0; i != ch.size(); i += 1) { if (ch[i]->kind() == aRelation) { UmlRelation * rel = (UmlRelation *) ch[i]; aRelationKind k = rel->relationKind(); if ((rel != extend) && ((k == aGeneralisation) || (k == aRealization)) && (!rel->phpDecl().isEmpty())) { fw.write(sep); sep = ", "; rel->roleType()->write(); } } } } else if (*p == '\r') p += 1; else if (*p == '\n') { if (descr) { fw.write("<br />"); p += 1; } else { fw.write(' '); do p += 1; while ((*p != 0) && (*p <= ' ')); } } else if ((*p == '{') || (*p == ';')) { if (descr) fw.write(*p++); else break; } else if (*p == '@') manage_alias(p); else writeq(*p++); } }
void UmlClass::gen_java_decl(QByteArray s, bool descr) { const char * p = bypass_comment(s); UmlRelation * extend = 0; while (*p != 0) { if (!strncmp(p, "${comment}", 10)) p += 10; else if (!strncmp(p, "${description}", 14)) p += 14; else if (!strncmp(p, "${public}", 9)) { p += 9; if (isJavaPublic()) fw.write("public "); } else if (!strncmp(p, "${visibility}", 13)) { p += 13; UmlItem::write(visibility(), javaLanguage); fw.write(' '); } else if (!strncmp(p, "${final}", 8)) { p += 8; if (isJavaFinal()) fw.write("final "); } else if (!strncmp(p, "${abstract}", 11)) { p += 11; if (isAbstract()) fw.write("abstract "); } else if (!strncmp(p, "${name}", 7)) { p += 7; writeq(name()); generics(); } else if (!strncmp(p, "${extends}", 10)) { p += 10; const QVector<UmlItem*> ch = children(); for (int i = 0; i != ch.size(); i += 1) { if (ch[i]->kind() == aRelation) { UmlRelation * rel = (UmlRelation *) ch[i]; aRelationKind k = rel->relationKind(); if (((k == aGeneralisation) || (k == aRealization)) && (!rel->javaDecl().isEmpty()) && ((JavaSettings::classStereotype(stereotype()) == "interface") || (JavaSettings::classStereotype(rel->roleType()->stereotype()) != "interface"))) { extend = rel; fw.write(" extends "); rel->roleType()->write(); generate(actuals(), rel->roleType(), FALSE); break; } } } } else if (!strncmp(p, "${implements}", 13)) { p += 13; const QVector<UmlItem*> ch = children(); const char * sep = " implements "; for (int i = 0; i != ch.size(); i += 1) { if (ch[i]->kind() == aRelation) { UmlRelation * rel = (UmlRelation *) ch[i]; aRelationKind k = rel->relationKind(); if ((rel != extend) && ((k == aGeneralisation) || (k == aRealization)) && (!rel->javaDecl().isEmpty())) { fw.write(sep); sep = ", "; rel->roleType()->write(); generate(actuals(), rel->roleType(), FALSE); } } } } else if (!strncmp(p, "${@}", 4)) p += 4; else if (*p == '\r') p += 1; else if (*p == '\n') { if (descr) { fw.write("<br />"); p += 1; } else { fw.write(' '); do p += 1; while ((*p != 0) && (*p <= ' ')); } } else if ((*p == '{') || (*p == ';')) { if (descr) fw.write(*p++); else break; } else if (*p == '@') manage_alias(p); else writeq(*p++); } }