void UmlAttribute::write_cpp_type(FileOut & out) { // note : doesn't manage function/operation pointer Q3CString s = cppDecl(); int index; remove_comments(s); // remove keywords not linked to the type if ((index = s.find("${static}")) != -1) s.replace(index, 9, " "); if ((index = s.find("${mutable}")) != -1) s.replace(index, 10, (isCppMutable()) ? "mutable " : ""); if ((index = s.find("${volatile}")) != -1) s.replace(index, 11, (isVolatile()) ? "volatile " : ""); if ((index = s.find("${value}")) != -1) s.replace(index, 8, " "); if ((index = s.find("${h_value}")) != -1) s.replace(index, 10, " "); // replace keywords linked to the type if ((index = s.find("${const}")) != -1) s.replace(index, 8, isReadOnly() ? "const" : ""); UmlTypeSpec t = type(); if (t.type == 0) t.explicit_type = CppSettings::type(t.explicit_type); write_type(out, t, s, "${name}", "${type}"); }
void UmlRelation::generate_decl(aVisibility & current_visibility, QTextStream & f_h, const WrapperStr & cl_stereotype, WrapperStr indent, BooL & first, bool) { switch (relationKind()) { case aDependency: if (stereotype() == "friend") { Q3ValueList<UmlFormalParameter> formals = roleType()->formals(); if (! formals.isEmpty()) { const char * sep = " template <"; Q3ValueList<UmlFormalParameter>::ConstIterator it; for (it = formals.begin(); it != formals.end(); ++it) { f_h << sep << (*it).type() << ' ' << (*it).name(); sep = ", "; } f_h << "> "; } else f_h << " "; f_h << "friend " << roleType()->cpp_stereotype() << " "; roleType()->write(f_h, FALSE); f_h << ";\n"; first = FALSE; } break; case aGeneralisation: case aRealization: break; default: if (!cppDecl().isEmpty()) { if (cl_stereotype == "enum") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>an <i>enum</i> cannot have relation</b></font><br>"); incr_warning(); return; } if (cl_stereotype == "typedef") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>a <i>typedef</i> cannot have relation</b></font><br>"); incr_warning(); return; } generate_visibility(current_visibility, f_h, first, indent); first = FALSE; const char * p = cppDecl(); const char * pp = 0; WrapperStr s; while ((*p == ' ') || (*p == '\t')) indent += toLocale(p); if (*p != '#') f_h << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; if (*p != '#') f_h << indent; } if (*p == '\n') { f_h << toLocale(p); if (*p && (*p != '#')) f_h << indent; } else if (*p == '@') manage_alias(p, f_h); else if (*p != '$') f_h << toLocale(p); else if (!strncmp(p, "${comment}", 10)) manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) f_h << "static "; } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) f_h << "const "; } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) f_h << "volatile "; } else if (!strncmp(p, "${mutable}", 10)) { p += 10; if (isCppMutable()) f_h << "mutable "; } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(f_h); } else if (!strncmp(p, "${name}", 7)) { p += 7; f_h << roleName(); } else if (!strncmp(p, "${inverse_name}", 15)) { p += 15; switch (relationKind()) { case anAssociation: case anAggregation: case anAggregationByValue: f_h << side(side(TRUE) != this)->roleName(); default: break; } } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; const WrapperStr & m = multiplicity(); if (!m.isEmpty() && (*((const char *) m) == '[')) f_h << m; else f_h << '[' << m << ']'; } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f_h << CppSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${value}", 8)) p += 8; else if (!strncmp(p, "${h_value}", 10)) { if (!defaultValue().isEmpty() && isClassMember()) { if (need_equal(p, defaultValue())) f_h << " = "; f_h << defaultValue(); } p += 10; } else if (!strncmp(p, "${association}", 14)) { p += 14; UmlClass::write(f_h, association()); } else // strange f_h << toLocale(p); } f_h << '\n'; } } }
void UmlRelation::gen_cpp_decl(QByteArray s, bool descr) { const char * p; if (! descr) { write((cppVisibility() == DefaultVisibility) ? visibility() : cppVisibility(), cppLanguage); fw.write(": "); p = bypass_comment(s); } else p = s; while (*p) { if (!strncmp(p, "${comment}", 10)) p += 10; else if (!strncmp(p, "${description}", 14)) p += 14; else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) fw.write("static "); } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) fw.write("const "); } else if (!strncmp(p, "${mutable}", 10)) { p += 10; if (isCppMutable()) fw.write("mutable "); } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) fw.write("volatile "); } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(); } else if (!strncmp(p, "${name}", 7)) { p += 7; writeq(roleName()); } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; QByteArray m = multiplicity(); if (m.isEmpty() || (((const char *) m)[0] != '[')) { fw.write("["); writeq(m); fw.write("]"); } else writeq(m); } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; writeq(CppSettings::relationAttributeStereotype(stereotype())); } else if (!strncmp(p, "${value}", 8) || !strncmp(p, "${h_value}", 10)) { break; } else if (!strncmp(p, "${association}", 14)) { p += 14; write(association(), cppLanguage); } else if (*p == '\r') p += 1; else if (*p == '\n') { if (descr) { fw.write("<br />"); p += 1; } else { fw.write(' '); do p += 1; while ((*p != 0) && (*p <= ' ')); } } else if (*p == ';') { if (descr) fw.write(*p++); else break; } else if (*p == '@') manage_alias(p); else writeq(*p++); } }
void UmlAttribute::generate_decl(aVisibility & current_visibility, QTextOStream & f_h, const Q3CString & cl_stereotype, Q3CString indent, BooL & first, bool last) { if (cl_stereotype == "typedef") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>a <i>typedef</i> cannot have attribute</b></font><br>"); incr_warning(); return; } const char * p = cppDecl(); const char * pp = 0; bool in_enum = (cl_stereotype == "enum"); if (!in_enum) generate_visibility(current_visibility, f_h, first, indent); first = FALSE; while ((*p == ' ') || (*p == '\t')) indent += *p++; if (*p != '#') f_h << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; if (*p != '#') f_h << indent; } if (*p == '\n') { f_h << *p++; if (*p && (*p != '#')) f_h << indent; } else if (*p == '@') manage_alias(p, f_h); else if (*p != '$') f_h << *p++; else if (!strncmp(p, "${comment}", 10)) manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${name}", 7)) { p += 7; f_h << name(); } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; const Q3CString & m = multiplicity(); if (!m.isEmpty() && (*((const char *) m) == '[')) f_h << m; else f_h << '[' << m << ']'; } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f_h << CppSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${value}", 8) || !strncmp(p, "${h_value}", 10)) { const char * pb = p; p += (p[2] == 'h') ? 10 : 8; if (in_enum) { if (!defaultValue().isEmpty()) { if (need_equal(pb, defaultValue())) f_h << " = "; f_h << defaultValue(); } if (last) { if (*p == ',') p += 1; } else if (*p != ',') f_h << ','; } else if ((p[-8] == 'h') && isClassMember() && !defaultValue().isEmpty()) { if (need_equal(pb, defaultValue())) f_h << " = "; f_h << defaultValue(); } } else if (in_enum) // strange f_h << *p++; else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) f_h << "static "; } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) f_h << "const "; } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) f_h << "volatile "; } else if (!strncmp(p, "${mutable}", 10)) { p += 10; if (isCppMutable()) f_h << "mutable "; } else if (!strncmp(p, "${type}", 7)) { p += 7; UmlClass::write(f_h, type()); //f_h << CppSettings::Type(Type().Type()); } else // strange f_h << *p++; } f_h << '\n'; }