Beispiel #1
0
void UmlRelation::generate(QTextOStream & f, const Q3CString & cl_stereotype,
                           Q3CString indent) {
    switch (relationKind()) {
    case aDependency:
    case aGeneralisation:
    case aRealization:
        break;
    default:
        if (!javaDecl().isEmpty()) {
            if (cl_stereotype == "enum_pattern") {
                write_trace_header();
                UmlCom::trace("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b>an <i>enum_pattern</i> cannot have relation</b></font><br>");
                incr_warning();
                return;
            }

            const char * p = javaDecl();
            const char * pp = 0;
            Q3CString s;

            while ((*p == ' ') || (*p == '\t'))
                indent += *p++;

            f << indent;

            for (;;) {
                if (*p == 0) {
                    if (pp == 0)
                        break;

                    // comment management done
                    p = pp;
                    pp = 0;
                    if (*p == 0)
                        break;
                    f << indent;
                }

                if (*p == '\n') {
                    f << *p++;
                    if (*p)
                        f << indent;
                }
                else if (*p == '@')
                    manage_alias(p, f);
                else if (*p != '$')
                    f << *p++;
                else if (!strncmp(p, "${comment}", 10))
                    manage_comment(p, pp, JavaSettings::isGenerateJavadocStyleComment());
                else if (!strncmp(p, "${description}", 14))
                    manage_description(p, pp);
                else if (!strncmp(p, "${visibility}", 13)) {
                    p += 13;
                    generate_visibility(f, cl_stereotype);
                }
                else if (!strncmp(p, "${static}", 9)) {
                    p += 9;
                    if (isClassMember())
                        f << "static ";
                }
                else if (!strncmp(p, "${final}", 8)) {
                    p += 8;
                    if (isReadOnly())
                        f << "final ";
                }
                else if (!strncmp(p, "${transient}", 12)) {
                    p += 12;
                    if (isJavaTransient())
                        f << "transient ";
                }
                else if (!strncmp(p, "${volatile}", 11)) {
                    p += 11;
                    if (isVolatile())
                        f << "volatile ";
                }
                else if (!strncmp(p, "${type}", 7)) {
                    p += 7;
                    roleType()->write(f);
                }
                else if (!strncmp(p, "${stereotype}", 13)) {
                    p += 13;
                    f << JavaSettings::relationAttributeStereotype(stereotype());
                }
                else if (!strncmp(p, "${name}", 7)) {
                    p += 7;
                    f << roleName();
                }
                else if (!strncmp(p, "${inverse_name}", 15)) {
                    p += 15;
                    switch (relationKind()) {
                    case anAssociation:
                    case anAggregation:
                    case anAggregationByValue:
                        f << side(side(TRUE) != this)->roleName();
                    default:
                        break;
                    }
                }
                else if (!strncmp(p, "${multiplicity}", 15)) {
                    p += 15;

                    Q3CString m = multiplicity();

                    if (*m != '[')
                        f << "[]";
                    else {
                        for (unsigned index = 0; index != m.length(); index += 1) {
                            switch (m.at(index)) {
                            case '[':
                                f << '[';
                                break;
                            case ']':
                                f << ']';
                            default:
                                break;
                            }
                        }
                    }
                }
                else if (!strncmp(p, "${value}", 8)) {
                    if (!defaultValue().isEmpty()) {
                        if (need_equal(p, defaultValue()))
                            f << " = ";
                        f << defaultValue();
                    }
                    p += 8;
                }
                else if (!strncmp(p, "${association}", 14)) {
                    p += 14;
                    UmlClass::write(f, association());
                }
                else if (!strncmp(p, "${@}", 4)) {
                    p += 4;
                    if (pp != 0)
                        f << "${@}";
                    else if (! javaAnnotations().isEmpty()) {
                        pp =p;
                        p = javaAnnotations();
                    }
                }
                else
                    // strange
                    f << *p++;
            }

            f << '\n';
        }
    }
}
void UmlAttribute::generate(QTextStream & f, const WrapperStr & st,
                            WrapperStr indent, int & enum_item_rank)
{
    if (!phpDecl().isEmpty()) {
        const char * p = phpDecl();
        const char * pp = 0;

        while ((*p == ' ') || (*p == '\t'))
            indent += *p++;

        f << indent;

        for (;;) {
            if (*p == 0) {
                if (pp == 0)
                    break;

                // comment management done
                p = pp;
                pp = 0;

                if (*p == 0)
                    break;

                f << indent;
            }

            if (*p == '\n') {
                f << *p++;

                if (*p)
                    f << indent;
            }
            else if (*p == '@')
                manage_alias(p, f);
            else if (*p != '$')
                f << *p++;
            else if (!strncmp(p, "${comment}", 10))
                manage_comment(p, pp, PhpSettings::isGenerateJavadocStyleComment());
            else if (!strncmp(p, "${description}", 14))
                manage_description(p, pp);
            else if (!strncmp(p, "${visibility}", 13)) {
                p += 13;
                generate_visibility(f);
            }
            else if (!strncmp(p, "${static}", 9)) {
                p += 9;

                if (isClassMember())
                    f << "static ";
            }
            else if (!strncmp(p, "${type}", 7)) {
                p += 7;
                UmlClass::write(f, type());
            }
            else if (!strncmp(p, "${name}", 7)) {
                p += 7;

                if ((st != "enum") && !isReadOnly())
                    f << "$";

                f << name();
            }
            else if (!strncmp(p, "${var}", 6)) {
                p += 6;

                if ((st != "enum") &&
                    !isReadOnly() &&
                    !isClassMember() &&
                    (visibility() == PackageVisibility))
                    f << "var ";
            }
            else if (!strncmp(p, "${value}", 8)) {
                if (!defaultValue().isEmpty()) {
                    if (need_equal(p, defaultValue()))
                        f << " = ";

                    f << defaultValue();
                }
                else if (st == "enum")
                    f << " = " << enum_item_rank;

                p += 8;
            }
            else if (!strncmp(p, "${const}", 8)) {
                p += 8;

                if (isReadOnly())
                    f << "const ";
            }
            else
                f << *p++;
        }

        f << '\n';
    }

    enum_item_rank += 1;
}
Beispiel #3
0
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:
                    case anAggregation:
                    case anAggregationByValue:
                        f << 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 << 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, "${association}", 14)) {
                    p += 14;
                    UmlClass::write(f, association());
                }
                else
                    // strange
                    f << toLocale(p);
            }

            f << '\n';
        }
    }
}
Beispiel #4
0
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("&nbsp;&nbsp;&nbsp;&nbsp;<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("&nbsp;&nbsp;&nbsp;&nbsp;<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';
        }
    }
}
Beispiel #5
0
void UmlRelation::generate(QTextStream & f, const Q3CString &,
                           Q3CString indent, int &) {
    switch (relationKind()) {
    case aDependency:
    case aGeneralisation:
    case aRealization:
        break;
    default:
        if (!phpDecl().isEmpty()) {
            const char * p = phpDecl();
            const char * pp = 0;
            Q3CString s;

            while ((*p == ' ') || (*p == '\t'))
                indent += *p++;

            f << indent;

            for (;;) {
                if (*p == 0) {
                    if (pp == 0)
                        break;

                    // comment management done
                    p = pp;
                    pp = 0;
                    if (*p == 0)
                        break;
                    f << indent;
                }

                if (*p == '\n') {
                    f << *p++;
                    if (*p)
                        f << indent;
                }
                else if (*p == '@')
                    manage_alias(p, f);
                else if (*p != '$')
                    f << *p++;
                else if (!strncmp(p, "${comment}", 10))
                    manage_comment(p, pp, PhpSettings::isGenerateJavadocStyleComment());
                else if (!strncmp(p, "${description}", 14))
                    manage_description(p, pp);
                else if (!strncmp(p, "${visibility}", 13)) {
                    p += 13;
                    generate_visibility(f);
                }
                else if (!strncmp(p, "${static}", 9)) {
                    p += 9;
                    if (isClassMember())
                        f << "static ";
                }
                else if (!strncmp(p, "${type}", 7)) {
                    p += 7;
                    roleType()->write(f);
                }
                else if (!strncmp(p, "${name}", 7)) {
                    p += 7;
                    if (!isReadOnly())
                        f << "$";
                    f << roleName();
                }
                else if (!strncmp(p, "${inverse_name}", 15)) {
                    p += 15;
                    switch (relationKind()) {
                    case anAssociation:
                    case anAggregation:
                    case anAggregationByValue:
                    {
                        UmlRelation * inverse = side(side(TRUE) != this);

                        if (!inverse->isReadOnly())
                            f << "$";
                        f << inverse->roleName();
                    }
                    default:
                        break;
                    }
                }
                else if (!strncmp(p, "${var}", 6)) {
                    p += 6;
                    if (!isReadOnly() &&
                            !isClassMember() &&
                            (visibility() == PackageVisibility))
                        f << "var ";
                }
                else if (!strncmp(p, "${value}", 8)) {
                    if (!defaultValue().isEmpty()) {
                        if (need_equal(p, defaultValue()))
                            f << " = ";
                        f << defaultValue();
                    }
                    p += 8;
                }
                else if (!strncmp(p, "${const}", 8)) {
                    p += 8;
                    if (isReadOnly())
                        f << "const ";
                }
                else
                    f << *p++;
            }

            f << '\n';
        }
    }
}
Beispiel #6
0
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("&nbsp;&nbsp;&nbsp;&nbsp;<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';
}
Beispiel #7
0
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;
	  if (isVolatile())
	    f << "volatile ";
	}
	else if (!strncmp(p, "${mutable}", 10)) {
	  p += 10;
	}
	else if (!strncmp(p, "${type}", 7)) {
	  p += 7;
	  UmlClass::write(f, type());
	  //f << CppSettings::Type(Type().Type());
	}
	else
	  // strange
	  f << *p++;
      }
      
      f << '\n';
    }
  }
}