Esempio n. 1
0
void UmlItem::write_stereotyped(FileOut & out)
{
    QMap<QString, Q3PtrList<UmlItem> >::Iterator it;

    for (it = _stereotypes.begin(); it != _stereotypes.end(); ++it) {
        const char * st = it.key();
        UmlClass * cl = UmlClass::findStereotype(it.key(), TRUE);

        if (cl != 0) {
            Q3ValueList<WrapperStr> extended;

            cl->get_extended(extended);

            Q3PtrList<UmlItem> & l = it.data();
            UmlItem * elt;

            for (elt = l.first(); elt != 0; elt = l.next()) {
                out << "\t<" << st;
                out.id_prefix(elt, "STELT_");

                const Q3Dict<WrapperStr> props = elt->properties();
                Q3DictIterator<WrapperStr> itp(props);

                while (itp.current()) {
                    QString k = itp.currentKey();

                    if (k.contains(':') == 2) {
                        out << " ";
                        out.quote((const char *)k.mid(k.findRev(':') + 1)); //[jasa] ambiguous call
                        out << "=\"";
                        out.quote((const char *)*itp.current());
                        out << '"';
                    }

                    ++itp;
                }

                Q3ValueList<WrapperStr>::Iterator iter_extended;

                for (iter_extended = extended.begin();
                        iter_extended != extended.end();
                        ++iter_extended) {
                    WrapperStr vr = "base_" + *iter_extended;

                    out.ref(elt, vr);
                }

                out << "/>\n";

                elt->unload();
            }
        }
    }

}
Esempio n. 2
0
void UmlPackage::applyStereotype(FileIn & in, Token & token)
{
    WrapperStr prof_st;
    Q3ValueList<WrapperStr> base_v;
    WrapperStr s;

    if (UmlClass::isAppliedStereotype(token, prof_st, base_v)) {
        WrapperStr s;
        Q3ValueList<WrapperStr>::Iterator it_ext;

        for (it_ext = base_v.begin(); it_ext != base_v.end(); ++it_ext) {
            WrapperStr s2;

            if (token.valueOf(*it_ext, s2)) {
                if (s.isEmpty())
                    s = s2;
                else if (s != s2)
                    in.warning("doesn't refer to the same element ('" + s + "' != '" + s2 + "')");
            }
        }

        if (s.isEmpty())
            in.warning("value of 'base_...' is missing");
        else {
            UmlItem * elt = All[s];

            if (elt == 0) {
                if (!FileIn::isBypassedId(s))
                    in.warning("unknown reference '" + s + "'");
            }
            else {
                elt->set_Stereotype(prof_st);
                elt->UmlItem::applyStereotype();	// set properties

                Q3Dict<WrapperStr> props = elt->properties();
                Q3DictIterator<WrapperStr> it(props);

                while (it.current()) {
                    WrapperStr k = it.currentKey().latin1();

                    if (token.valueOf(k.mid(k.findRev(':') + 1).lower(), s))
                        elt->set_PropertyValue(k, s);

                    ++it;
                }
            }
        }

        if (! token.closed())
            in.finish(token.what());
    }
    else
        in.bypass(token);

}