WrapperStr UmlOperation::compute_name() { WrapperStr get_set_spec = phpNameSpec(); if (! get_set_spec.isEmpty()) { UmlClassMember * it; if ((it = getOf()) == 0) it = setOf(); int index; WrapperStr s = (it->kind() == aRelation) ? ((UmlRelation *) it)->roleName() : it->name(); if ((index = get_set_spec.find("${name}")) != -1) get_set_spec.replace(index, 7, s); else if ((index = get_set_spec.find("${Name}")) != -1) get_set_spec.replace(index, 7, capitalize(s)); else if ((index = s.find("${NAME}")) != -1) get_set_spec.replace(index, 7, s.upper()); else if ((index = s.find("${nAME}")) != -1) get_set_spec.replace(index, 7, s.lower()); return get_set_spec; } else return name(); }
void UmlOperation::gen_php_decl(QByteArray s, bool descr) { QByteArray cl_stereotype = PhpSettings::classStereotype(parent()->stereotype()); const char * p = bypass_comment(s); const QList<UmlParameter> & pa = params(); unsigned npa = pa.count(); unsigned rank; while (*p) { if (!strncmp(p, "${comment}", 10)) p += 10; else if (!strncmp(p, "${description}", 14)) p += 14; else if (!strncmp(p, "${final}", 8)) { p += 8; if (isPhpFinal()) fw.write("final "); } else if (!strncmp(p, "${visibility}", 13)) { p += 13; UmlItem::write(visibility(), phpLanguage); fw.write(' '); } else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) fw.write("static "); } else if (!strncmp(p, "${abstract}", 11)) { p += 11; if (isAbstract() && (cl_stereotype != "interface")) fw.write("abstract "); } else if (!strncmp(p, "${name}", 7)) { p += 7; writeq(compute_name(phpNameSpec())); } else if (!strncmp(p, "${(}", 4)) { p += 4; fw.write('('); } else if (!strncmp(p, "${)}", 4)) { p += 4; fw.write(')'); } else if (!strncmp(p, "${staticnl}", 11)) break; else if (sscanf(p, "${t%u}", &rank) == 1) { p = strchr(p, '}') + 1; if (rank < npa) write(pa[rank].type, phpLanguage); else fw.write("???"); } else if (sscanf(p, "${p%u}", &rank) == 1) { p = strchr(p, '}') + 1; if (rank < npa) { fw.write('$'); writeq(pa[rank].name); } else fw.write("???"); } else if (sscanf(p, "${v%u}", &rank) == 1) { p = strchr(p, '}') + 1; if (rank >= npa) fw.write("???"); else if (! pa[rank].default_value.isEmpty()) { fw.write(" = "); writeq(pa[rank].default_value); } } 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++); } }