void FileIn::bypass(Token & tk) { static QSet<QString> bypassed; WrapperStr s = tk.xmiType(); if (s.isEmpty()) { QString k = tk.what(); if (!bypassed.contains(k)) { warning("bypass <" + tk.what() + "...> (other cases not signaled)"); bypassed.insert(k); } } else { QString k = tk.what() + " " + s; if (!bypassed.contains(k)) { warning("bypass <" + tk.what() + " xmi:type=\"" + s + "\"...> (other cases not signaled)"); bypassed.insert(k); } } s = tk.xmiId(); if (! s.isEmpty()) BypassedIds.insert(s); if (! tk.closed()) finish(tk.what()); }
void Manifestation::import(FileIn & in, Token & token, UmlArtifact * artifact) { WrapperStr s; WrapperStr name; WrapperStr utilized; name = token.valueOf("name"); if (!(s = token.valueOf("utilizedelement")).isEmpty()) utilized = s; else if (!(s = token.valueOf("client")).isEmpty()) utilized = s; if (! token.closed()) { WrapperStr k = token.what(); const char * kstr = k; while (in.read(), !token.close(kstr)) { s = token.what(); if (s == "utilizedelement") utilized = token.xmiIdref(); else if ((s == "client") && s.isEmpty()) utilized = token.xmiIdref(); if (! token.closed()) in.finish(s); } } if (utilized.isEmpty()) in.warning("'utilizedElement' and 'client' missing in Manifestation"); else All.append(Manifestation(name, artifact, utilized)); }
void UmlClass::generalizeDependRealize(UmlItem * target, FileIn & in, int context, WrapperStr label, WrapperStr constraint) { 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 * 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) in.warning(r[context].err + name() + "' to '" + target->name() + "'"); else { if (! label.isEmpty()) rel->set_Name(label); if (! constraint.isEmpty() && (target->kind() == aClass)) ((UmlRelation *) rel)->set_Constraint(constraint); } }
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); }
void UmlItem::write_description_properties(FileOut & out) { if (! description().isEmpty()) { static int rank = 0; out.indent(); out << "<ownedComment xmi:type=\"uml:Comment\" xmi:id=\"COMMENT_" << ++rank << "\" body=\""; out.quote((const char *)description()); //[jasa] ambiguous call out << "\"/>\n"; } WrapperStr ste = stereotype(); if (_gen_extension) { const Q3Dict<WrapperStr> up = properties(); Q3DictIterator<WrapperStr> it(up); if (it.current()) { out.indent(); out << "<xmi:Extension extender=\"Bouml\">\n"; if (! ste.isEmpty()) { out.indent(); out << "\t<stereotype name=\""; out.quote((const char *)ste); //[jasa] ambiguous call out << "\"/>\n"; } do { out.indent(); out << "\t<taggedValue tag=\""; out.quote((const char *)it.currentKey()); //[jasa] ambiguous call out << "\" value=\""; out.quote((const char *) * (it.current())); //[jasa] ambiguous call out << "\"/>\n"; ++it; } while (it.current()); out.indent(); out << "</xmi:Extension>\n"; } else if (! ste.isEmpty()) { out.indent(); out << "<xmi:Extension extender=\"Bouml\"><stereotype name=\""; out.quote((const char *)ste); //[jasa] ambiguous call out << "\"/></xmi:Extension>\n"; } } if (ste.operator QString().contains(':') == 1) // probably a stereotype part of profile _stereotypes[ste].append(this); }
void UmlClass::readFormal(FileIn & in, Token & token) { if (! token.closed()) { signatures[token.xmiId()] = this; WrapperStr k = token.what(); const char * kstr = k; unsigned int rank = 0; while (in.read(), !token.close(kstr)) { WrapperStr s = token.what(); if (s == "parameter") { // useless if (! token.closed()) in.finish(token.what()); } else if ((s == "ownedparameter") && (token.xmiType() == "uml:ClassifierTemplateParameter")) { WrapperStr idparam = token.xmiId(); WrapperStr pname = token.valueOf("name"); // at least for VP WrapperStr value; if (! token.closed()) { while (in.read(), !token.close("ownedparameter")) { s = token.what(); if ((s == "ownedparameteredelement") || (s == "ownedelement")) { s = token.valueOf("name"); if (! s.isEmpty()) pname = s; } else if (s == "defaultvalue") value = token.valueOf("value"); if (! token.closed()) in.finish(token.what()); } } if (! pname.isEmpty()) { UmlFormalParameter f(pname, value); addFormal(rank++, f); formalsId.append(idparam); } } else if (! token.closed()) in.finish(token.what()); } } }
void UmlState::importActivity(FileIn & in, Token & token) { WrapperStr k = token.what(); const char * kstr = k; WrapperStr b = token.valueOf("body"); if (b.isEmpty()) { if (! token.closed()) { while (in.read(), !token.close(kstr)) { WrapperStr s = token.what(); if (s == "body") { b = in.body("body"); in.finish(k); break; } else if ((s == "node") && (token.xmiType() == "uml:CallOperationAction")) { s = token.valueOf("operation"); if (! s.isEmpty()) { if (k == "entry") UnresolvedWithContext::add(this, s, 0); else if (k == "exit") UnresolvedWithContext::add(this, s, 1); else UnresolvedWithContext::add(this, s, 2); } if (! token.closed()) in.finish("node"); in.finish(k); return; } else if (! token.closed()) in.finish(s); } } } else if (! token.closed()) in.finish(k); if (! b.isEmpty()) { if (k == "entry") set_EntryBehavior(b); else if (k == "exit") set_ExitBehavior(b); else set_DoActivity(b); } }
WrapperStr UmlPackage::source_path(const WrapperStr & f, WrapperStr relto) { if (!dir.read) { dir.src = cppSrcDir(); dir.h = cppHDir(); dir.src_absolute = dir.h_absolute = FALSE; QDir d_root(rootDir()); if (dir.src.isEmpty()) // considered given relative dir.src = RootDir; else if (QDir::isRelativePath(dir.src)) dir.src = d_root.filePath(dir.src); else dir.src_absolute = TRUE; if (dir.h.isEmpty()) // considered given relative dir.h = RootDir; else if (QDir::isRelativePath(dir.h)) dir.h = d_root.filePath(dir.h); else dir.h_absolute = TRUE; if (dir.src.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"); } dir.read = TRUE; } if (f.isEmpty()) return dir.src; QDir d(dir.src); if (! d.exists()) create_directory(dir.src); // don't return on error QByteArray temp = d.filePath(f).toLatin1(); WrapperStr df = (dir.src_absolute || relto.isEmpty()) ? WrapperStr(temp.constData()) : relative_path(d, relto) + f; return df + WrapperStr(".") + CppSettings::sourceExtension(); }
Package::Package(Package * parent, UmlPackage * pk) : BrowserNode(parent, pk->name()) { //if (text(0) == "unknown") // unknown = this; uml = pk; QDir d_root(RootSDir); h_path = force_final_slash(pk->cppHDir()); if (h_path.isEmpty()) h_path = RootCDir; else if (QDir::isRelativePath(h_path)) { if (RootCDir.isEmpty()) { WrapperStr err = "<font face=helvetica><b>root path not set in <i>generation settings</i>, " "don't know where is <i>" + h_path + "<i></b></font><br>"; UmlCom::trace(err); } else h_path = force_final_slash(d_root.filePath(h_path)); } src_path = force_final_slash(pk->cppSrcDir()); if (src_path.isEmpty()) src_path = RootCDir; else if (QDir::isRelativePath(src_path)) { if (RootCDir.isEmpty()) { WrapperStr err = "<font face=helvetica><b>root path not set in <i>generation settings</i>, " "don't know where is <i>" + src_path + "<i></b></font><br>"; UmlCom::trace(err); } else src_path = force_final_slash(d_root.filePath(src_path)); } namespace_ = pk->cppNamespace(); if (!h_path.isEmpty()) Pack_From_Path.replace(h_path, this); if ((h_path != src_path) && !src_path.isEmpty()) Pack_From_Path.replace(src_path, this); }
void UmlItem::write_multiplicity(FileOut & out, WrapperStr s, UmlItem * who) { if (!s.isEmpty()) { WrapperStr min; WrapperStr max; int index = s.find(".."); if (index != -1) { min = s.left(index).stripWhiteSpace(); max = s.mid(index + 2).stripWhiteSpace(); } else min = max = s.stripWhiteSpace(); out.indent(); out << "<lowerValue xmi:type=\"uml:LiteralString\""; out.id_prefix(who, "MULTIPLICITY_L_"); out << " value=\"" << min.operator QString() << "\"/>\n"; out.indent(); out << "<upperValue xmi:type=\"uml:LiteralString\""; out.id_prefix(who, "MULTIPLICITY_U_"); out << " value=\"" << max.operator QString() << "\"/>\n"; } }
void UmlItem::importComment(FileIn & in, Token & token, UmlItem * where) { WrapperStr doc = readComment(in, token); if (! doc.isEmpty()) where->set_Description(doc); }
static void manage_decorators(QTextStream & f, const WrapperStr & decorators, QString indent, BooL & indent_needed) { if (! decorators.isEmpty()) { int index = 0; int index2; while ((index2 = decorators.find("\n", index)) != -1) { if (indent_needed) f << indent; else indent_needed = TRUE; f << decorators.mid(index, index2 + 1 - index); index = index2 + 1; } if (index != (int) decorators.length()) { if (indent_needed) { f << indent; indent_needed = FALSE; } f << decorators.mid(index); } } }
void UmlClass::importPrimitiveType(FileIn & in, Token & token, UmlItem *) { WrapperStr id = token.xmiId(); UmlTypeSpec t; t.explicit_type = token.valueOf("name"); if (FromBouml) { if (! token.closed()) { BooL dummy; in.read(); // <xmi:Extension extender="Bouml"> in.readWord(FALSE, dummy); // < in.readWord(FALSE, dummy); // basedOn t.type = dynamic_cast<UmlClass *>(All[in.readWord(FALSE, dummy)]); if (t.type != 0) // forget modifiers t.explicit_type = ""; in.readWord(FALSE, dummy); // / in.readWord(FALSE, dummy); // > in.read(); // </xmi:Extension> in.read(); // end of token } } else if (! token.closed()) in.finish(token.what()); if (!id.isEmpty()) PrimitiveTypes[id] = t; }
void write_trace_header() { if (!Verbose && !TraceHeader.isEmpty()) { UmlCom::trace("<hr>" + TraceHeader); TraceHeader = ""; } }
WrapperStr UmlItem::readComment(FileIn & in, Token & token) { in.bypassedId(token); WrapperStr doc = token.valueOf("body"); if (! token.closed()) { WrapperStr k = token.what(); const char * kstr = k; while (in.read(), !token.close(kstr)) { if (token.what() == "body") { if (! doc.isEmpty()) doc += "\n"; doc += in.body("body"); } else if (! token.closed()) in.finish(token.what()); } } return doc; }
void UmlAccessVariableValueAction::import_it(FileIn & in, Token & token) { WrapperStr s = token.valueOf("variable"); if (! s.isEmpty()) setVariable(s); if (! token.closed()) { WrapperStr k = token.what(); const char * kstr = k; while (in.read(), !token.close(kstr)) { s = token.what(); if (s == "variable") { setVariable(token.xmiIdref()); if (! token.closed()) in.finish("variable"); } else import(in, token); } } }
void Package::use() { WrapperStr s1; while (!(s1 = Lex::read_word()).isEmpty()) { WrapperStr s = Lex::read_word(); WrapperStr s2; if (s == "as") { s2 = Lex::read_word(); s = Lex::read_word(); } else { int p = s1.operator QString().lastIndexOf('\\'); s2 = (p == -1) ? WrapperStr() // strange : s1.mid(p + 1); } if (! s2.isEmpty()) Namespace::add_alias(s2, s1); if ((s == ";") || s.isEmpty()) return; else if (s != ",") { UmlOperation::skip_body(0); return; } } }
WrapperStr UmlPackage::rootDir(aLanguage who) { if (! RootDirRead) { RootDirRead = TRUE; switch (who) { case cppLanguage: RootDir = CppSettings::rootDir(); break; case javaLanguage: RootDir = JavaSettings::rootDir(); break; case phpLanguage: RootDir = PhpSettings::rootDir(); break; default: RootDir = PythonSettings::rootDir(); } if (!RootDir.isEmpty() && // empty -> error QDir::isRelativePath(RootDir)) { QFileInfo f(getProject()->supportFile()); QDir d(f.path()); RootDir = d.filePath(RootDir); } } return RootDir; }
bool UmlClass::isPrimitiveType(Token & token, UmlTypeSpec & ts) { if (token.xmiType() != "uml:PrimitiveType") return FALSE; WrapperStr href = token.valueOf("href"); int index; if (href.isEmpty() || ((index = href.find('#')) == -1)) return FALSE; ts.explicit_type = href.mid(index + 1); if ((CppSettings::type(ts.explicit_type) == ts.explicit_type) && CppSettings::umlType(ts.explicit_type).isEmpty()) { // not defined href = ts.explicit_type.lower(); if (href == "integer") ts.explicit_type = "int"; else if (href == "boolean") ts.explicit_type = "bool"; else if (href == "string") ts.explicit_type = "string"; else if (href == "unlimitednatural") ts.explicit_type = "long"; } return TRUE; }
void UmlActivity::readCondition(FileIn & in, Token & token) { if (! token.closed()) { WrapperStr k = token.what(); const char * kstr = k; while (in.read(), !token.close(kstr)) { WrapperStr s = token.what(); if (s == "specification") { WrapperStr v = token.valueOf("body"); if (v.isNull()) v = token.valueOf("value"); // UMODEL if (! v.isEmpty()) { if (k[1] == 'r') set_PreCondition(v); else set_PostCondition(v); } } if (! token.closed()) in.finish(s); } } }
void UmlArtifact::roundtrip_java() { if (! managed) { managed = TRUE; if (stereotype() != "source") return; const WrapperStr srcdef = javaSource(); if (srcdef.isEmpty()) return; const WrapperStr & name = UmlArtifact::name(); UmlPackage * pack = package(); WrapperStr src_path = pack->java_path(name); { WrapperStr s = " <i> " + src_path + "</i>"; UmlCom::message(name); if (verbose()) UmlCom::trace(WrapperStr("<hr><font face=helvetica>roundtrip body from") + s + "</font><br>"); else set_trace_header(WrapperStr("<font face=helvetica>roundtrip body from") + s + "</font><br>"); } UmlOperation::roundtrip(src_path, javaLanguage); } }
void FileIn::bypassedId(Token & tk) { WrapperStr s = tk.xmiId(); if (! s.isEmpty()) BypassedIds.insert(s); }
void UmlArtifact::roundtrip_cpp() { if (! managed) { managed = TRUE; if (stereotype() != "source") return; const WrapperStr hdef = cppHeader(); const WrapperStr srcdef = cppSource(); if (hdef.isEmpty() && srcdef.isEmpty()) return; const WrapperStr & name = UmlArtifact::name(); UmlPackage * pack = package(); WrapperStr h_path = pack->header_path(name); WrapperStr src_path = pack->source_path(name); { WrapperStr s; if (!hdef.isEmpty()) s = "<i> " + h_path + "</i>"; if (!srcdef.isEmpty()) { if (!hdef.isEmpty()) s += " and <i> " + src_path + "</i>"; else s = "<i> " + src_path + "</i>"; } UmlCom::message(name); if (verbose()) UmlCom::trace(WrapperStr("<hr><font face=helvetica>roundtrip body from") + s + "</font><br>"); else set_trace_header(WrapperStr("<font face=helvetica>roundtrip body from") + s + "</font><br>"); } UmlOperation::roundtrip(h_path, cppLanguage); UmlOperation::roundtrip(src_path, cppLanguage); } }
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); } }
unsigned UmlSettings::multiplicity_column(const WrapperStr & mult) { if (mult.isEmpty() || (mult == "1")) return 0; if ((mult == "*") || (mult.find("..") != -1)) return 1; return 2; }
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"); }
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; } }
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; } }
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; }
void UmlReduceAction::importIt(FileIn & in, Token & token, UmlItem * where) { where = where->container(aReduceAction, token, in); if (where != 0) { WrapperStr s = token.valueOf("name"); UmlReduceAction * a = create(where, s); if (a == 0) in.error("cannot create reduce action '" + s + "' in '" + where->name() + "'"); a->addItem(token.xmiId(), in); if (token.valueOf("isordered") == "true") a->set_isOrdered(TRUE); s = token.valueOf("reducer"); if (! token.closed()) { WrapperStr k = token.what(); const char * kstr = k; while (in.read(), !token.close(kstr)) { if (token.what() == "reducer") { 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 { switch ((*it)->kind()) { case anActivity: case aState: a->set_Reducer(*it); break; default: break; } } } } }