Ejemplo n.º 1
0
void UmlClass::gen_python_decl(QByteArray s, bool descr)
{
    QByteArray st = PythonSettings::classStereotype(stereotype());

    if (st == "ignored")
        return;

    const char * p = bypass_comment(s);

    while (*p != 0) {
        if (!strncmp(p, "${comment}", 10))
            p += 10;
        else if (!strncmp(p, "${description}", 14))
            p += 14;
        else if (!strncmp(p, "${docstring}", 12))
            p += 12;
        else if (!strncmp(p, "${name}", 7)) {
            p += 7;
            writeq(name());
        }
        else if (!strncmp(p, "${inherit}", 10)) {
            p += 10;

            const QVector<UmlItem*> ch = children();
            bool inh = FALSE;

            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->pythonDecl().isEmpty()) {
                        if (inh)
                            fw.write(", ");
                        else  {
                            inh = TRUE;
                            fw.write('(');
                        }

                        rel->roleType()->write();
                    }
                }
            }

            if (inh)
                fw.write(')');
            else if (isPython_2_2())
                fw.write("(object)");

            break;
        }
        else if (!descr && ((*p == '\r') || (*p == '\n') || (*p == ':')))
            break;
        else if (*p == '@')
            manage_alias(p);
        else
            writeq(*p++);
    }
}
Ejemplo n.º 2
0
void UmlRelation::gen_python_decl(QByteArray s)
{
    QByteArray st = PythonSettings::classStereotype(stereotype());
    const char * p = bypass_comment(s);

    while (*p) {
        if (!strncmp(p, "${comment}", 10))
            p += 10;
        else if (!strncmp(p, "${description}", 14))
            p += 14;
        else if (!strncmp(p, "${name}", 7)) {
            p += 7;
            writeq(roleName());
        }
        else if (!strncmp(p, "${value}", 8)) {
            p += 8;
            writeq((defaultValue().isEmpty()) ? "None" : defaultValue());
        }
        else if (!strncmp(p, "${self}", 7)) {
            p += 7;

            if (!isClassMember())
                fw.write("self.");
        }
        else if (!strncmp(p, "${type}", 7)) {
            p += 7;
            roleType()->write();
        }
        else if (!strncmp(p, "${stereotype}", 13)) {
            p += 13;
            writeq(st);
        }
        else if (*p == '\r')
            p += 1;
        else if (*p == '@')
            manage_alias(p);
        else
            writeq(*p++);
    }
}
Ejemplo n.º 3
0
void UmlOperation::gen_python_decl(QByteArray s, bool descr)
{
    QByteArray cl_stereotype =
        PythonSettings::classStereotype(parent()->stereotype());
    const char * p = bypass_comment(s);
    const QList<UmlParameter> & pa = params();
    unsigned npa = pa.count();
    bool in_params = FALSE;
    unsigned rank;

    while (*p) {
        if (!strncmp(p, "${comment}", 10))
            p += 10;
        else if (!strncmp(p, "${description}", 14))
            p += 14;
        else if (!strncmp(p, "${docstring}", 12))
            p += 12;
        else if (!strncmp(p, "${static}", 9)) {
            p += 9;

            if (isClassMember())
                fw.write("@staticmethod<br />");
        }
        else if (!strncmp(p, "${abstract}", 11)) {
            p += 11;

            if (isAbstract())
                fw.write("@abstractmethod<br />");
        }
        else if (!strncmp(p, "${@}", 4)) {
            p += 4;
            writeq(pythonDecorators());
        }
        else if (!strncmp(p, "${name}", 7)) {
            p += 7;
            writeq(compute_name(pythonNameSpec()));
        }
        else if (!strncmp(p, "${class}", 8)) {
            p += 8;
            parent()->write();
        }
        else if (!strncmp(p, "${(}", 4)) {
            p += 4;
            fw.write('(');
            in_params = TRUE;
        }
        else if (!strncmp(p, "${)}", 4)) {
            p += 4;
            fw.write(')');
            in_params = FALSE;
        }
        else if (sscanf(p, "${t%u}", &rank) == 1) {
            p = strchr(p, '}') + 1;

            if (rank < npa) {
                const UmlTypeSpec & t = pa[rank].type;

                if (! t.toString().isEmpty()) {
                    if (in_params)
                        fw.write(": ");

                    write(t, pythonLanguage);
                }
            }
            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 (!strncmp(p, "${type}", 7)) {
            p += 7;

            const UmlTypeSpec & t = returnType();

            if (! t.toString().isEmpty()) {
                fw.write(" -> ");
                write(t, pythonLanguage);
            }
        }
        else if (*p == ':') {
            if (descr)
                fw.write(*p++);
            else
                break;
        }
        else if (*p == '\r')
            p += 1;
        else if (*p == '@')
            manage_alias(p);
        else
            writeq(*p++);
    }
}
Ejemplo n.º 4
0
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++);
    }
}
Ejemplo n.º 5
0
void UmlOperation::gen_java_decl(QByteArray s, bool descr)
{
    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 (isJavaFinal())
                fw.write("final ");
        }
        else if (!strncmp(p, "${visibility}", 13)) {
            p += 13;
            UmlItem::write(visibility(), javaLanguage);
            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())
                fw.write("abstract ");
        }
        else if (!strncmp(p, "${synchronized}", 15)) {
            p += 15;

            if (isJavaSynchronized())
                fw.write("synchronized ");
        }
        else if (!strncmp(p, "${type}", 7)) {
            p += 7;
            write(returnType(), javaLanguage);
        }
        else if (!strncmp(p, "${name}", 7)) {
            p += 7;
            writeq(compute_name(javaNameSpec()));
        }
        else if (!strncmp(p, "${(}", 4)) {
            p += 4;
            fw.write('(');
        }
        else if (!strncmp(p, "${)}", 4)) {
            p += 4;
            fw.write(')');
        }
        else if (!strncmp(p, "${throws}", 9)) {
            p += 9;

            const char * sep = " throws ";
            const QList<UmlTypeSpec> e = exceptions();
            unsigned n = e.count();

            for (unsigned index2 = 0; index2 != n; index2 += 1) {
                fw.write(sep);
                sep = ", ";
                write(e[index2], javaLanguage);
            }
        }
        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, javaLanguage);
            else
                fw.write("???");
        }
        else if (sscanf(p, "${p%u}", &rank) == 1) {
            p = strchr(p, '}') + 1;

            if (rank < npa)
                writeq(pa[rank].name);
            else
                fw.write("???");
        }
        else if (!strncmp(p, "${stereotype}", 13)) {
            p += 13;
            // get/set relation with multiplicity > 1
            UmlClassMember * m = getOf();

            if ((m != 0) || ((m = setOf()) != 0))
                writeq(JavaSettings::relationAttributeStereotype(m->stereotype()));
        }
        else if (!strncmp(p, "${association}", 14)) {
            p += 14;
            // get/set relation with multiplicity > 1
            UmlClassMember * m = getOf();

            if (((m != 0) || ((m = setOf()) != 0)) &&
                (m->kind() == aRelation))
                write(((UmlRelation *) m)->association(), javaLanguage);
        }
        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++);
    }
}
Ejemplo n.º 6
0
void UmlOperation::gen_cpp_decl(QByteArray s, bool descr)
{
    const char * p = bypass_comment(s);

    if (! descr) {
        write((cppVisibility() == DefaultVisibility)
              ? visibility() : cppVisibility(),
              cppLanguage);
        fw.write(": ");
        p = bypass_comment(s);
    }
    else
        p = 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, "${friend}", 9)) {
            p += 9;

            if (isCppFriend())
                fw.write("friend ");
        }
        else if (!strncmp(p, "${static}", 9)) {
            p += 9;

            if (isClassMember())
                fw.write("static ");
        }
        else if (!strncmp(p, "${inline}", 9)) {
            p += 9;

            if (isCppInline())
                fw.write("inline ");
        }
        else if (!strncmp(p, "${virtual}", 10)) {
            p += 10;

            if (isCppVirtual())
                fw.write("virtual ");
        }
        else if (!strncmp(p, "${type}", 7)) {
            p += 7;
            write(returnType(), cppLanguage);
        }
        else if (!strncmp(p, "${name}", 7)) {
            p += 7;
            writeq(compute_name(cppNameSpec()));
        }
        else if (!strncmp(p, "${(}", 4)) {
            p += 4;
            fw.write('(');
        }
        else if (!strncmp(p, "${)}", 4)) {
            p += 4;
            fw.write(')');
        }
        else if (!strncmp(p, "${const}", 8)) {
            p += 8;

            if (isCppConst())
                fw.write(" const");
        }
        else if (!strncmp(p, "${volatile}", 11)) {
            p += 11;

            if (isVolatile())
                fw.write(" volatile");
        }
        else if (!strncmp(p, "${throw}", 8)) {
            p += 8;

            const char * sep = " throw (";
            QList<UmlTypeSpec> e = exceptions();
            unsigned n = e.count();
            unsigned index2;

            for (index2 = 0; index2 != n; index2 += 1) {
                fw.write(sep);
                sep = ", ";
                write(e[index2], cppLanguage);
            }

            if (index2 != 0)
                fw.write(')');
            else if (CppSettings::operationForceThrow())
                fw.write(" throw ()");
        }
        else if (sscanf(p, "${t%u}", &rank) == 1) {
            p = strchr(p, '}') + 1;

            if (rank < npa)
                write(pa[rank].type, cppLanguage);
            else
                fw.write("???");
        }
        else if (sscanf(p, "${p%u}", &rank) == 1) {
            p = strchr(p, '}') + 1;

            if (rank < pa.count())
                writeq(pa[rank].name);
            else
                fw.write("???");
        }
        else if (sscanf(p, "${v%u}", &rank) == 1) {
            p = strchr(p, '}') + 1;

            if (rank >= pa.count())
                fw.write("???");
            else if (! pa[rank].default_value.isEmpty()) {
                fw.write(" = ");
                writeq(pa[rank].default_value);
            }
        }
        else if (!strncmp(p, "${abstract}", 11)) {
            if (isAbstract())
                fw.write("= 0 ");

            break;
        }
        else if (!strncmp(p, "${stereotype}", 13)) {
            p += 13;
            // get/set relation with multiplicity > 1
            UmlClassMember * m = getOf();

            if ((m != 0) || ((m = setOf()) != 0))
                writeq(CppSettings::relationAttributeStereotype(m->stereotype()));
        }
        else if (!strncmp(p, "${association}", 14)) {
            p += 14;
            // get/set relation with multiplicity > 1
            UmlClassMember * m = getOf();

            if (((m != 0) || ((m = setOf()) != 0)) &&
                (m->kind() == aRelation))
                write(((UmlRelation *) m)->association(), cppLanguage);
        }
        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++);
    }
}
Ejemplo n.º 7
0
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++);
  }
}
Ejemplo n.º 8
0
void UmlClass::gen_cpp_decl(QCString s, bool descr) {
  const char * p = (descr)
    ? (const char *) s
    : (const char *) bypass_comment(s);

  while (*p) {
    if (!strncmp(p, "${comment}", 10))
      p += 10;
    else if (!strncmp(p, "${description}", 14))
      p += 14;
    else if (!strncmp(p, "${type}", 7)) {
      p += 7;
      bool find = FALSE;

      if (baseType().type != 0) {
	UmlClass * mother = baseType().type;
	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->roleType() == mother)) {
	      rel->roleType()->write();
	      generate(actuals(), mother, TRUE);
	      find = TRUE;
	      break;
	    }
	  }
	}
      }
      if (! find)
	UmlItem::write(baseType(), cppLanguage);
    }
    else if (!strncmp(p, "${template}", 11)) {
      p += 11;
      generate(formals());
    }
    else if (!strncmp(p, "${name}", 7)) {
      p += 7;
      writeq(name());
    }
    else if (!strncmp(p, "${inherit}", 10)) {
      p += 10;

      const QVector<UmlItem> ch = children();
      const char * sep = " : ";

      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->cppDecl().isEmpty()) {
	    fw.write(sep);
	    // UmlItem::write else G++ call UmlClass::write(QCString) !
	    UmlItem::write((rel->cppVisibility() == DefaultVisibility)
		           ? rel->visibility() : rel->cppVisibility(),
			   cppLanguage);
	    fw.write((rel->cppVirtualInheritance()) ? " virtual " : " ");
	    rel->roleType()->write();
	    generate(actuals(), rel->roleType(), TRUE);
	    sep = ", ";
	  }
	}
      }
    }
    else if (*p == '{') {
      if (descr)
	fw.write(*p++);
      else
	break;
    }
    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 == '@')
      manage_alias(p);
    else
      writeq(*p++);
  }

}
Ejemplo n.º 9
0
void UmlRelation::gen_php_decl(QByteArray s, bool descr)
{
    const char * p = bypass_comment(s);

    while (*p) {
        if (!strncmp(p, "${comment}", 10))
            p += 10;
        else if (!strncmp(p, "${description}", 14))
            p += 14;
        else if (!strncmp(p, "${visibility}", 13)) {
            p += 13;
            write(visibility(), phpLanguage);
            fw.write(' ');
        }
        else if (!strncmp(p, "${static}", 9)) {
            p += 9;

            if (isClassMember())
                fw.write("static ");
        }
        else if (!strncmp(p, "${name}", 7)) {
            p += 7;

            if (!isReadOnly())
                fw.write("$");

            writeq(roleName());
        }
        else if (!strncmp(p, "${var}", 6)) {
            p += 6;

            if (!isReadOnly() &&
                    !isClassMember() &&
                    (visibility() == PackageVisibility))
                fw.write("var ");
        }
        else if (!strncmp(p, "${value}", 8)) {
            p += 8;
        }
        else if (!strncmp(p, "${const}", 8)) {
            p += 8;

            if (isReadOnly())
                fw.write("const ");
        }
        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 == ';') {
            if (descr)
                fw.write(*p++);
            else
                break;
        }
        else if (*p == '@')
            manage_alias(p);
        else
            writeq(*p++);
    }
}
Ejemplo n.º 10
0
void UmlRelation::gen_java_decl(QByteArray s, bool descr)
{
    const char * p = bypass_comment(s);

    while (*p) {
        if (!strncmp(p, "${comment}", 10))
            p += 10;
        else if (!strncmp(p, "${description}", 14))
            p += 14;
        else if (!strncmp(p, "${visibility}", 13)) {
            p += 13;
            write(visibility(), javaLanguage);
            fw.write(' ');
        }
        else if (!strncmp(p, "${static}", 9)) {
            p += 9;

            if (isClassMember())
                fw.write("static ");
        }
        else if (!strncmp(p, "${transient}", 12)) {
            p += 12;

            if (isJavaTransient())
                fw.write("transient ");
        }
        else if (!strncmp(p, "${volatile}", 11)) {
            p += 11;

            if (isVolatile())
                fw.write("volatile ");
        }
        else if (!strncmp(p, "${final}", 8)) {
            p += 8;

            if (isReadOnly())
                fw.write("final ");
        }
        else if (!strncmp(p, "${type}", 7)) {
            p += 7;
            roleType()->write();
        }
        else if (!strncmp(p, "${name}", 7)) {
            p += 7;
            writeq(roleName());
        }
        else if (!strncmp(p, "${multiplicity}", 15)) {
            p += 15;

            QByteArray m = multiplicity();

            if (! m.isEmpty()) {
                const char * s = m;

                if (*s != '[')
                    fw.write("[]");
                else {
                    while (*s) {
                        switch (*s++) {
                        case '[':
                            fw.write('[');
                            break;

                        case ']':
                            fw.write(']');

                        default:
                            break;
                        }
                    }
                }
            }
        }
        else if (!strncmp(p, "${stereotype}", 13)) {
            p += 13;
            writeq(JavaSettings::relationAttributeStereotype(stereotype()));
        }
        else if (!strncmp(p, "${value}", 8)) {
            p += 8;
        }
        else if (!strncmp(p, "${association}", 14)) {
            p += 14;
            write(association(), javaLanguage);
        }
        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 == ';') {
            if (descr)
                fw.write(*p++);
            else
                break;
        }
        else if (*p == '@')
            manage_alias(p);
        else
            writeq(*p++);
    }
}
Ejemplo n.º 11
0
void UmlRelation::gen_cpp_decl(QByteArray s, bool descr)
{
    const char * p;

    if (! descr) {
        write((cppVisibility() == DefaultVisibility)
              ? visibility() : cppVisibility(),
              cppLanguage);
        fw.write(": ");
        p = bypass_comment(s);
    }
    else
        p = s;

    while (*p) {
        if (!strncmp(p, "${comment}", 10))
            p += 10;
        else if (!strncmp(p, "${description}", 14))
            p += 14;
        else if (!strncmp(p, "${static}", 9)) {
            p += 9;

            if (isClassMember())
                fw.write("static ");
        }
        else if (!strncmp(p, "${const}", 8)) {
            p += 8;

            if (isReadOnly())
                fw.write("const ");
        }
        else if (!strncmp(p, "${mutable}", 10)) {
            p += 10;

            if (isCppMutable())
                fw.write("mutable ");
        }
        else if (!strncmp(p, "${volatile}", 11)) {
            p += 11;

            if (isVolatile())
                fw.write("volatile ");
        }
        else if (!strncmp(p, "${type}", 7)) {
            p += 7;
            roleType()->write();
        }
        else if (!strncmp(p, "${name}", 7)) {
            p += 7;
            writeq(roleName());
        }
        else if (!strncmp(p, "${multiplicity}", 15)) {
            p += 15;

            QByteArray m = multiplicity();

            if (m.isEmpty() || (((const char *) m)[0] != '[')) {
                fw.write("[");
                writeq(m);
                fw.write("]");
            }
            else
                writeq(m);
        }
        else if (!strncmp(p, "${stereotype}", 13)) {
            p += 13;
            writeq(CppSettings::relationAttributeStereotype(stereotype()));
        }
        else if (!strncmp(p, "${value}", 8) || !strncmp(p, "${h_value}", 10)) {
            break;
        }
        else if (!strncmp(p, "${association}", 14)) {
            p += 14;
            write(association(), cppLanguage);
        }
        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 == ';') {
            if (descr)
                fw.write(*p++);
            else
                break;
        }
        else if (*p == '@')
            manage_alias(p);
        else
            writeq(*p++);
    }
}
Ejemplo n.º 12
0
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++);
    }
}