void UmlExtraClassMember::generate_def(QTextStream & f, Q3CString indent, bool h, Q3CString templates, Q3CString, Q3CString, Q3CString) { if (!cppDef().isEmpty() && ((isCppInline() || !templates.isEmpty()) == h)) { const char * p = cppDef(); if (*p != '#') f << indent; f << p; } }
void UmlOperation::change(Context & ctx) { if (ctx.onOperation() && ctx.match_stereotype(stereotype())) { if (ctx.cpp()) { const Q3CString & c = cppDecl(); if (!c.isEmpty() && ctx.match(c)) { if (!set_CppDecl(ctx.replace(c))) ctx.err(); } const Q3CString & f = cppDef(); if (!f.isEmpty() && ctx.match(f)) { if (!set_CppDef(ctx.replace(f))) ctx.err(); } } if (ctx.java()) { const Q3CString & c = javaDecl(); if (!c.isEmpty() && ctx.match(c)) { if (!set_JavaDecl(ctx.replace(c))) ctx.err(); } } if (ctx.php()) { const Q3CString & c = phpDecl(); if (!c.isEmpty() && ctx.match(c)) { if (!set_PhpDecl(ctx.replace(c))) ctx.err(); } } if (ctx.python()) { const Q3CString & c = pythonDecl(); if (!c.isEmpty() && ctx.match(c)) { if (!set_PythonDecl(ctx.replace(c))) ctx.err(); } } if (ctx.idl()) { const Q3CString & c = idlDecl(); if (!c.isEmpty() && ctx.match(c)) { if (!set_IdlDecl(ctx.replace(c))) ctx.err(); } } } }
void UmlOperation::defaultDef() { if (cppDecl().isEmpty()) set_CppDecl(CppSettings::operationDecl()); if (isAbstract()) set_CppDef(""); else if (cppDef().isEmpty()) set_CppDef(CppSettings::operationDef()); setUsed(); }
void UmlOperation::setParams(const char * s) { QByteArray d; int index; d = cppDecl(); if (((index = d.indexOf("${(}")) != -1) && (d.mid(index + 4, 4) == "${)}")) { d.insert(d.indexOf("${(}") + 4, s); set_CppDecl(d); } d = cppDef(); if (((index = d.indexOf("${(}")) != -1) && (d.mid(index + 4, 4) == "${)}")) { d.insert(d.indexOf("${(}") + 4, s); set_CppDef(d); } }
void UmlOperation::rename_jdk5() { QCString s; bool changed = FALSE; bool javasettings = (parent()->name() == "JavaSettings"); s = cppDecl(); if (rename(s, FALSE, javasettings)) { changed = TRUE; set_CppDecl(s); } s = cppDef(); if (rename(s, FALSE, javasettings)) { changed = TRUE; set_CppDef(s); } s = cppBody(); if (rename(s, FALSE, javasettings)) { changed = TRUE; set_CppBody(s); } s = javaDef(); if (rename(s, TRUE, javasettings)) { changed = TRUE; set_JavaDef(s); } s = javaBody(); if (rename(s, TRUE, javasettings)) { changed = TRUE; set_JavaBody(s); } if (changed) UmlCom::trace(parent()->name() + "::" + name() + " upgraded to take into account the rename of 'enum' to 'enum pattern'<br>\n"); }
void UmlOperation::setType(UmlClass * type, const char * s) { UmlTypeSpec t; t.type = type; set_ReturnType(t); static const QByteArray sep = " \t\n\r"; QByteArray d; int typeindex; int nameindex; d = cppDecl(); if (((typeindex = d.indexOf("${type}")) != -1) && ((nameindex = d.indexOf("${name}", typeindex + 7)) != -1)) { while (sep.indexOf(d[nameindex - 1]) != -1) nameindex -= 1; d.replace(typeindex, nameindex - typeindex, s); set_CppDecl(d); } if (! isAbstract()) { d = cppDef(); if (((typeindex = d.indexOf("${type}")) != -1) && ((nameindex = d.indexOf("${class}", typeindex + 7)) != -1)) { while (sep.indexOf(d[nameindex - 1]) != -1) nameindex -= 1; d.replace(typeindex, nameindex - typeindex, s); set_CppDef(d); } } }
bool UmlExtraClassMember::need_source() { return !cppDef().isEmpty(); }
void UmlOperation::importParameters(File & f) { QByteArray s; unsigned rank = 0; const char * sep = ""; QByteArray doc = description(); for (;;) { switch (f.read(s)) { case ')': if (doc != description()) set_Description(doc); return; case '(': // a parameter break; default: f.syntaxError(s); } f.read("object"); f.read("Parameter"); UmlParameter p; QByteArray ti; ti = QString("${t%1}").arg(rank).toLatin1(); if (f.read(p.name) != STRING) f.syntaxError(s, "parameter's name"); QByteArray id; QByteArray ste; QByteArray p_doc; QHash<QByteArray, QByteArray*> prop; int k; for (;;) { k = f.readDefinitionBeginning(s, id, ste, p_doc, prop); if (k == ')') break; if (s == "type") { if (f.read(s) != STRING) f.syntaxError(s, "parameter type"); switch (((UmlClass *) parent())->language()) { case Corba: if (strncmp(s, "in ", 3) == 0) { p.dir = InputDirection; s = s.mid(3); } else if (strncmp(s, "out ", 4) == 0) { p.dir = OutputDirection; s = s.mid(4); } else if (strncmp(s, "inout ", 6) == 0) { p.dir = InputOutputDirection; s = s.mid(6); } else { QByteArray err = "<br>'" + s + "' : wrong parameter direction, in " + f.context(); UmlCom::trace(err); p.dir = InputOutputDirection; } break; default: // !!!!!!!!!!!!! p.dir = InputOutputDirection; } p.type.explicit_type = s; } else if (s == "quidu") { if (f.read(s) != STRING) f.syntaxError(s, "wrong quidu"); if (UmlClass::replaceType(p.type, s, ti)) ti = s; } else f.skipNextForm(); } QByteArray d; int index; switch (((UmlClass *) parent())->language()) { case Cplusplus: case AnsiCplusplus: case VCplusplus: s= QString("%1%2 ${p%3}").arg(sep).arg((const char *) ti).arg(rank).toLatin1(); if ((index = (d = cppDecl()).indexOf("${)}")) != -1) //set_CppDecl(d.insert(index, s));//[jasa] original line set_CppDecl(d.insert(index, (const char *)s)); //[jasa] fix ambiguous call if ((index = (d = cppDef()).indexOf("${)}")) != -1) set_CppDef(d.insert(index, (const char *)s)); //[jasa] fix ambiguous call break; case Oracle8: break; case Corba: if ((index = (d = idlDecl()).indexOf("${)}")) != -1) { s = QString("%1${d%2} %3 ${p%4}").arg( sep).arg(rank).arg((const char *) ti).arg(rank).toLatin1(); set_IdlDecl(d.insert(index, (const char *)s)); //[jasa] fix ambiguous call } break; case Java: if ((index = (d = javaDecl()).indexOf("${)}")) != -1) { s = QString("%s%s ${p%u}").arg( sep).arg( (const char *) ti).arg( rank).toLatin1(); set_JavaDecl(d.insert(index, (const char *)s)); //[jasa] } break; default: break; } addParameter(rank++, p); sep = ", "; } }
void UmlOperation::import(File & f) { if (scanning) { f.skipBlock(); return; } QByteArray s; UmlTypeSpec t; for (;;) { switch (f.read(s)) { case -1: f.eof(); throw 0; case ')': set_ReturnType(t); return; case ATOM: break; default: f.syntaxError(s); } // atom if (s == "parameters") { f.read("("); f.read("list"); f.read("Parameters"); importParameters(f); } else if (s == "result") { if (f.read(s) != STRING) f.syntaxError(s, "return type"); t.explicit_type = s; } else if (s == "quidu") { if (f.read(s) != STRING) f.syntaxError(s, "wrong quidu"); if (UmlClass::replaceType(t, s, "${type}")) { switch (((UmlClass *) parent())->language()) { case Cplusplus: case AnsiCplusplus: case VCplusplus: set_CppDecl(replace(cppDecl(), "${type}", s)); set_CppDef(replace(cppDef(), "${type}", s)); break; case Oracle8: break; case Corba: set_IdlDecl(replace(idlDecl(), "${type}", s)); break; case Java: set_JavaDecl(replace(javaDecl(), "${type}", s)); break; default: break; } } } else if (s == "exceptions") importExceptions(f); else if (s == "opExportControl") set_Visibility(f.readVisibility()); else f.skipNextForm(); } }