Пример #1
0
void UmlActivityObject::write_in_state(FileOut & out)
{
    WrapperStr s = inState();

    if (!s.isEmpty()) {
        UmlState * st = UmlState::find(s);

        if (st != 0)
            out.ref(st, "inState");
        else {
            // not legal but ...
            out << " inState=\"";
            out.quote(s);
            out << '"';
        }
    }
}
Пример #2
0
void UmlItem::importDependency(FileIn & in, Token & token, UmlItem * where)
{
    WrapperStr client = token.valueOf("client");
    WrapperStr supplier = token.valueOf("supplier");
    WrapperStr label = token.valueOf("name");
    WrapperStr constraint;
    int kind = (token.xmiType() == "uml:Usage") ? 3 : 1;

    if (! token.closed()) {
        WrapperStr k = token.what();
        const char * kstr = k;

        while (in.read(), !token.close(kstr)) {
            WrapperStr s = token.what();

            if (s == "client")
                client = token.xmiIdref();
            else if (s == "supplier")
                supplier = token.xmiIdref();
            else if (s == "ownedrule") {
                constraint = UmlItem::readConstraint(in, token);
                continue;
            }

            if (! token.closed())
                in.finish(s);
        }
    }

    if (client.isEmpty())
        in.warning("'client' is missing");
    else {
        if (supplier.isEmpty())
            // Borland Together 2006 for Eclipse
            supplier = where->id();

        QMap<QString, UmlItem *>::ConstIterator from = All.find(client);
        QMap<QString, UmlItem *>::ConstIterator to = All.find(supplier);

        if ((from != All.end()) && (to != All.end()))
            (*from)->generalizeDependRealize(*to, in, kind, label, constraint);
        else
            UnresolvedRelation::add(kind, client, supplier, label, constraint);
    }
}
void UmlReplyAction::importIt(FileIn & in, Token & token, UmlItem * where)
{
    where = where->container(aReplyAction, token, in);

    if (where != 0) {
        WrapperStr s = token.valueOf("name");
        UmlReplyAction * a = create(where, s);

        if (a == 0)
            in.error("cannot create reply action '"
                     + s + "' in '" + where->name() + "'");

        a->addItem(token.xmiId(), in);

        if (!(s = token.valueOf("trigger")).isEmpty()) {
            WrapperStr tr = Trigger::get(s);

            if (!tr.isNull())
                a->set_ReplyToCall(tr);
            else
                Unresolved::addRef(a, s);
        }

        if (! token.closed()) {
            WrapperStr k = token.what();
            const char * kstr = k;

            while (in.read(), !token.close(kstr)) {
                if (token.what() == "trigger") {
                    WrapperStr tr_name;
                    WrapperStr tr_ref;

                    Trigger::add(in, token, tr_name, tr_ref);

                    if (!tr_name.isNull())
                        a->set_ReplyToCall(tr_name);
                    else
                        Unresolved::addRef(a, tr_ref);
                }
                else
                    a->import(in, token);
            }
        }
    }
}
Пример #4
0
void UmlClass::need_artifact(const QStringList & imports,
                             bool remove_java_lang,
                             const QStringList & ,
                             const WrapperStr & path, UmlArtifact *& cp)
{
    if (parent()->kind() == aClassView) {
        if (cp != 0)
            cp->addAssociatedClass(this);
        else {
            UmlPackage * pack = (UmlPackage *) parent()->parent();

            if ((cp = associatedArtifact()) == 0) {
                // create associated artifact
                QFileInfo fi(path);
                WrapperStr artname = WrapperStr(fi.baseName().toAscii().constData());

                if ((cp = UmlBaseArtifact::create(pack->get_deploymentview(), artname)) == 0) {
                    UmlCom::trace(WrapperStr("<font face=helvetica><b>cannot create<i> artifact ")
                                  + artname + "</i></b></font><br>");
                    return;
                }

                cp->addAssociatedClass(this);
            }

            cp->set_Stereotype("source");

            WrapperStr s = JavaSettings::sourceContent();
            int index = s.find("${definition}");

            if (index != -1) {


                for (QStringList::const_iterator it = imports.begin(); it != imports.end(); it++) {
                    WrapperStr import = WrapperStr((*it).toAscii().constData());

                    if (!remove_java_lang || (import != "java.lang.")) {
                        import += (((const char *) import)[import.length() - 1] == '.')
                                  ? "*;\n" : ";\n";

                        s.insert(index, (const char *)("import " + import));
                        index = s.find("${definition}", index);
                    }
                }

                for (QStringList::const_iterator it = imports.begin(); it != imports.end(); it++) {
                    s.insert(index, (const char *)("import static" + WrapperStr((*it).toAscii().constData()) + '\n'));
                    index = s.find("${definition}", index);
                }
            }

            cp->set_JavaSource(WrapperStr(s));
        }
    }
}
Пример #5
0
bool UmlClass::is_itself(WrapperStr t)
{
    // class is a template class and t is x<...> where x is the class,
    // t is normalized
    // return true if t is the class with its formals
    int index = t.find('<');

    t = t.mid(index + 1, t.length() - index - 2);

    QList<UmlFormalParameter> l = formals();
    QList<UmlFormalParameter>::ConstIterator it = l.begin();
    WrapperStr t2 = (*it).name();

    while ((++it) != l.end())
        t2 += ',' + (*it).name();

    return (t == t2);
}
Пример #6
0
void UmlItem::importGeneralization(FileIn & in, Token & token, UmlItem * where)
{
    WrapperStr id = token.valueOf("general");
    WrapperStr constraint;

    if (! token.closed()) {
        WrapperStr k = token.what();
        const char * kstr = k;

        while (in.read(), !token.close(kstr)) {
            WrapperStr s = token.what();

            if (s == "general") {
                id = token.xmiIdref();

                if (id.isEmpty() && !(id = token.valueOf("href")).isEmpty()) {
                    int index = id.find('#');

                    if (index != -1)
                        id = id.mid(index + 1);
                }
            }
            else if (s == "ownedrule") {
                constraint = UmlItem::readConstraint(in, token);
                continue;
            }

            if (! token.closed())
                in.finish(s);
        }
    }

    if (!id.isEmpty()) {
        QMap<QString, UmlItem *>::ConstIterator iter = All.find(id);

        if (iter != All.end())
            where->generalizeDependRealize(*iter, in, 0, "", constraint);
        else
            Unresolved::addGeneralization(where, id, constraint);
    }
    else
        in.warning("'general' is missing");
}
void UmlCreateObjectAction::importIt(FileIn & in, Token & token, UmlItem * where)
{
    where = where->container(aCreateObjectAction, token, in);

    if (where != 0) {
        WrapperStr s = token.valueOf("name");
        UmlCreateObjectAction * a = create(where, s);

        if (a == 0)
            in.error("cannot create create object action '"
                     + s + "' in '" + where->name() + "'");

        a->addItem(token.xmiId(), in);

        s = token.valueOf("classifier");

        if (! token.closed()) {
            WrapperStr k = token.what();
            const char * kstr = k;

            while (in.read(), !token.close(kstr)) {
                if (token.what() == "classifier") {
                    s = token.xmiIdref();

                    if (! token.closed())
                        in.finish(token.what());
                }
                else
                    a->import(in, token);
            }
        }

        if (!s.isEmpty()) {
            QMap<QString, UmlItem *>::Iterator it = All.find(s);

            if (it == All.end())
                Unresolved::addRef(a, s);
            else
                a->set_Classifier((*it)->name());
        }
    }
}
Пример #8
0
bool UmlItem::setType(WrapperStr idref, int context, UmlTypeSpec & type)
{
    if (idref.isEmpty())
        return FALSE;
    else if (getType(idref, type))
        return TRUE;
    else {
        UnresolvedWithContext::add(this, idref, context);
        return FALSE;
    }
}
Пример #9
0
bool UmlItem::setType(WrapperStr idref, UmlTypeSpec & type)
{
    if (idref.isEmpty())
        return FALSE;
    else if (getType(idref, type))
        return TRUE;
    else {
        Unresolved::addRef(this, idref);
        return FALSE;
    }
}
Пример #10
0
WrapperStr IdlSettings::type(WrapperStr s)
{
    if (s.isEmpty())
        return s;

    read_if_needed_();

    UmlBuiltin * b = UmlSettings::_map_builtins.find(s);

    return (b) ? b->idl : s;
}
Пример #11
0
bool neq(const WrapperStr & s1, const WrapperStr & s2)
{
    const char * p1 = (s1.isNull()) ? "" : (const char *) s1;
    const char * p2 = (s2.isNull()) ? "" : (const char *) s2;

    for (;;) {
        while (*p1 == '\r') p1 += 1;

        while (*p2 == '\r') p2 += 1;

        if (*p1 == 0)
            return (*p2 != 0);

        if (*p1 != *p2)
            return true;

        p1 += 1;
        p2 += 1;
    }
}
Пример #12
0
WrapperStr JavaSettings::type(const WrapperStr & s)
{
    if (s.isEmpty())
        return s;

    read_if_needed_();

    UmlBuiltin * b = UmlSettings::_map_builtins.value(s);

    return (b) ? b->java : s;
}
Пример #13
0
void FileIn::finish(WrapperStr what)
{
    for (;;) {
        Token & tk = read(TRUE);

        if (tk.close(what))
            return;
        else if (tk.close())
            error("'&lt;/" + tk.what() + "&gt;' while wait for '&lt;/" + what + "&gt;'");
        else {
            WrapperStr s = tk.xmiId();

            if (! s.isEmpty())
                BypassedIds.insert(s);

            if (! tk.closed())
                finish(tk.what());
        }
    }
}
Пример #14
0
WrapperStr CppSettings::type(WrapperStr s)
{
    if (s.isEmpty())
        return s;

    read_if_needed_();

    UmlBuiltin * b = UmlSettings::_map_builtins.value(s);

    return (b) ? b->cpp : s;
}
Пример #15
0
static WrapperStr force_final_slash(WrapperStr p)
{
    int ln = p.length();

    if (ln < 2)
        return p;

    return (p[ln - 1] != '/')
           ? WrapperStr(p + '/')
           : p;
}
Пример #16
0
void UmlItem::replace_alias(WrapperStr & s)
{
    int index = 0;

    while ((index = s.find("@{", index)) != -1) {
        int index2 = s.find('}', index + 2);

        if (index2 == -1)
            return;

        UmlBaseItem * obj = this;
        WrapperStr key = s.mid(index + 2, index2 - index - 2);
        WrapperStr value;

        for (;;) {
            if (obj->propertyValue(key, value)) {
                s.replace(index, index2 - index + 1, value);
                index += value.length();
                break;
            }
            else if ((obj = obj->parent()) == 0) {
                index = index2 + 1;
                break;
            }
        }
    }
}
void UmlValueSpecificationAction::importIt(FileIn & in, Token & token, UmlItem * where)
{
    where = where->container(aValueSpecificationAction, token, in);

    if (where != 0) {
        WrapperStr s = token.valueOf("name");
        UmlValueSpecificationAction * a = create(where, s);

        if (a == 0)
            in.error("cannot create value specification action '"
                     + s + "' in '" + where->name() + "'");

        a->addItem(token.xmiId(), in);

        WrapperStr v = token.valueOf("value");

        if (! v.isEmpty())
            a->setValue(v);

        a->import_it(in, token);
    }
}
Пример #18
0
void UmlClass::solveGeneralizationDependencyRealization(int context, WrapperStr idref, WrapperStr label, WrapperStr constraint)
{
    QMap<QString, UmlItem *>::Iterator it = All.find(idref);

    if (it != All.end()) {
        static const struct {
            aRelationKind rk;
            const char * err;
        } r[] = {
            { aGeneralisation, "cannot create generalization from '" },
            { aDependency, "cannot create dependency from '" },
            { aRealization, "cannot create realization from '" },
            { aDependency, "cannot create usage from '" },
            { aDependency, "cannot create import from '" }
        };
        UmlItem * target = *it;
        UmlItem * rel;

        if (target->kind() == aClass)
            rel = UmlRelation::create(r[context].rk, this, (UmlClass *) target);
        else
            rel = UmlNcRelation::create(r[context].rk, this, target);

        if (rel == 0)
            UmlCom::trace(r[context].err + name() + "' to '" + target->name() + "'<br>");
        else {
            if (!label.isEmpty())
                rel->set_Name(label);

            if (!constraint.isEmpty() && (target->kind() == aClass))
                ((UmlRelation *) rel)->set_Constraint(constraint);

            if (context == 3)
                rel->set_Stereotype("use");
        }
    }
    else if (!FileIn::isBypassedId(idref))
        UmlCom::trace("relation : unknown target reference '" + idref + "'<br>");
}
Пример #19
0
void UmlActivityObject::setOrdering(WrapperStr s, FileIn & in)
{
    if (s == "unordered")
        set_Ordering(unordered);
    else if (s == "ordered")
        set_Ordering(ordered);
    else if (s == "LIFO")
        set_Ordering(lifo);
    else if (s == "FIFO")
        set_Ordering(fifo);
    else if (! s.isEmpty())
        in.warning("wrong ordering '" + s + "'");
}
Пример #20
0
WrapperStr UmlPackage::header_path(const WrapperStr & f, WrapperStr relto)
{
    if (!dir.read) {
        source_path(f);

        if (dir.h.isEmpty()) {
            UmlCom::trace(WrapperStr("<font color=\"red\"><b><b> The generation directory "
                                    "must be specified for the package<i> ") + name()
                          + "</i>, edit the <i> generation settings</i> (tab 'directory') "
                          "or edit the package (tab 'C++')</b></font><br>");
            UmlCom::bye(n_errors() + 1);
            UmlCom::fatal_error("UmlPackage::source_path");
        }

        if (QDir::isRelativePath(dir.h)) {
            UmlCom::trace(WrapperStr("<font color=\"red\"><b><i>")
                          + name() + "</i>'s header path <i>(" + dir.h
                          + "</i>) is not absolute, edit the <i> generation settings</i> "
                          "(tab 'directory'), or edit the package (tab 'C++')</b></font><br>");
            UmlCom::bye(n_errors() + 1);
            UmlCom::fatal_error("UmlPackage::source_path");
        }
    }

    if (f.isEmpty())
        return dir.h;

    QDir d(dir.h);

    if (! d.exists())
        create_directory(dir.h);	// don't return on error
    QByteArray temp = d.filePath(f).toLatin1();

    WrapperStr df = (dir.h_absolute || relto.isEmpty())
                   ? WrapperStr(temp.constData())
                   : relative_path(d, relto) + f;

    return df + WrapperStr(".") + CppSettings::headerExtension();
}
Пример #21
0
void UmlActivityObject::importIt(FileIn & in, Token & token, UmlItem * where)
{
    where = where->container(anActivityObject, token, in);

    if (where != 0) {
        WrapperStr s = token.valueOf("name");
        UmlActivityObject * a = create(where, s);

        if (a == 0)
            in.error("cannot create activity object '"
                     + s + "' in '" + where->name() + "'");

        a->addItem(token.xmiId(), in);

        WrapperStr ste;

        s = token.xmiType();

        switch (((const char *) s)[0]) {
        case 'D':
            ste = "datastore";
            break;

        case 'C':
            ste = "centralBuffer";
            break;

        default:
            break;
        }

        a->import_it(in, token);

        if (! ste.isNull())
            a->set_Stereotype(ste);
    }

}
Пример #22
0
void UmlItem::write_default_value(FileOut & out, WrapperStr v, UmlItem * who, int rank)
{
    if (! v.isEmpty()) {
        if (v[0] == '=') {
            v = v.mid(1);

            if (v.isEmpty())
                return;
        }

        out.indent();
        out << "<defaultValue xmi:type=\"uml:LiteralString\"";

        if (rank == -1)
            out.id_prefix(who, "VALUE_");
        else
            out.id_prefix(who, "VALUE", rank);

        out << " value=\"";
        out.quote((const char *)v); //[jasa] ambiguous call
        out << "\"/>\n";
    }
}
Пример #23
0
void UmlActivityObject::importMultiplicity(FileIn & in, Token & token, bool upper)
{
    WrapperStr s = token.valueOf("value");

    if (!s.isEmpty() &&
        (s != "Unspecified")) {	// VP
        WrapperStr m = multiplicity();

        if (m.isEmpty())
            m = s;
        else if (m != s) {
            if (upper)
                m += ".." + s;
            else
                m = s + ".." + m;
        }

        set_Multiplicity(m);
    }

    if (! token.closed())
        in.finish(token.what());
}
Пример #24
0
void FileOut::idref_datatype(const WrapperStr & t)
{
    if (t.isEmpty())
        return;

    QMap<QString, int>::ConstIterator it = _datatypes.find(t);

    if (it == _datatypes.end())
        it = _datatypes.insert(t, _datatypes.count());

    ((QTextStream &) *this) << " xmi:idref=\"BOUML_datatype_"
                             << it.value() << '"';

}
Пример #25
0
void UmlExtraClassMember::generate_def(QTextStream & f, WrapperStr indent,
                                       bool h, WrapperStr templates,
                                       WrapperStr, WrapperStr, WrapperStr)
{
    if (!cppDef().isEmpty() &&
        ((isCppInline() || !templates.isEmpty()) == h)) {
        const char * p = cppDef();

        if (*p != '#')
            f << indent;

        f << p;
    }
}
Пример #26
0
void UmlArtifact::importIt(FileIn & in, Token & token, UmlItem * where)
{
    where = where->container(anArtifact, token, in);

    if (where == 0)
        return;

    WrapperStr s = token.valueOf("name");

    if (s.isEmpty()) {
        static unsigned n = 0;

        s.sprintf("anonymous_artifact_%u", ++n);
    }

    UmlArtifact * artifact = create((UmlDeploymentView *) where, s);

    if (artifact == 0)
        in.error("cannot create artifact '" + s +
                 "' in '" + where->name() + "'");

    artifact->addItem(token.xmiId(), in);

    if (! token.closed()) {
        WrapperStr k = token.what();
        const char * kstr = k;

        while (in.read(), !token.close(kstr)) {
            if (token.what() == "manifestation")
                Manifestation::import(in, token, artifact);
            else
                artifact->UmlItem::import(in, token);
        }
    }

    artifact->unload(TRUE, FALSE);
}
Пример #27
0
void UmlItem::importExtension(FileIn & in, Token & token, UmlItem * where)
{
    if (! token.closed()) {
        WrapperStr s = token.valueOf("extender");

        if (s.isNull())
            s = token.valueOf("xmi:extender");

        if (s == "Bouml") {
            WrapperStr k = token.what();
            const char * kstr = k;

            while (in.read(), !token.close(kstr)) {
                s = token.what();

                if (s == "taggedvalue")
                    // is closed
                    where->set_PropertyValue(token.valueOf("tag"), token.valueOf("value"));
                else if (s == "stereotype")
                    where->set_Stereotype(token.valueOf("name"));

                if (! token.closed())
                    in.finish(token.what());
            }
        }
        else if (s == "Visual Paradigm for UML") {
            WrapperStr k = token.what();
            const char * kstr = k;

            while (in.read(), !token.close(kstr)) {
                s = token.what();

                if (s == "appliedstereotype") {
                    s = token.valueOf("xmi:value");

                    if (s.right(3) == "_id") {
                        s = s.mid(s.find("_") + 1);
                        s = s.left(s.length() - 3).lower();
                    }

                    where->set_Stereotype(s);
                }

                if (! token.closed())
                    in.finish(token.what());
            }
        }
        else
            in.finish(token.what());
    }
}
Пример #28
0
void UmlActivityObject::setInState(WrapperStr s)
{
    if (FromBouml && (s.left(8) != "BOUML_0x"))
        set_InState(s);
    else {
        QMap<QString, UmlItem *>::Iterator it = All.find(s);

        if (it != All.end()) {
            if ((*it)->kind() == aState)
                set_InState((*it)->name());
        }
        else
            UnresolvedWithContext::add(this, s, 1);
    }
}
Пример #29
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);
    }
}
Пример #30
0
void UmlNode::importIt(FileIn & in, Token & token, UmlItem * where)
{
    where = where->container(aNode, token, in);

    if (where == 0)
        return;

    WrapperStr s = token.valueOf("name");

    if (s.isEmpty()) {
        static unsigned n = 0;

        s.sprintf("anonymous_node_%u", ++n);
    }

    UmlNode * node = create((UmlDeploymentView *) where, s);

    if (node == 0)
        in.error("cannot create node '" + s +
                 "' in '" + where->name() + "'");

    node->addItem(token.xmiId(), in);

    if (token.xmiType() == "uml:Device")
        node->set_Stereotype("device");

    if (! token.closed()) {
        WrapperStr k = token.what();
        const char * kstr = k;

        while (in.read(), !token.close(kstr))
            node->UmlItem::import(in, token);
    }

    node->unload(TRUE, FALSE);
}