Example #1
0
void UmlOperation::write_cpp_returntype(FileOut & out, WrapperStr decl)
{
    // doesn't manage function pointer
    // manage keywords
    int index;

    if ((index = decl.find("${static}")) != -1)
        decl.remove(index, 9);

    if ((index = decl.find("${friend}")) != -1)
        decl.remove(index, 9);

    if ((index = decl.find("${virtual}")) != -1)
        decl.remove(index, 10);

    if ((index = decl.find("${inline}")) != -1)
        decl.remove(index, 9);

    if ((index = decl.find("${(}")) == -1)
        decl = "${type} ${name}";
    else
        decl.truncate(index);

    UmlTypeSpec t = returnType();

    if ((t.type != 0) ||
        !(t.explicit_type = CppSettings::type(t.explicit_type)).isEmpty())
        write_type(out, t, decl, "${name}", "${type}");
}
void UmlClassMember::remove_comments(WrapperStr & s)
{
    int index1 = 0;

    if ((index1 = s.find("${comment}")) != -1)
        s.remove((unsigned) index1, 10);
    else if ((index1 = s.find("${description}")) != -1)
        s.remove((unsigned) index1, 14);

    while ((index1 = s.find('/', index1)) != -1) {
        int index2;

        switch (((const char *) s)[index1 + 1]) {
        case '/':
            if ((index2 = s.find('\n', index1 + 2)) != -1)
                s.remove(index1, index2 - index1 + 1);
            else
                s.truncate(index1);

            break;

        case '*':
            if ((index2 = s.find("*/", index1 + 2)) != -1)
                s.replace(index1, index2 - index1 + 1, " ");
            else
                s.truncate(index1);

            break;

        default:
            index1 += 1;
        }
    }
}
Example #3
0
void UmlOperation::write_java_returntype(FileOut & out, WrapperStr decl)
{
// manage keywords
    int index;

    if ((index = decl.find("${visibility}")) != -1)
        decl.remove(index, 13);

    if ((index = decl.find("${final}")) != -1)
        decl.remove(index, 8);

    if ((index = decl.find("${static}")) != -1)
        decl.remove(index, 9);

    if ((index = decl.find("${abstract}")) != -1)
        decl.remove(index, 11);

    if ((index = decl.find("${synchronized}")) != -1)
        decl.remove(index, 15);

    if ((index = decl.find("${@}")) != -1)
        decl.remove(index, 4);

    if ((index = decl.find("${(}")) == -1)
        decl = "${type} ${name}";
    else
        decl.truncate(index);

    UmlTypeSpec t = returnType();

    if ((t.type != 0) ||
        !(t.explicit_type = JavaSettings::type(t.explicit_type)).isEmpty())
        write_type(out, t, decl, "${name}", "${type}");
}
Example #4
0
void remove_python_comments(WrapperStr & s)
{
    int index1 = 0;

    while ((index1 = s.find('#', index1)) != -1) {
        int index2;

        if ((index2 = s.find('\n', index1 + 1)) != -1)
            s.remove(index1, index2 - index1 + 1);
        else
            s.truncate(index1);
    }
}
Example #5
0
void UmlClassMember::remove_preprocessor(WrapperStr & s)
{
    int index = 0;

    while ((index = s.find('#', index)) != -1) {
        // remove all up to the end of line
        int index2 = index + 1;
        int index3;

        while ((index3 = s.find('\n', index2)) != -1) {
            // manage multi lines #define
            if (((const char *) s)[index3 - 1] != '\\')
                break;
            else
                index2 = index3 + 1;
        }

        // the \n is still here to have a separator
        if (index3 == -1)
            s.truncate(index);
        else
            s.remove(index, index3 - index);
    }
}
Example #6
0
void UmlRelation::compute_dependency(Q3PtrList<CppRefType> & dependencies,
                                     const WrapperStr & cl_stereotype,
                                     bool all_in_h)
{
    if (cl_stereotype == "enum")
        return;

    switch (relationKind()) {
    case aDependency:
        if (stereotype() == "friend")
            break;

        CppRefType::add(roleType(), dependencies, cppDecl() != "#include in source",
                        roleType()->isCppExternal());
        break;

    case aGeneralisation:
    case aRealization:
        CppRefType::add(roleType(), dependencies, TRUE);
        break;

    default:
        WrapperStr decl = cppDecl();
        int index;

        if ((index = decl.find("${static}")) != -1)
            decl.remove((unsigned) index, 9);

        if ((index = decl.find("${mutable}")) != -1)
            decl.remove((unsigned) index, 10);

        if ((index = decl.find("${volatile}")) != -1)
            decl.remove((unsigned) index, 11);

        if ((index = decl.find("${const}")) != -1)
            decl.remove((unsigned) index, 8);

        if ((index = decl.find("${multiplicity}")) != -1)
            decl.remove((unsigned) index, 15);

        if ((index = decl.find("${name}")) != -1)
            decl.remove((unsigned) index, 7);

        if ((index = decl.find("${inverse_name}")) != -1)
            decl.remove((unsigned) index, 15);

        if ((index = decl.find("${value}")) != -1)
            decl.remove((unsigned) index, 8);

        if ((index = decl.find("${h_value}")) != -1)
            decl.remove((unsigned) index, 10);

        if ((index = decl.find("${stereotype}")) != -1)
            decl.replace((unsigned) index, 13,
                         CppSettings::relationAttributeStereotype(stereotype()));

        if ((index = decl.find("${association}")) != -1) {
            decl.replace((unsigned) index, 14,
                         association().toString());
        }

        replace_alias(decl);

        UmlTypeSpec type;

        type.type = roleType();
        UmlClassMember::compute_dependency(dependencies, decl, type, all_in_h);
    }
}
Example #7
0
void UmlClass::compute_dependency(QList<CppRefType *> & dependencies,
                                  const WrapperStr &, bool all_in_h)
{
    QVector<UmlItem*> ch = children();
    const WrapperStr stereotype = cpp_stereotype();
    bool a_typedef = (stereotype == "typedef");
    bool an_enum = (stereotype == "enum");
    const QList<UmlFormalParameter> formals = this->formals();
    const QList<UmlActualParameter> actuals = this->actuals();

    if (!formals.isEmpty())
        // template class, force depend in h
        all_in_h = TRUE;

    for (int index = 0; index != ch.size(); index += 1) {
        if (ch[index]->kind() != aNcRelation) {
            UmlClassItem * it = (UmlClassItem *) ch[index];

            if (! it->cppDecl().isEmpty())
                it->compute_dependency(dependencies, stereotype, all_in_h);
        }
    }

    if (an_enum && (!formals.isEmpty() || !actuals.isEmpty())) {
        write_trace_header();
        UmlCom::trace("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b><i>template enum</i></b></font><br>");
        incr_warning();
    }
    else if (a_typedef && !formals.isEmpty()) {
        write_trace_header();
        UmlCom::trace("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b><i>template typedef</i></b></font><br>");
        incr_warning();
    }
    else {
        QList<UmlFormalParameter>::ConstIterator itf;

        for (itf = formals.begin(); itf != formals.end(); ++itf)
            CppRefType::remove((*itf).name(), dependencies);

        QList<UmlActualParameter>::ConstIterator ita;

        for (ita = actuals.begin(); ita != actuals.end(); ++ita)
            UmlClassMember::compute_dependency(dependencies, "${type}",
                                               (*ita).value(), all_in_h);

        if (a_typedef) {
            WrapperStr decl = cppDecl();
            int index;

            remove_comments(decl);

            if ((index = decl.find("${name}")) != -1)
                decl.remove((unsigned) index, 7);

            replace_alias(decl);

            UmlClassMember::compute_dependency(dependencies, decl,
                                               baseType(), all_in_h);
        }
    }

    if ((associatedArtifact() == 0) ||
        (associatedArtifact()->associatedClasses().count() == 1))
        CppRefType::remove(this, dependencies);
    else
        CppRefType::force_ref(this, dependencies);
}