void UmlClass::addCopy(bool cte) { TRACE_FUNCTION; UmlOperation * op = UmlOperation::create(this, name()); if (op == 0) UmlCom::trace("can't add copy contructor"); else { // to see that it is a copy constructor op->set_Stereotype("copy"); // add 'source' parameter UmlParameter param; param.name = "source"; param.dir = (cte) ? InputDirection : InputOutputDirection; param.type.type = this; op->addParameter(0, param); // add the parameter profile, and // remove the useless "${type} " mainly to remove the space QByteArray p = (cte) ? "const ${t0} & ${p0}" : "${t0} & ${p0}"; QByteArray s; int index; s = op->cppDecl(); if (s.isEmpty()) s = CppSettings::operationDecl(); if ((index = s.indexOf("${(}")) != -1) s.insert(index + 4, (const char *)p); //[rageek] cast because QByteArray if ((index = s.indexOf("${type} ")) != -1) s.remove(index, 8); op->set_CppDecl(s); s = op->cppDef(); if (s.isEmpty()) s = CppSettings::operationDef(); if ((index = s.indexOf("${(}")) != -1) s.insert(index + 4, (const char *)p); //[rageek] cast because QByteArray if ((index = s.indexOf("${type} ")) != -1) s.remove(index, 8); op->set_CppDef(s); } }
void UmlOperation::import(File & f, UmlClass * parent) { QByteArray s; if (f.read(s) != STRING) f.syntaxError(s, "operations's name"); QByteArray id; QByteArray ste; QByteArray doc; QHash<QByteArray, QByteArray*> prop; QByteArray s2; int k; do { k = f.readDefinitionBeginning(s2, id, ste, doc, prop); } while (id.isEmpty()); UmlOperation * x; if (scanning) { QByteArray name; if (s.left(8) != "operator") name = (s.at(0) == '~') ? ("~" + legalName(s.mid(1))) : legalName(s); else name = s; if ((x = UmlBaseOperation::create(parent, name)) == 0) { UmlCom::trace("<br>cannot create operation '" + s + "' in " + parent->fullName()); throw 0; } newItem(x, id); if (!ste.isEmpty()) { bool managed = FALSE; QStringList l = QString(ste).split(","); for (QStringList::Iterator it = l.begin(); it != l.end(); ++it) { if ((*it) == "const") { managed = TRUE; x->set_isCppConst(TRUE); } else if ((*it) == "abstract") { managed = TRUE; x->set_isAbstract(TRUE); x->set_isCppVirtual(TRUE); } else if ((*it) == "virtual") { managed = TRUE; x->set_isCppVirtual(TRUE); } else if ((*it) == "static") { managed = TRUE; x->set_isClassMember(TRUE); } } if (!managed) x->set_Stereotype(ste); } if (!doc.isEmpty()) x->set_Description(doc); } else if ((x = (UmlOperation *) findItem(id, anOperation)) == 0) { UmlCom::trace("<br>unknown operation '" + s + "' in " + parent->fullName()); throw 0; } else { switch (((UmlClass *) x->parent())->language()) { case Cplusplus: case AnsiCplusplus: case VCplusplus: x->cplusplus(prop); break; case Oracle8: x->oracle8(prop); break; case Corba: x->corba(prop); break; case Java: x->java(prop); break; default: break; } x->setProperties(prop); } f.unread(k, s2); x->import(f); }