Ejemplo n.º 1
0
void UmlRelation::uml2cpp(bool)
{
    bool composition = FALSE;

    switch (relationKind()) {
    case aGeneralisation:
    case aRealization:
        set_CppDecl("${type}");
        break;

    case aDependency:
        if (stereotype() == "friend")
            set_CppDecl("friend " +
                        CppSettings::classStereotype(roleType()->stereotype()) +
                        " ${type};");
        else
            set_CppDecl("#include in source");

        break;

    case anAggregationByValue:
    case aDirectionalAggregationByValue:
        composition = TRUE;

        // no break
    default: {
        Q3CString st = CppSettings::classStereotype(parent()->stereotype());

        set_CppDecl(((st == "enum") || (st == "typedef") || (st == "ignored"))
                    ? Q3CString("")
                    : CppSettings::relationDecl(composition, multiplicity()));
    }
    }
}
Ejemplo n.º 2
0
void UmlClass::cplusplus(Q3Dict<Q3CString> & prop) {
  if (!scanning) {
    if (stereotype() == "typedef") {
      Q3CString * bt = prop.find("Cplusplus/ImplementationType");
      
      if (bt != 0) {
	UmlTypeSpec t;
	
	t.explicit_type = *bt;	// no quidu
	set_BaseType(t);
      }
      
      set_CppDecl(CppSettings::typedefDecl());
    }
    else if (stereotype() == "struct")
      set_CppDecl(CppSettings::structDecl());
    else if (stereotype() == "union")
      set_CppDecl(CppSettings::unionDecl());
    else if (stereotype() == "enum")
      set_CppDecl(CppSettings::enumDecl());
    else
      set_CppDecl(CppSettings::classDecl());
    
    prop.remove("Cplusplus/ImplementationType");
  }

  Q3CString * v;
  
  if ((v = prop.find("Cplusplus/BodySourceFile")) != 0) {
    _body_file = *v;
    prop.remove("Cplusplus/BodySourceFile");
  }
  else if ((v = prop.find("Traversal/BodyFile")) != 0) {
    _body_file = *v;
    prop.remove("Traversal/BodyFile");
  }
  
  if ((v = prop.find("Cplusplus/HeaderSourceFile")) != 0) {
    _file = *v;
    prop.remove("Cplusplus/HeaderSourceFile");
  }
  else if ((v = prop.find("Traversal/CodeFile")) != 0) {
    _file = *v;
    prop.remove("Traversal/CodeFile");
  }
}
Ejemplo n.º 3
0
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();
            }
        }
    }
}
Ejemplo n.º 4
0
void UmlOperation::defaultDef()
{
    if (cppDecl().isEmpty())
        set_CppDecl(CppSettings::operationDecl());

    if (isAbstract())
        set_CppDef("");
    else if (cppDef().isEmpty())
        set_CppDef(CppSettings::operationDef());

    setUsed();
}
Ejemplo n.º 5
0
void UmlClass::uml2cpp(bool rec) {
  if (isCppExternal())
    set_CppDecl(CppSettings::externalClassDecl());
  else {
    QCString st = CppSettings::classStereotype(stereotype());
    UmlItem * pack = parent()->parent();
    
    while (pack->kind() != aPackage)
      pack = pack->parent();
    
    if ((st == "stereotype") ||
	(st == "metaclass") ||
	(pack->stereotype() == "profile")) {
      set_CppDecl("");
      return;
    }
    
    if (st == "enum")
      set_CppDecl(CppSettings::enumDecl());
    else if (st == "union")
      set_CppDecl(CppSettings::unionDecl());
    else if (st == "struct")
      set_CppDecl(CppSettings::structDecl());
    else if (st == "typedef")
      set_CppDecl(CppSettings::typedefDecl());
    else if (st == "ignored") {
      set_CppDecl("");
      return;
    }
    else
      set_CppDecl(CppSettings::classDecl());
    
    if (rec) {
      const QVector<UmlItem> ch = children();
      unsigned n = ch.size();
      
      for (unsigned i = 0; i != n; i += 1)
	ch[i]->uml2cpp(rec);
    }
    
    if (parent()->kind() == aClassView) {
      // not nested
      UmlArtifact * art = artifact();
			 
      art->set_CppSource(CppSettings::sourceContent());
      art->set_CppHeader(CppSettings::headerContent());
    }
  }
}
Ejemplo n.º 6
0
void UmlClass::uml2java(bool rec) {
  if (isJavaExternal())
    set_JavaDecl(JavaSettings::externalClassDecl());
  else {
    QCString st = JavaSettings::classStereotype(stereotype());
    UmlItem * pack = parent()->parent();
    
    while (pack->kind() != aPackage)
      pack = pack->parent();
    
    if ((st == "stereotype") ||
	(st == "metaclass") ||
	(pack->stereotype() == "profile")) {
      set_CppDecl("");
      return;
    }
    
    if (st == "enum_pattern")
      set_JavaDecl(JavaSettings::enumPatternDecl());
    else if (st == "enum")
      set_JavaDecl(JavaSettings::enumDecl());
    else if (st == "interface")
      set_JavaDecl(JavaSettings::interfaceDecl());
    else if (st == "@interface") {
      QCString s = JavaSettings::interfaceDecl();
      int index = s.find("interface");
      
      if (index != -1)
	s.insert(index, '@');
      set_JavaDecl(s);
    }
    else if (st == "ignored") {
      set_JavaDecl("");
      return;
    }
    else
      set_JavaDecl(JavaSettings::classDecl());
    
    if (rec) {
      const QVector<UmlItem> ch = children();
      unsigned n = ch.size();
      
      for (unsigned i = 0; i != n; i += 1)
	ch[i]->uml2java(rec);
    }
    
    if (parent()->kind() == aClassView)
      // not nested
      artifact()->set_JavaSource(JavaSettings::sourceContent());
  }
}
Ejemplo n.º 7
0
void UmlClass::uml2idl(bool rec) {
  if (isIdlExternal())
    set_IdlDecl(IdlSettings::externalClassDecl());
  else {
    QCString st = IdlSettings::classStereotype(stereotype());
    UmlItem * pack = parent()->parent();
    
    while (pack->kind() != aPackage)
      pack = pack->parent();
    
    if ((st == "stereotype") ||
	(st == "metaclass") ||
	(pack->stereotype() == "profile")) {
      set_CppDecl("");
      return;
    }
    
    if (st == "struct")
      set_IdlDecl(IdlSettings::structDecl());
    else if (st == "union")
      set_IdlDecl(IdlSettings::unionDecl());
    else if (st == "enum")
      set_IdlDecl(IdlSettings::enumDecl());
    else if (st == "exception")
      set_IdlDecl(IdlSettings::exceptionDecl());
    else if (st == "typedef")
      set_IdlDecl(IdlSettings::typedefDecl());
    else if (st == "interface")
      set_IdlDecl(IdlSettings::interfaceDecl());
    else if (st == "ignored") {
      set_IdlDecl("");
      return;
    }
    else
      set_IdlDecl(IdlSettings::valuetypeDecl());
    
    if (rec) {
      const QVector<UmlItem> ch = children();
      unsigned n = ch.size();
      
      for (unsigned i = 0; i != n; i += 1)
	ch[i]->uml2idl(rec);
    }
    
    if (parent()->kind() == aClassView)
      // not nested
      artifact()->set_IdlSource(IdlSettings::sourceContent());
  }
}
Ejemplo n.º 8
0
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();
            }
        }
    }
}
Ejemplo n.º 9
0
void UmlClass::uml2php(bool rec) {
  if (isPhpExternal())
    set_PhpDecl(PhpSettings::externalClassDecl());
  else {
    QCString st = PhpSettings::classStereotype(stereotype());
    UmlItem * pack = parent()->parent();
    
    while (pack->kind() != aPackage)
      pack = pack->parent();
    
    if ((st == "stereotype") ||
	(st == "metaclass") ||
	(pack->stereotype() == "profile")) {
      set_CppDecl("");
      return;
    }
    
    
    if (st == "enum")
      set_PhpDecl(PhpSettings::enumDecl());
    else if (st == "interface")
      set_PhpDecl(PhpSettings::interfaceDecl());
    else if (st == "ignored") {
      set_PhpDecl("");
      return;
    }
    else
      set_PhpDecl(PhpSettings::classDecl());
    
    if (rec) {
      const QVector<UmlItem> ch = children();
      unsigned n = ch.size();
      
      for (unsigned i = 0; i != n; i += 1)
	ch[i]->uml2php(rec);
    }
    
    if (parent()->kind() == aClassView)
      // not nested
      artifact()->set_PhpSource(PhpSettings::sourceContent());
  }
}
Ejemplo n.º 10
0
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);
    }
}
Ejemplo n.º 11
0
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");
  
}
Ejemplo n.º 12
0
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);
        }
    }
}
Ejemplo n.º 13
0
void UmlRelation::cplusplus(UmlRelation::Role * role) {
  set_CppDecl(CppSettings::relationDecl(role->is_byvalue,
					role->cardinality));
}
Ejemplo n.º 14
0
void UmlOperation::remove_cpp_throw() {
  set_CppDecl(remove_throw(CppSettings::operationDecl()));
  set_CppDef(remove_throw(CppSettings::operationDef()));
}
Ejemplo n.º 15
0
void UmlOperation::set_cpp(const char * return_form_or_inherit,
			   const char * params, QCString body,
			   bool inlinep, const char * if_def,
			   const char * end_if) {
  if (*return_form_or_inherit == ':') {
    // inherit
    if (inlinep) {
      QCString s = remove_throw(CppSettings::operationDecl());
      int index = s.find("${)}");
      
      s.resize(index + 5);
      s.insert(index, params);
      s.append(" ");
      s.append(return_form_or_inherit);
      if (!body.isEmpty()) {
	s.append(" {\n  ");
	s.append(body);
	s.append("}\n");
      }
      else
	s.append(" {\n}\n");
      conditional(s, if_def, end_if);
      set_CppDecl(s);
      
      set_CppDef("");
    }
    else {
      QCString s = remove_throw(CppSettings::operationDecl());
      int index = s.find("${)}");
      
      s.resize(index + 5);
      s.insert(index, params);
      s.append(";");
      conditional(s, if_def, end_if);
      set_CppDecl(s);
      
      s = remove_throw(CppSettings::operationDef());
      index = s.find("${)}");
      s.resize(index + 5);
      s.insert(index, params);
      s.append(" ");
      s.append(return_form_or_inherit);
      if (!body.isEmpty()) {
	s.append(" {\n  ");
	s.append(body);
	s.append("}\n");
      }
      else
	s.append(" {\n}\n");
      conditional(s, if_def, end_if);
      set_CppDef(s);
    }
  }
  else {
    // return
    if (inlinep) {
      QCString s = remove_throw(CppSettings::operationDecl());
      int index = s.find("${type}");
      
      s.replace(index, 7, return_form_or_inherit);
      s.insert(s.find("${)}", index), params);
      s.resize(s.findRev(";") + 1);
      if (!body.isEmpty()) {
	s.append(" {\n  ");
	s.append(body);
	s.append("}\n");
      }
      else
	s.append(" {\n}\n");
      conditional(s, if_def, end_if);
      set_CppDecl(s);
      
      set_CppDef("");
    }
    else {
      QCString s = remove_throw(CppSettings::operationDecl());
      int index = s.find("${type}");
      
      s.replace(index, 7, return_form_or_inherit);
      s.insert(s.find("${)}", index), params);
      conditional(s, if_def, end_if);
      set_CppDecl(s);
      
      s = remove_throw(CppSettings::operationDef());
      index = s.find("${type}");
      s.replace(index, 7, return_form_or_inherit);
      s.insert(s.find("${)}", index), params);
      conditional(s, if_def, end_if);
      set_CppDef(s);
      
      set_CppBody(body);
    }
  }
}
Ejemplo n.º 16
0
void UmlOperation::import(File & f)
{
    if (scanning) {
        f.skipBlock();
        return;
    }

    QByteArray s;
    UmlTypeSpec t;

    for (;;) {
        switch (f.read(s)) {
        case -1:
            f.eof();
            throw 0;

        case ')':
            set_ReturnType(t);
            return;

        case ATOM:
            break;

        default:
            f.syntaxError(s);
        }

        // atom
        if (s == "parameters") {
            f.read("(");
            f.read("list");
            f.read("Parameters");
            importParameters(f);
        }
        else if (s == "result") {
            if (f.read(s) != STRING)
                f.syntaxError(s, "return type");

            t.explicit_type = s;
        }
        else if (s == "quidu") {
            if (f.read(s) != STRING)
                f.syntaxError(s, "wrong quidu");

            if (UmlClass::replaceType(t, s, "${type}")) {
                switch (((UmlClass *) parent())->language()) {
                case Cplusplus:
                case AnsiCplusplus:
                case VCplusplus:
                    set_CppDecl(replace(cppDecl(), "${type}", s));
                    set_CppDef(replace(cppDef(), "${type}", s));
                    break;

                case Oracle8:
                    break;

                case Corba:
                    set_IdlDecl(replace(idlDecl(), "${type}", s));
                    break;

                case Java:
                    set_JavaDecl(replace(javaDecl(), "${type}", s));
                    break;

                default:
                    break;
                }
            }
        }
        else if (s == "exceptions")
            importExceptions(f);
        else if (s == "opExportControl")
            set_Visibility(f.readVisibility());
        else
            f.skipNextForm();
    }

}
Ejemplo n.º 17
0
void UmlOperation::importParameters(File & f)
{
    QByteArray s;
    unsigned rank = 0;
    const char * sep = "";
    QByteArray doc = description();

    for (;;) {
        switch (f.read(s)) {
        case ')':
            if (doc != description())
                set_Description(doc);

            return;

        case '(':
            // a parameter
            break;

        default:
            f.syntaxError(s);
        }

        f.read("object");
        f.read("Parameter");

        UmlParameter p;
        QByteArray ti;

        ti = QString("${t%1}").arg(rank).toLatin1();

        if (f.read(p.name) != STRING)
            f.syntaxError(s, "parameter's name");

        QByteArray id;
        QByteArray ste;
        QByteArray p_doc;
        QHash<QByteArray, QByteArray*> prop;
        int k;

        for (;;) {
            k = f.readDefinitionBeginning(s, id, ste, p_doc, prop);

            if (k == ')')
                break;

            if (s == "type") {
                if (f.read(s) != STRING)
                    f.syntaxError(s, "parameter type");

                switch (((UmlClass *) parent())->language()) {
                case Corba:
                    if (strncmp(s,  "in ", 3) == 0) {
                        p.dir = InputDirection;
                        s = s.mid(3);
                    }
                    else if (strncmp(s,  "out ", 4) == 0) {
                        p.dir = OutputDirection;
                        s = s.mid(4);
                    }
                    else if (strncmp(s,  "inout ", 6) == 0) {
                        p.dir = InputOutputDirection;
                        s = s.mid(6);
                    }
                    else {
                        QByteArray err =
                            "<br>'" + s + "' : wrong parameter direction, in " + f.context();

                        UmlCom::trace(err);
                        p.dir = InputOutputDirection;
                    }

                    break;

                default:
                    // !!!!!!!!!!!!!
                    p.dir = InputOutputDirection;
                }

                p.type.explicit_type = s;
            }
            else if (s == "quidu") {
                if (f.read(s) != STRING)
                    f.syntaxError(s, "wrong quidu");

                if (UmlClass::replaceType(p.type, s, ti))
                    ti = s;
            }
            else
                f.skipNextForm();
        }

        QByteArray d;
        int index;

        switch (((UmlClass *) parent())->language()) {
        case Cplusplus:
        case AnsiCplusplus:
        case VCplusplus:
            s= QString("%1%2 ${p%3}").arg(sep).arg((const char *) ti).arg(rank).toLatin1();

            if ((index = (d = cppDecl()).indexOf("${)}")) != -1)
                //set_CppDecl(d.insert(index, s));//[jasa] original line
                set_CppDecl(d.insert(index, (const char *)s)); //[jasa] fix ambiguous call

            if ((index = (d = cppDef()).indexOf("${)}")) != -1)
                set_CppDef(d.insert(index, (const char *)s)); //[jasa] fix ambiguous call

            break;

        case Oracle8:
            break;

        case Corba:
            if ((index = (d = idlDecl()).indexOf("${)}")) != -1) {
                s = QString("%1${d%2} %3 ${p%4}").arg(
                          sep).arg(rank).arg((const char *) ti).arg(rank).toLatin1();
                set_IdlDecl(d.insert(index, (const char *)s)); //[jasa] fix ambiguous call
            }

            break;

        case Java:
            if ((index = (d = javaDecl()).indexOf("${)}")) != -1) {
                s = QString("%s%s ${p%u}").arg( sep).arg( (const char *) ti).arg( rank).toLatin1();
                set_JavaDecl(d.insert(index, (const char *)s)); //[jasa]
            }

            break;

        default:
            break;
        }

        addParameter(rank++, p);
        sep = ", ";
    }
}
Ejemplo n.º 18
0
void UmlOperation::cplusplus(QHash<QByteArray, QByteArray*> &)
{
    set_CppDecl(CppSettings::operationDecl());
    set_CppDef(CppSettings::operationDef());
}