本文整理汇总了C++中UmlClass类的典型用法代码示例。如果您正苦于以下问题:C++ UmlClass类的具体用法?C++ UmlClass怎么用?C++ UmlClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UmlClass类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: parent
UmlClass * UmlClass::addMetaclass(WrapperStr mclname, const char * mclpath)
{
UmlPackage * pack = (UmlPackage *) parent()->parent(); // is a package
const Q3PtrVector<UmlItem> ch = pack->children();
unsigned n = ch.size();
UmlClass * r = 0;
for (unsigned i = 0; i != n; i += 1) {
UmlItem * x = ch[i];
if ((x->kind() == aClassView) &&
!strncmp(x->name(), "meta classes", 12) &&
((r = UmlClass::create(x, mclname)) != 0))
break;
}
if (r == 0) {
WrapperStr s = "meta classes";
UmlItem * v = 0;
while ((v = UmlClassView::create(pack, s)) == 0)
s += "_";
r = UmlClass::create(v, mclname);
}
r->set_Stereotype("metaclass");
if (mclpath != 0)
r->set_PropertyValue("metaclassPath", mclpath);
return r;
}
开发者ID:daniel7solis,项目名称:douml,代码行数:33,代码来源:UmlClass.cpp
示例2: findItem
bool UmlClass::replaceType(UmlTypeSpec & t, Q3CString & target_id, const Q3CString & ts)
{
UmlClass * cl = (UmlClass *) findItem(target_id, aClass);
bool result = FALSE;
if (cl != 0) {
int index = 0;
const Q3CString & s = cl->name();
unsigned ln1 = s.length();
unsigned ln2 = ts.length();
while ((index = t.explicit_type.find(s, index)) != -1) {
if (((index == 0) || isSep(((const char *) t.explicit_type)[index - 1])) &&
isSep(((const char *) t.explicit_type)[index + (int) ln1])) {
t.explicit_type.replace((unsigned) index, ln1, ts);
index += ln2;
result = TRUE;
}
else
index += 1;
}
}
if (result) {
target_id = t.explicit_type;
t.explicit_type = 0;
t.type = cl;
}
return result;
}
开发者ID:SciBoy,项目名称:douml,代码行数:31,代码来源:UmlClass.cpp
示例3: generate
void UmlJunctionPseudoState::generate(UmlClass * machine, UmlClass * anystate, UmlState * state) {
// create an operation because a priori shared
if (_oper.isEmpty())
_oper.sprintf("_junction%d", ++_rank);
UmlClass * cl = state->assocClass();
UmlOperation * junction;
if (((junction = (UmlOperation *) cl->getChild(anOperation, _oper)) == 0) &&
((junction = UmlBaseOperation::create(cl, _oper)) == 0)) {
UmlCom::trace("Error : cannot create operation '" + _oper
+ "' in class '" + cl->name() + "'<br>");
throw 0;
}
junction->defaultDef();
junction->setComment("implement a junction, through an operation because shared, internal");
junction->setType("void", "${type}");
junction->addParam(0, InputOutputDirection, "stm", machine);
junction->setParams("${t0} & ${p0}");
Q3CString body;
const Q3PtrVector<UmlItem> ch = children();
Q3PtrList<UmlTransition> trs;
unsigned index;
for (index = 0; index != ch.count(); index += 1)
if (ch[index]->kind() == aTransition)
// theo mandatory
trs.append((UmlTransition *) ch[index]);
UmlTransition::generate(trs, machine, anystate, state, body, " ", FALSE);
junction->set_CppBody(body);
}
开发者ID:SciBoy,项目名称:douml,代码行数:35,代码来源:UmlJunctionPseudoState.cpp
示例4: new_one
bool UmlAttribute::new_one(Class * container, Q3CString name,
aVisibility visibility, bool constp,
bool staticp, const Q3CString & value,
Q3CString comment, Q3CString description)
{
#ifdef TRACE
cout << "ATTRIBUTE '" << name << "'\n";
#endif
#ifndef REVERSE
if (visibility == PrivateVisibility)
return TRUE;
#endif
if (((const char *) name)[0] == '$')
name = name.mid(1);
UmlClass * cl = container->get_uml();
UmlAttribute * at = UmlBaseAttribute::create(cl, name);
if (at == 0) {
PhpCatWindow::trace(Q3CString("<font face=helvetica><b>cannot add attribute <i>")
+ name + "</i> in <i>" + cl->name()
+ "</i></b></font><br>");
return FALSE;
}
#ifdef REVERSE
Statistic::one_attribute_more();
#endif
if (!comment.isEmpty()) {
Q3CString s = (at->phpDecl().find("${description}") != -1)
? description : comment;
UmlTypeSpec t;
int index;
if (! (t.explicit_type = value_of(s, "@var", index)).isEmpty()) {
at->set_Type(t);
s.replace(index, t.explicit_type.length(), "${type}");
}
at->set_Description(s);
}
if (constp)
at->set_isReadOnly(TRUE);
if (staticp)
at->set_isClassMember(TRUE);
if (! value.isEmpty())
at->set_DefaultValue(value);
at->set_Visibility(visibility);
return TRUE;
}
开发者ID:SciBoy,项目名称:douml,代码行数:58,代码来源:UmlAttribute.cpp
示例5: while
void UmlClass::importInstantiate(File & f) {
if (scanning) {
f.skipNextForm();
return;
}
f.read("(");
f.read("object");
f.read("Instantiation_Relationship");
Q3CString id;
Q3CString ste;
Q3CString doc;
Q3Dict<Q3CString> prop;
Q3CString s2;
int k;
do {
k = f.readDefinitionBeginning(s2, id, ste, doc, prop);
} while (id.isEmpty());
for (;;) {
if (k == ATOM) {
if (s2 == "quidu")
break;
f.skipNextForm();
k = f.read(s2);
}
else
f.syntaxError(s2);
}
if (f.read(s2) != STRING)
f.syntaxError(s2, "quidu value");
UmlClass * target = (UmlClass *) findItem(s2, aClass);
if (target != 0) {
UmlRelation * r = UmlRelation::create(aRealization, this, target);
if (r == 0)
UmlCom::trace("<br>cannot create aRealization from '" +
fullName() + "' to '" + target->fullName() + "'");
else {
newItem(r, id);
if (!ste.isEmpty())
r->set_Stereotype(ste);
if (!doc.isEmpty())
r->set_Description(doc);
r->setProperties(prop);
}
}
f.skipBlock();
}
开发者ID:SciBoy,项目名称:douml,代码行数:55,代码来源:UmlClass.cpp
示例6: write_stereotyped
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();
}
}
}
}
开发者ID:vresnev,项目名称:douml,代码行数:55,代码来源:UmlItem.cpp
示例7: generate
void UmlClass::generate()
{
if (! flat) {
int n = classes.size();
for (int i = 0; i != n; i += 1)
{
UmlClass * cl = (UmlClass *)classes.elementAt(i);
cl->html();
}
}
}
开发者ID:DoUML,项目名称:douml,代码行数:13,代码来源:UmlClass.cpp
示例8: findStereotype
bool UmlClass::isAppliedStereotype(Token & tk, WrapperStr & prof_st, Q3ValueList<WrapperStr> & base_v)
{
static Q3Dict<WrapperStr> stereotypes;
static Q3Dict<Q3ValueList<WrapperStr> > bases;
WrapperStr s = tk.what();
WrapperStr * st = stereotypes[s];
if (st != 0) {
prof_st = *st;
base_v = *bases[s];
return TRUE;
}
base_v.clear();
if (tk.xmiType().isEmpty() && (getFct(tk) == 0)) {
int index = s.find(':');
if ((index != -1) &&
((index != 3) || ((s.left(3) != "uml") && (s.left(3) != "xmi")))) {
UmlClass * cl = findStereotype(s, FALSE);
if (cl != 0) {
const Q3PtrVector<UmlItem> ch = cl->children();
unsigned n = ch.size();
for (unsigned i = 0; i != n; i += 1) {
UmlItem * x = ch[i];
if ((x->kind() == aRelation) &&
(((UmlRelation *) x)->relationKind() == aDirectionalAssociation) &&
(((UmlRelation *) x)->roleType()->stereotype() == "metaclass"))
base_v.append("base_" + ((UmlRelation *) x)->roleType()->name().lower());
}
if (base_v.isEmpty())
base_v.append("base_element");
prof_st = cl->parent()->parent()->name() + ":" + cl->name();
stereotypes.insert(s, new WrapperStr(prof_st));
bases.insert(s, new Q3ValueList<WrapperStr>(base_v));
return TRUE;
}
}
}
return FALSE;
}
开发者ID:daniel7solis,项目名称:douml,代码行数:49,代码来源:UmlClass.cpp
示例9: it
void UmlClass::extend(WrapperStr mcl)
{
if (parent()->parent()->kind() != aPackage)
return;
int index = mcl.find('#');
if (index == -1)
return;
WrapperStr path = mcl.left(index);
const char * defltpath0 = "http://schema.omg.org/spec/UML/2.0/uml.xml";
const char * defltpath1 = "http://schema.omg.org/spec/UML/2.1/uml.xml";
bool dflt = ((path == defltpath0) || (path == defltpath1));
mcl = mcl.mid(index + 1);
static Q3PtrList<UmlClass> metaclasses;
Q3PtrListIterator<UmlClass> it(metaclasses);
UmlClass * metacl = UmlClass::get(mcl, 0);
WrapperStr s;
if ((metacl == 0) ||
(metacl->stereotype() != "metaclass") ||
!((dflt) ? (!metacl->propertyValue("metaclassPath", s) ||
(s == defltpath0) ||
(s == defltpath1))
: (metacl->propertyValue("metaclassPath", s) &&
(path == s)))) {
metacl = 0;
if (dflt) {
for (; (metacl = it.current()) != 0; ++it) {
if (!strcmp(mcl, metacl->name()) &&
(!metacl->propertyValue("metaclassPath", s) ||
(s == defltpath0) ||
(s == defltpath1)))
break;
}
}
else {
for (; (metacl = it.current()) != 0; ++it) {
if (!strcmp(mcl, metacl->name()) &&
metacl->propertyValue("metaclassPath", s) &&
(path == s))
break;
}
}
if (metacl == 0) {
metacl = addMetaclass(mcl, (dflt) ? 0 : (const char *)path); //[rageek] different types for ? :
metaclasses.append(metacl);
}
}
UmlRelation::create(aDirectionalAssociation, this, metacl);
}
开发者ID:daniel7solis,项目名称:douml,代码行数:58,代码来源:UmlClass.cpp
示例10: importIdlConstant
void UmlClass::importIdlConstant(UmlItem * parent, const Q3CString & id, const Q3CString & s, const Q3CString & doc, Q3Dict<Q3CString> & prop)
{
// use a class to define the constant !
UmlClass * x;
if ((x = UmlClass::create(parent, legalName(s))) == 0) {
UmlCom::trace("<br>cannot create class '" + s + "' in " +
parent->fullName());
throw 0;
}
newItem(x, id);
x->lang = Corba;
x->set_Stereotype("constant");
if (!doc.isEmpty())
x->set_Description(doc);
Q3CString type;
Q3CString value;
Q3CString * v;
if ((v = prop.find("CORBA/ImplementationType")) != 0) {
type = *v;
prop.remove("CORBA/ImplementationType");
}
if ((v = prop.find("CORBA/ConstValue")) != 0) {
if (!v->isEmpty())
value = " = " + *v;
prop.remove("CORBA/ConstValue");
}
Q3CString d = IdlSettings::constDecl();
int index;
if ((index = d.find("${type}")) != -1)
d.replace(index, 7, type);
if ((index = d.find("${value}")) != -1)
d.replace(index, 8, value);
x->setProperties(prop);
x->set_IdlDecl(d);
}
开发者ID:SciBoy,项目名称:douml,代码行数:45,代码来源:UmlClass.cpp
示例11: new_friend
bool UmlRelation::new_friend(Class * container, UmlClass * to,
Q3PtrList<UmlItem> & expected_order)
{
UmlClass * from = container->get_uml();
#ifdef DEBUG_BOUML
cout << "FRIEND from '" << from->name() << "' to '" << to->name() << "'\n";
#endif
const Q3PtrVector<UmlItem> & ch = from->children();
UmlItem ** v = ch.data();
UmlItem ** const vsup = v + ch.size();
for (;v != vsup; v += 1) {
if (((*v)->kind() == aRelation) &&
(((UmlRelation *) *v)->relationKind() == aDependency) &&
(((UmlRelation *) *v)->roleType() == to) &&
!neq((*v)->stereotype(), "friend")) {
expected_order.append(*v);
((UmlRelation *) *v)->set_usefull();
return TRUE;
}
}
// relation not found
UmlRelation * rel = UmlBaseRelation::create(aDependency, from, to);
if (rel == 0) {
UmlCom::trace(Q3CString("<font face=helvetica><b>cannot add friend relation in <i>")
+ from->name() + "</i> to <i>"
+ to->name() + "</i></b></font><br><hr><br>");
return FALSE;
}
expected_order.append(rel);
container->set_updated();
rel->set_CppDecl("Generated");
return rel->set_Stereotype("friend");
}
开发者ID:SciBoy,项目名称:douml,代码行数:42,代码来源:UmlRelation.cpp
示例12: parent
UmlClass * UmlClass::auxilarily_typedef(const WrapperStr & base
#ifdef REVERSE
, bool libp
# ifdef ROUNDTRIP
, bool container_roundtrip
, QList<UmlItem *> & container_expected_order
# endif
#endif
)
{
WrapperStr typedef_decl = CppSettings::typedefDecl();
const QVector<UmlItem*>& children = parent()->children();
unsigned n = children.count();
unsigned index;
// a typedef with the right definition already exist ?
for (index = 0; index != n; index += 1) {
if (children[index]->kind() == aClass) {
UmlClass * cl = (UmlClass *) children[index];
if ((cl->stereotype() == "typedef") &&
(cl->cppDecl() == typedef_decl) &&
(cl->baseType().explicit_type == base)) {
#ifdef ROUNDTRIP
cl->set_usefull();
if (container_roundtrip)
container_expected_order.append(cl);
#endif
return cl;
}
}
}
// must create typedef with a new name
for (;;) {
static unsigned nty;
QString s("typedef%1");
s=s.arg(QString::number(++nty));
for (index = 0; index != n; index += 1)
if (children[index]->name() == s)
break;
if (index == n) {
UmlClass * cl = UmlClass::create(parent(), s.toLatin1().constData());
if (cl == 0) {
#ifdef REVERSE
UmlCom::message("");
CppCatWindow::trace(WrapperStr("<font face=helvetica><b>cannot create class <i>")
+ s + "</i> under <i>"
+ parent()->name() + "</b></font><br>");
throw 0;
#else
QMessageBox::critical(0, "Fatal Error",
WrapperStr("<font face=helvetica><b>cannot create class <i>")
+ s + "</i> under <i>"
+ parent()->name() + "</b></font><br>");
QApplication::exit(1);
#endif
}
UmlTypeSpec typespec;
typespec.explicit_type = base;
cl->set_Stereotype("typedef");
cl->set_BaseType(typespec);
cl->set_CppDecl(typedef_decl);
#ifdef REVERSE
if (!libp)
cl->need_artifact(Namespace::current());
# ifdef ROUNDTRIP
if (container_roundtrip)
container_expected_order.append(cl);
# endif
#endif
return cl;
}
}
}
开发者ID:ErickCastellanos,项目名称:douml,代码行数:89,代码来源:UmlClass.cpp
示例13: parent
void UmlAttribute::generate_def(QTextOStream & f, Q3CString indent, bool h,
Q3CString templates, Q3CString cl_names,
Q3CString, Q3CString) {
if (isClassMember() && !cppDecl().isEmpty()) {
UmlClass * cl = (UmlClass *) parent();
if ((!templates.isEmpty() || ((cl->name().find('<') != -1))) ? h : !h) {
const char * p = cppDecl();
const char * pp = 0;
while ((*p == ' ') || (*p == '\t'))
p += 1;
bool re_template = !templates.isEmpty() &&
insert_template(p, f, indent, templates);
if (*p != '#')
f << indent;
const char * pname = name_spec(p);
for (;;) {
if (*p == 0) {
if (pp == 0)
break;
// comment management done
p = pp;
pp = 0;
if (re_template)
f << templates;
if (*p == 0)
break;
f << indent;
}
if (*p == '\n') {
f << *p++;
if (*p && (*p != '#'))
f << indent;
}
else if (*p == '@')
manage_alias(p, f);
else if (*p != '$') {
if (p == pname)
f << cl_names << "::";
f << *p++;
}
else if (!strncmp(p, "${comment}", 10)) {
if (!manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment())
&& re_template)
f << templates;
}
else if (!strncmp(p, "${description}", 14)) {
if (!manage_description(p, pp) && re_template)
f << templates;
}
else if (!strncmp(p, "${name}", 7)) {
if (*pname == '$')
f << cl_names << "::";
p += 7;
f << name();
}
else if (!strncmp(p, "${multiplicity}", 15)) {
p += 15;
const Q3CString & m = multiplicity();
if (!m.isEmpty() && (*((const char *) m) == '['))
f << m;
else
f << '[' << m << ']';
}
else if (!strncmp(p, "${stereotype}", 13)) {
p += 13;
f << CppSettings::relationAttributeStereotype(stereotype());
}
else if (!strncmp(p, "${value}", 8)) {
if (!defaultValue().isEmpty()) {
if (need_equal(p, defaultValue()))
f << " = ";
f << defaultValue();
}
p += 8;
}
else if (!strncmp(p, "${h_value}", 10))
p += 10;
else if (!strncmp(p, "${static}", 9)) {
p += 9;
}
else if (!strncmp(p, "${const}", 8)) {
p += 8;
if (isReadOnly())
f << "const ";
}
else if (!strncmp(p, "${volatile}", 11)) {
p += 11;
//.........这里部分代码省略.........
开发者ID:SciBoy,项目名称:douml,代码行数:101,代码来源:UmlAttribute.cpp
示例14: QLOG_INFO
bool UmlAttribute::new_one(Class * container, const WrapperStr & name,
UmlTypeSpec typespec, aVisibility visibility,
bool staticp, bool finalp, bool transientp,
bool volatilep, const WrapperStr & array,
const WrapperStr & value, WrapperStr comment,
WrapperStr description, WrapperStr annotation
#ifdef ROUNDTRIP
, bool roundtrip, QList<UmlItem *> & expected_order
#endif
)
{
#ifdef TRACE
QLOG_INFO() << "ATTRIBUTE '" << name << "'\n";
#endif
if (
#ifdef REVERSE
container->from_libp() && (
#endif
visibility == PrivateVisibility
#ifdef REVERSE
)
#endif
)
{
Lex::finish_line();
Lex::clear_comments();
return TRUE;
}
UmlClass * cl = container->get_uml();
UmlAttribute * at;
#ifdef ROUNDTRIP
bool created;
if (!roundtrip ||
((at = search_attr(container, name)) == 0)) {
#endif
at = UmlBaseAttribute::create(cl, name);
if (at == 0) {
JavaCatWindow::trace(WrapperStr("<font face=helvetica><b>cannot add attribute <i>")
+ name + "</i> in <i>" + cl->name()
+ "</i></b></font><br>");
return FALSE;
}
#ifdef REVERSE
# ifndef ROUNDTRIP
Statistic::one_attribute_more();
# else
if (roundtrip)
container->set_updated();
created = TRUE;
}
else
created = FALSE;
# endif
#endif
Lex::finish_line();
comment = Lex::get_comments(comment);
description = Lex::get_description(description);
WrapperStr decl = JavaSettings::attributeDecl("");
int index = decl.find("${type}");
if ((index == -1) || (decl.find("${name}") == -1)) {
decl = " ${comment}${@}${visibility}${static}${final}${transient}${volatile}${type} ${name}${value};";
index = decl.find("${type}");
}
#ifdef ROUNDTRIP
if (roundtrip && !created) {
if (decl.find("${description}") != -1) {
if (nequal(at->description(), description)) {
at->set_Description(description);
container->set_updated();
}
}
else if (nequal(at->description(), Lex::simplify_comment(comment))) {
at->set_Description(comment); // comment was set
container->set_updated();
}
if (at->isReadOnly() != finalp) {
at->set_isReadOnly(finalp);
container->set_updated();
}
if (at->isJavaTransient() != transientp) {
at->set_isJavaTransient(transientp);
container->set_updated();
}
//.........这里部分代码省略.........
开发者ID:ErickCastellanos,项目名称:douml,代码行数:101,代码来源:UmlAttribute.cpp
示例15: side
void UmlRelation::write_relation_as_attribute(FileOut & out) {
UmlRelation * first = side(TRUE);
Q3CString s;
UmlClass * base;
if ((first->parent()->stereotype() == "stereotype") &&
(first->roleType()->stereotype() == "metaclass")) {
if (this != first)
return;
base = first->roleType();
s = "base_" + base->name();
}
else {
base = 0;
switch (_lang) {
case Uml:
s = roleName();
break;
case Cpp:
if (cppDecl().isEmpty())
return;
s = true_name(roleName(), cppDecl());
break;
default: // Java
if (javaDecl().isEmpty())
return;
s = true_name(roleName(), javaDecl());
}
}
out.indent();
out << "<ownedAttribute xmi:type=\"uml:Property\" name=\"" << s << '"';
out.id(this);
if (base != 0)
out.ref(first, "association", "EXT_");
else {
write_visibility(out);
write_scope(out);
if (isReadOnly())
out << " isReadOnly=\"true\"";
if (isDerived()) {
out << " isDerived=\"true\"";
if (isDerivedUnion())
out << " isDerivedUnion=\"true\"";
}
if (isOrdered())
out << " isOrdered=\"true\"";
if (isUnique())
out << " isUnique=\"true\"";
if (first->_assoc_class != 0)
out.ref(first->_assoc_class, "association");
else
out.ref(first, "association", "ASSOC_");
out << " aggregation=\"";
if (this == first) {
parent()->memo_relation(this);
if (_gen_eclipse) {
switch (relationKind()) {
case anAggregation:
case aDirectionalAggregation:
out << "shared";
break;
case anAggregationByValue:
case aDirectionalAggregationByValue:
out << "composite";
break;
default:
out << "none";
}
}
else
out << "none";
}
else if (_gen_eclipse)
out << "none";
else {
switch (relationKind()) {
case anAggregation:
case aDirectionalAggregation:
out << "shared";
break;
case anAggregationByValue:
case aDirectionalAggregationByValue:
out << "composite";
break;
default:
out << "none";
}
}
out << '"';
}
out << ">\n";
out.indent(+1);
//.........这里部分代码省略.........
开发者ID:SciBoy,项目名称:douml,代码行数:101,代码来源:UmlRelation.cpp
示例16: if
void CppRefType::compute(Q3PtrList<CppRefType> & dependencies,
const WrapperStr & hdef, const WrapperStr & srcdef,
WrapperStr & h_incl, WrapperStr & decl, WrapperStr & src_incl,
UmlArtifact * who)
{
UmlPackage * pack = who->package();
WrapperStr hdir;
WrapperStr srcdir;
if (CppSettings::isRelativePath()) {
WrapperStr empty;
hdir = pack->header_path(empty);
srcdir = pack->source_path(empty);
}
else if (CppSettings::isRootRelativePath())
hdir = srcdir = UmlPackage::rootDir();
// aze.cpp includes aze.h
src_incl += "#include \"";
if (CppSettings::includeWithPath())
src_incl += pack->header_path(who->name(), srcdir);
else {
src_incl += who->name();
src_incl += '.';
src_incl += CppSettings::headerExtension();
}
src_incl += "\"\n";
h_incl = ""; // to not be WrapperStr::null
decl = ""; // to not be WrapperStr::null
CppRefType * ref;
for (ref = dependencies.first(); ref != 0; ref = dependencies.next())
{
UmlClass * cl = (ref->type.type)
? ref->type.type
: UmlBaseClass::get(ref->type.explicit_type, 0);
bool included = ref->included;
WrapperStr hform; // form in header
WrapperStr srcform; // form in source
if (cl == 0) {
WrapperStr in = CppSettings::include(ref->type.explicit_type);
if (!in.isEmpty())
hform = srcform = in + '\n';
else
// doesn't know what it is
continue;
}
else if (cl->isCppExternal())
{
QString className = cl->name();
hform = cl->cppDecl();
int index;
if ((index = hform.find('\n')) == -1)
// wrong form
continue;
hform = hform.mid(index + 1) + '\n';
for (;;) {
if ((index = hform.find("${name}")) != -1)
hform.replace(index, 7, cl->name());
else if ((index = hform.find("${Name}")) != -1)
hform.replace(index, 7, capitalize(cl->name()));
else if ((index = hform.find("${NAME}")) != -1)
hform.replace(index, 7, cl->name().upper());
else if ((index = hform.find("${nAME}")) != -1)
hform.replace(index, 7, cl->name().lower());
else
break;
}
srcform = hform;
}
else {
QString className = cl->name();
WrapperStr st = cl->cpp_stereotype();
if ((st == "enum") || (st == "typedef"))
included = TRUE;
UmlArtifact * art = cl->associatedArtifact();
if (art != 0) {
if (art == who)
// don't include itself
continue;
if (CppSettings::includeWithPath()) {
UmlPackage * p = art->package();
hform = "#include \"" + p->header_path(art->name(), hdir) + "\"\n";
//.........这里部分代码省略.........
开发者ID:lollisoft,项目名称:douml,代码行数:101,代码来源:CppRefType.cpp
示例17: switch
void UmlClass::importRelations(File & f) {
Q3CString s;
f.read("(");
f.read("list");
if (f.read(s) != ATOM)
f.syntaxError(s, "an atom");
for (;;) {
switch (f.read(s)) {
case ')':
return;
case '(':
break;
default:
f.syntaxError(s);
}
f.read("object");
if (f.read(s) != ATOM)
f.syntaxError(s, "an atom");
aRelationKind rk;
Q3CString sr;
if (s == "Uses_Relationship") {
rk = aDependency;
sr = "dependency";
}
else if (s == "Inheritance_Relationship") {
rk = aGeneralisation;
sr = "generalisation";
}
else if (s == "Realize_Relationship") {
rk = aRealization;
sr = "realization";
}
else {
f.skipBlock();
continue;
}
// dependency or generalisation
Q3CString id;
Q3CString ste;
Q3CString doc;
Q3Dict<Q3CString> prop;
Q3CString s2;
int k;
do {
k = f.readDefinitionBeginning(s2, id, ste, doc, prop);
} while (id.isEmpty());
Q3CString target_id;
aVisibility visibility = PublicVisibility;
bool virtual_inheritance = FALSE;
bool a_friend = FALSE;
for (;;) {
if (k == ATOM) {
if (s2 == "quidu") {
if (f.read(target_id) != STRING)
f.syntaxError(target_id, "quidu value");
}
else if (s2 == "exportControl")
visibility = f.readVisibility();
else if (s2 == "virtual")
virtual_inheritance = f.readBool();
else if (s2 == "friend")
a_friend = f.readBool();
else
f.skipNextForm();
k = f.read(s2);
}
else if (k == ')')
break;
else
f.syntaxError(s2);
}
if (target_id.isEmpty())
f.syntaxError("quidu missing");
UmlClass * target = (UmlClass *) findItem(target_id, aClass);
if (target != 0) {
UmlRelation * r;
if (a_friend) {
if ((r = UmlRelation::create(rk, target, this)) == 0) {
UmlCom::trace("<br>cannot create " + sr + " from '" +
target->fullName() + "' to '" + fullName() + "'");
f.skipBlock();
return;
}
r->set_Stereotype("friend");
}
else {
//.........这里部分代码省略.........
开发者ID:SciBoy,项目名称:douml,代码行数:101,代码来源:UmlClass.cpp
示例18: parent
void UmlRelation::generate_def(QTextStream & f, WrapperStr indent, bool h,
WrapperStr templates, WrapperStr cl_names,
WrapperStr, WrapperStr)
{
if (isClassMember() && !cppDecl().isEmpty()) {
UmlClass * cl = (UmlClass *) parent();
if ((!templates.isEmpty() || (cl->name().find('<') != -1))
? h : !h) {
const char * p = cppDecl();
const char * pp = 0;
while ((*p == ' ') || (*p == '\t'))
p += 1;
bool re_template = !templates.isEmpty() &&
insert_template(p, f, indent, templates);
if (*p != '#')
f << indent;
const char * pname = name_spec(p);
for (;;) {
if (*p == 0) {
if (pp == 0)
break;
// comment management done
p = pp;
pp = 0;
if (re_template)
f << templates;
if (*p == 0)
break;
if (*p != '#')
f << indent;
}
if (*p == '\n') {
f << toLocale(p);
if (*p && (*p != '#'))
f << indent;
}
else if (*p == '@')
manage_alias(p, f);
else if (*p != '$') {
if (p == pname)
f << cl_names << "::";
f << toLocale(p);
}
else if (!strncmp(p, "${comment}", 10)) {
if (!manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment())
&& re_template)
f << templates;
}
else if (!strncmp(p, "${description}", 14)) {
if (!manage_description(p, pp) && re_template)
f << templates;
}
else if (!strncmp(p, "${static}", 9)) {
p += 9;
}
else if (!strncmp(p, "${const}", 8)) {
p += 8;
if (isReadOnly())
f << "const ";
}
else if (!strncmp(p, "${volatile}", 11)) {
p += 11;
if (isVolatile())
f << "volatile ";
}
else if (!strncmp(p, "${mutable}", 10)) {
p += 10;
}
else if (!strncmp(p, "${type}", 7)) {
p += 7;
roleType()->write(f);
}
else if (!strncmp(p, "${name}", 7)) {
p += 7;
if (*pname == '$')
f << cl_names << "::";
f << roleName();
}
else if (!strncmp(p, "${inverse_name}", 15)) {
p += 15;
switch (relationKind()) {
case anAssociation:
//.........这里部分代码省略.........
开发者ID:harmegnies,项目名称:douml,代码行数:101,代码来源:UmlRelation.cpp
示例19: new_one
bool UmlRelation::new_one(Class * container, const Q3CString & name,
UmlClass * dest, const Q3CString & modifier,
const Q3CString & pretype, const Q3CString & array,
const Q3CString & typeform, aVisibility visibility,
bool staticp, bool constp, bool mutablep, bool volatilep,
const Q3CString & value, Q3CString comment,
Q3CString description
#ifdef ROUNDTRIP
, bool roundtrip, Q3PtrList<UmlItem> & expected_order
#endif
)
{
#ifdef DEBUG_BOUML
cout << "RELATION '" << name << "' from '" << cl->name() << "' to '" << dest->name()
<< "' modifier '" << modifier << "' array '" << array
<< "' typeform '" << typeform << "'\n";
#endif
if (
#ifdef REVERSE
container->from_libp() &&
#endif
(visibility == PrivateVisibility)) {
Lex::finish_line();
Lex::clear_comments();
return TRUE;
}
UmlClass * cl = container->get_uml();
UmlRelation * rel;
#ifdef ROUNDTRIP
if (roundtrip &&
((rel = search_rel(container, name, dest, "")) != 0)) {
rel->set_usefull();
expected_order.append(rel);
}
else {
#endif
rel = UmlBaseRelation::create((modifier.isEmpty() &&
((typeform == "${type}") ||
(typeform[typeform.find("${type}") + 7] != '*')))
? aDirectionalAggregationByValue
: aDirectionalAssociation,
cl, dest);
if (rel == 0) {
UmlCom::trace(Q3CString("<font face=helvetica><b>cannot add relation <i>")
+ name + "</i> in <i>" + cl->name() + "</i> to <i>"
+ dest->name() + "</i></b></font><br><hr>");
return FALSE;
}
#ifdef REVERSE
# ifndef ROUNDTRIP
Statistic::one_relation_more();
# else
if (roundtrip) {
expected_order.append(rel);
container->set_updated();
roundtrip = FALSE;
}
}
# endif
#endif
Lex::finish_line();
comment = Lex::get_comments(comment);
description = Lex::get_description(description);
#ifdef ROUNDTRIP
if (roundtrip) {
if (rel->visibility() != visibility) {
rel->set_Visibility(visibility);
container->set_updated();
}
if (rel->isReadOnly() != constp) {
rel->set_isReadOnly(constp);
container->set_updated();
}
if (rel->isClassMember() != staticp) {
rel->set_isClassMember(staticp);
container->set_updated();
}
if (rel->isCppMutable() != mutablep) {
rel->set_isCppMutable(mutablep);
container->set_updated();
}
if (rel->isVolatile() != volatilep) {
rel->set_isVolatile(volatilep);
container->set_updated();
}
}
else {
#endif
//.........这里部分代码省略.........
开发者ID:SciBoy,< |
请发表评论