Beispiel #1
0
void UmlArtifact::roundtrip_java()
{
    if (! managed) {
        managed = TRUE;

        if (stereotype() != "source")
            return;

        const WrapperStr srcdef = javaSource();

        if (srcdef.isEmpty())
            return;

        const WrapperStr & name = UmlArtifact::name();
        UmlPackage * pack = package();
        WrapperStr src_path = pack->java_path(name);

        {
            WrapperStr s = " <i> " + src_path + "</i>";

            UmlCom::message(name);

            if (verbose())
                UmlCom::trace(WrapperStr("<hr><font face=helvetica>roundtrip body from")
                              + s + "</font><br>");
            else
                set_trace_header(WrapperStr("<font face=helvetica>roundtrip body from")
                                 + s + "</font><br>");
        }

        UmlOperation::roundtrip(src_path, javaLanguage);
    }
}
Beispiel #2
0
void UmlPackage::fileControl(bool ci) {
  UmlPackage * prj = getProject();
  Q3CString prjfile = prj->supportFile();
  BooL rec;
  BooL reload;
  Q3CString cmd;
  
  if (! prj->propertyValue((ci) ? "check-in-cmd" : "check-out-cmd", cmd))
    cmd = "specify the command containing %file and %dir or %dironly";
  
  Dialog dialog(ci, cmd, rec, reload);	// the dialog execution set 'cmd' and 'rec'
  
  if (dialog.exec() == QDialog::Accepted) {
    // save the command for a future usage
    prj->set_PropertyValue((ci) ? "check-in-cmd" : "check-out-cmd", cmd);
    
    if (reload)
      saveProject();
    
    // get files list
    Q3Dict<void> files;
  
    getFiles(files, (rec) ? ~0u : 1);
    if (this == prj)
      getAuxFiles(files);
  
    // apply the command on each file
    Q3DictIterator<void> it(files);
    QFileInfo prjpath(prjfile);
    QString dir = prjpath.dirPath(TRUE);
    QString dironly = dir;
    int index;
    
    if ((dironly.length() > 3) &&
        (((const char *) dironly)[1] == ':') &&
        (((const char *) dironly)[2] == '/'))
      dironly = dironly.mid(2);
  
    while ((index = cmd.find("%dironly")) != -1)
      cmd.replace(index, 8, dironly);
    
    while ((index = cmd.find("%dir")) != -1)
      cmd.replace(index, 4, dir);
      
    while (it.current()) {
      QString s = cmd;
  
      while ((index = s.find("%file")) != -1)
        s.replace(index, 5, it.currentKey());
      
      system((const char *) s);
      ++it;
    }
    
    UmlCom::trace("Done.");
  
    if (reload)
      loadProject(prjfile);
  }
}
Beispiel #3
0
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;
}
Beispiel #4
0
void UmlArtifact::genpro() {
  UmlPackage * pack = (UmlPackage *) parent()->parent();
  
  Q3CString path;

  if (! propertyValue("genpro path", path)) {

    path = pack->cppSrcDir();
  
    if (path.isEmpty())
      path = root_dir();
    else if (QDir::isRelativePath(path)) {
      QDir d(root_dir());
      
      d.cd(path);
      path = d.absPath();
    }
  }

  if (stereotype() == "executable") {
    gen_app(path);
  }
  else
    UmlCom::trace(stereotype() + " : not managed");
}
Beispiel #5
0
void UmlClass::import(QTextOStream & f, const QCString & indent) {
  QCString s;
  
  if (!isJavaExternal()) {
    UmlArtifact * cp = associatedArtifact();
    UmlPackage * pack = (UmlPackage *)
      ((cp != 0) ? (UmlItem *) cp : (UmlItem *) this)->package();
    
    if ((s = pack->javaPackage()).isEmpty())
      return;
    
    QCString s2 = name();
    UmlItem * p = this;
    
    while ((p = p->parent())->kind() == aClass)
      s2 = p->name() + dot + s2;
    
    s += dot + s2;
  }
  else if ((s = package()->javaPackage()).isEmpty())
    return;
  else
    s += dot + name();
  
  if (! UmlArtifact::generated_one()->is_imported(s)) {
    f << indent << "import " << s << ";\n";
    UmlArtifact::generated_one()->imported(s);
  }
}
Beispiel #6
0
void UmlClass::need_artifact(const QStringList & imports,
                             bool remove_java_lang,
                             const QStringList & ,
                             const WrapperStr & path, UmlArtifact *& cp)
{
    if (parent()->kind() == aClassView) {
        if (cp != 0)
            cp->addAssociatedClass(this);
        else {
            UmlPackage * pack = (UmlPackage *) parent()->parent();

            if ((cp = associatedArtifact()) == 0) {
                // create associated artifact
                QFileInfo fi(path);
                WrapperStr artname = WrapperStr(fi.baseName().toAscii().constData());

                if ((cp = UmlBaseArtifact::create(pack->get_deploymentview(), artname)) == 0) {
                    UmlCom::trace(WrapperStr("<font face=helvetica><b>cannot create<i> artifact ")
                                  + artname + "</i></b></font><br>");
                    return;
                }

                cp->addAssociatedClass(this);
            }

            cp->set_Stereotype("source");

            WrapperStr s = JavaSettings::sourceContent();
            int index = s.find("${definition}");

            if (index != -1) {


                for (QStringList::const_iterator it = imports.begin(); it != imports.end(); it++) {
                    WrapperStr import = WrapperStr((*it).toAscii().constData());

                    if (!remove_java_lang || (import != "java.lang.")) {
                        import += (((const char *) import)[import.length() - 1] == '.')
                                  ? "*;\n" : ";\n";

                        s.insert(index, (const char *)("import " + import));
                        index = s.find("${definition}", index);
                    }
                }

                for (QStringList::const_iterator it = imports.begin(); it != imports.end(); it++) {
                    s.insert(index, (const char *)("import static" + WrapperStr((*it).toAscii().constData()) + '\n'));
                    index = s.find("${definition}", index);
                }
            }

            cp->set_JavaSource(WrapperStr(s));
        }
    }
}
Beispiel #7
0
UmlPackage * UmlPackage::importProfile(FileIn & in, WrapperStr href)
{
    if (!href.isEmpty() && (href.left(5) != "http:") && (href.left(8) != "pathmap:")) {
        int index = href.find('#');

        if (index != -1) {
            WrapperStr id = href.mid(index + 1);
            QMap<WrapperStr, UmlItem *>::Iterator it = All.find(id);

            if (it == All.end()) {
                UmlPackage * pf = getProject()->findProfile(id);

                if (pf == 0) {
                    QFileInfo fi(in.path());
                    QDir d(fi.dir(TRUE));
                    QString fn = d.absFilePath(href.left(index));

                    if (QFile::exists(fn)) {
                        WrapperStr cmd = qApp->argv()[0] + WrapperStr(" ") + WrapperStr((const char *)fn); //[rageek] ambiguous, cast
                        int pid = UmlCom::targetItem()->apply(cmd);

                        while (isToolRunning(pid)) {
#ifdef WIN32
                            Sleep(1000);
#else
                            sleep(1);
#endif
                        }

                        UmlCom::targetItem()->unload(FALSE, FALSE); // to reread children

                        if ((pf = ((UmlPackage *) UmlCom::targetItem())->findProfile(id)) != 0)
                            // not in Bouml case
                            pf->loadFromProfile();
                    }
                    else
                        in.warning("can't open " + href.left(index));
                }
                else
                    // not in Bouml case
                    pf->loadFromProfile();

                return pf;
            }
            else if ((*it)->kind() == aPackage)
                return (UmlPackage *) *it;
        }
    }

    return 0;
}
Beispiel #8
0
void UmlArtifact::generate_text()
{
    const WrapperStr srcdef = javaSource();

    if (srcdef.isEmpty()) {
        if (verbose())
            UmlCom::trace(WrapperStr("<hr><font face=helvetica>artifact <i>")
                          + name() + "</i> has an empty Java definition</font><br>");

        return;
    }

    UmlPackage * pack = package();
    const WrapperStr & name = UmlArtifact::name();
    WrapperStr src_path = pack->text_path(name);

    WrapperStr s = " in <i> " + src_path + "</i>";

    UmlCom::message(name);

    if (verbose())
        UmlCom::trace(WrapperStr("<hr><font face=helvetica>Generate code for <i> ")
                      + name + "</i>" + s + "</font><br>");
    else
        set_trace_header(WrapperStr("<font face=helvetica>Generate code for <i> ")
                         + name + "</i>" + s + "</font><br>");

    if (must_be_saved(src_path, (const char *) srcdef)) {
        write_trace_header();

        FILE * fp_src;

        if ((fp_src = fopen((const char *) src_path, "wb")) == 0) {
            write_trace_header();
            UmlCom::trace(WrapperStr("<font color=\"red\"><b><i> ")
                          + name + " : </i> cannot open <i> "
                          + src_path + "</i>, edit the <i> generation settings</i> (tab directory) or the <i>"
                          + pack->name() + "</i> Java directory specification</b></font><br>");
            incr_error();
        }
        else {
            fputs((const char *) srcdef, fp_src);
            fclose(fp_src);
        }
    }
    else if (get_trace_header().isEmpty())
        UmlCom::trace(WrapperStr("<font face=helvetica><i> ")
                      + src_path + "</i> not modified</font><br>");
}
Beispiel #9
0
void UmlClass::write(QTextOStream & f) {
  if (isJavaExternal()) {
    QCString s = javaDecl().stripWhiteSpace();
    int index;
      
    if ((index = s.find("${name}")) != -1)
      s.replace(index, 7, name());
    else if ((index = s.find("${Name}")) != -1)
      s.replace(index, 7, capitalize(name()));
    else if ((index = s.find("${NAME}")) != -1)
      s.replace(index, 7, name().upper());
    else if ((index = s.find("${nAME}")) != -1)
      s.replace(index, 7, name().lower());
    
    f << s;
  }
  else {
    UmlClass * toplevel = this;
    UmlItem * p;
    QCString s2;
    
    while ((p = toplevel->parent())->kind() == aClass) {
      toplevel = (UmlClass *) p;
      s2 = dot + p->name() + s2;
    }
    
    UmlArtifact * cp = toplevel->associatedArtifact();
    UmlPackage * pack = (UmlPackage *)
      ((cp != 0) ? (UmlItem *) cp : (UmlItem *) toplevel)->package();
    
    if (pack != UmlArtifact::generation_package()) {
      QCString s = pack->javaPackage();

      if (! s.isEmpty() && (s != "java.lang") && (s.left(10) != "java.lang.")) {
	s += s2;
	
	if (JavaSettings::isForcePackagePrefixGeneration() ||
	    !UmlArtifact::generated_one()->is_imported(s, name()))
	  f << s << '.';
      }
    }
    else if (! s2.isEmpty())
      f << s2.mid(1) << '.';
    
    f << name();
  }
}
Beispiel #10
0
void UmlArtifact::roundtrip_cpp()
{
    if (! managed) {
        managed = TRUE;

        if (stereotype() != "source")
            return;

        const WrapperStr hdef = cppHeader();
        const WrapperStr srcdef = cppSource();

        if (hdef.isEmpty() && srcdef.isEmpty())
            return;

        const WrapperStr & name = UmlArtifact::name();
        UmlPackage * pack = package();
        WrapperStr h_path = pack->header_path(name);
        WrapperStr src_path = pack->source_path(name);

        {
            WrapperStr s;

            if (!hdef.isEmpty())
                s = "<i> " + h_path + "</i>";

            if (!srcdef.isEmpty()) {
                if (!hdef.isEmpty())
                    s += " and <i> " + src_path + "</i>";
                else
                    s = "<i> " + src_path + "</i>";
            }

            UmlCom::message(name);

            if (verbose())
                UmlCom::trace(WrapperStr("<hr><font face=helvetica>roundtrip body from")
                              + s + "</font><br>");
            else
                set_trace_header(WrapperStr("<font face=helvetica>roundtrip body from")
                                 + s + "</font><br>");
        }

        UmlOperation::roundtrip(h_path, cppLanguage);
        UmlOperation::roundtrip(src_path, cppLanguage);
    }
}
Beispiel #11
0
void Package::send_dir(bool rec)
{
    // reverse phase
    UmlPackage * prj = root->uml;

    while (prj->parent() != 0)
        prj = (UmlPackage *) prj->parent();

    prj->set_childrenVisible(FALSE);

    QDir d(path);

    progress = new Progress(file_number(d, TRUE),
                            (scan) ? "Scanning in progress, please wait ..."
                            : "Reverse in progress, please wait ...");

    reverse_directory(d, rec);

    if (progress != 0)
        delete progress;

    ((uml) ? uml : root->uml)->set_childrenVisible(TRUE);
}
Beispiel #12
0
UmlClassView * UmlPackage::get_classview(const Q3CString & nmsp) {
  UmlPackage * pack;
  
  if (nmsp != cppNamespace()) {
    if (namespace_fixedp) {
      if ((pack = findCppNamespace(nmsp)) == 0) {
	Q3CString s = nmsp;
	
	if (s.isEmpty())
	  s = name();
	else {
	  int index = 0;
	  
	  while ((index = s.find("::", index)) != -1)
	    s.replace(index++, 2, " ");
	}
	
	if (((pack = UmlBasePackage::create(this, s)) == 0) &&
	    ((pack = UmlBasePackage::create(this, s += "_")) == 0) &&
	    ((pack = UmlBasePackage::create(this, s += "_")) == 0) &&
	    ((pack = UmlBasePackage::create(this, s += "_")) == 0) &&
	    ((pack = UmlBasePackage::create(this, s += "_")) == 0)) {
#ifdef REVERSE
	  UmlCom::trace(Q3CString("<font face=helvetica><b>cannot create package <i>")
			+ s + "</i> under package <i>"
			+ name() + "</b></font><br>");
	  UmlCom::message("");
	  throw 0;
#else
	  QMessageBox::critical(0, "Fatal Error", 
				Q3CString("<font face=helvetica><b>cannot create package <i>")
				+ s + "</i> under package <i>"
				+ Name() + "</b></font><br>");
	  QApplication::exit(1);
#endif	  
	}
	
	pack->set_CppNamespace(nmsp);
	pack->set_CppSrcDir(cppSrcDir());
	pack->set_CppHDir(cppHDir());
	pack->namespace_fixedp = TRUE;
      }
    }
    else {
      pack = this;
      pack->set_CppNamespace(nmsp);
      pack->namespace_fixedp = TRUE;
    }
  }
  else
    pack = this;
  
  if (pack->class_view == 0) {
    Q3PtrVector<UmlItem> ch = pack->children();
    
    for (unsigned index = 0; index != ch.size(); index += 1)
      // return the first class view find
      if (ch[index]->kind() == aClassView)
	return pack->class_view = (UmlClassView *) ch[index];
    
    if ((pack->class_view = UmlBaseClassView::create(pack, name())) == 0) {
#ifdef REVERSE
      UmlCom::trace(Q3CString("<font face=helvetica><b>cannot create class view <i>")
		    + name() + "</i> under package <i>"
		    + pack->name() + "</b></font><br>");
      UmlCom::message("");
      throw 0;
#else
      QMessageBox::critical(0, "Fatal Error", 
			    Q3CString("<font face=helvetica><b>cannot create class view <i>")
			    + name() + "</i> under package <i>"
			    + pack->name() + "</b></font><br>");
      QApplication::exit(1);
#endif
    }
  }
  
  return pack->class_view;
}
Beispiel #13
0
int main(int argc, char ** argv)
{
  if (argc != 2)
      return 0;
  
  if (UmlCom::connect(Q3CString(argv[1]).toUInt())) {
    bool aborted = TRUE;
    
    try {
      UmlCom::trace("<b>C++ roundtrip</b> release 1.3<br>");
      UmlCom::traceAutoRaise(FALSE);
      
      char * argv = 0;
      int argc = 0;
      QApplication * app = new QApplication(argc, &argv);
      UmlItem * item = UmlCom::targetItem();
      int n;

      switch (item->kind()) {
      default:
	UmlCom::trace("<font face=helvetica><b>must be applied on a <i>package, class view, deployment view, artifact</i> or <i>class</i></b></font><br>");
	aborted = FALSE;
	throw 0;
      case aPackage:
	n = ((UmlPackage *) item)->count_roundtriped();
	break;
      case aClassView:
      case aDeploymentView:
      case anArtifact:
	n = 1;
	break;
      case aClass:
	if (item->parent()->kind() != aClassView) {
	  UmlCom::trace("<font face=helvetica><b>can't be applied on a <i>class</i> nested or out of a <i>class view</i></b></font><br>");
	  aborted = FALSE;
	  throw 0;
	}
	n = 1;
	break;
      }

      UmlPackage * project = UmlPackage::getProject();
      
      UmlCom::trace("<font face=helvetica>Upload project ...</font>");
      Package::init(project, app);
      UmlCom::trace("<font face=helvetica>...done</font><br>");
      UmlCom::message("");
      Package::set_step(0, n);
      
      UmlCom::trace("<font face=helvetica>Preparation...</font>");
      if (!item->set_roundtrip_expected() &&
	  (QMessageBox::warning(0, "Roundtrip",
				"Some elements to roundtrip are read-only and will not be updated\n\n"
				"Roundtrip anyway ?",
				"Yes", "No", QString::null, 1, 1)
	   != 0)) {
	aborted = FALSE;
	throw 0;
      }
      
      Package::set_step(0, -1);
      UmlCom::trace("<font face=helvetica>...done</font><br>");
      
      if ((item->kind() == aPackage) && !UmlArtifact::is_roundtrip_usefull()) {
	UmlCom::trace("<font face=helvetica>you don't ask for to roundtrip artifact(s)<br><br>"
		      "probably you want to do a <i>reverse</i> rather than a <i>roundtrip</i></font><br>");
	aborted = FALSE;
	throw 0;
      }
	
      Q3CString f;
	
      if (project->propertyValue("#file", f))
	Lex::defines(f);
	         
      n = 0;
      item->scan_it(n);
      CppSettings::set_UseDefaults(TRUE);
      project->set_childrenVisible(FALSE);
      item->send_it(n);
      UmlOperation::force_defs();
      Statistic::produce();
      
      // umark all
      {
	Q3PtrVector<UmlItem> marked = UmlItem::markedItems();
	UmlItem ** v = marked.data();
	UmlItem ** const vsup = v + marked.size();
	
	for (;v != vsup; v += 1)
	  (*v)->set_isMarked(FALSE);
      }
      
      Q3PtrList<UmlItem> useless;
      
      item->mark_useless(useless);
      
      if (!useless.isEmpty() &&
	  (QMessageBox::warning(0, "C++ roundtrip",
				"The marked elements are useless because they don't\n"
				"correspond to something in the roundtriped files\n\n\n"
				"Delete them ?",
				"Yes", "No", QString::null, 1, 1)
	   == 0)) {
	Q3PtrListIterator<UmlItem> iter(useless);
	
	do {
	  if (iter.current()->isMarked())
	    iter.current()->deleteIt();
	} while (++iter, iter.current() != 0);
      }
      
      project->set_childrenVisible(TRUE);
      item->set_childrenVisible(TRUE); // re select it
      aborted = FALSE;
    }
    catch (...) {
    }
    
    try {
      // socket may be already closed
      if (aborted)
	UmlCom::trace("<font face=helvetica><br><b>Rountrip aborted!</b></font><br>");	
      
      UmlCom::message("");
      UmlCom::showTrace();
      UmlCom::bye((aborted) ? 1 : 0);	// application must not be deleted
    }
    catch (...) {
    }
  }
  
  UmlCom::close();	// application must not be deleted
  return 0;
}
Beispiel #14
0
void Package::reverse_file(WrapperStr path, WrapperStr name)
{
    if (! Lex::open(path)) {
        // very strange !
        if (! scan)
            UmlCom::trace(WrapperStr("<font face=helvetica><b>cannot open <i>")
                          + path + "</i></b></font><br>");
    }
    else {
        UmlArtifact * art = 0;
        WrapperStr file_start;
        WrapperStr file_end;

        UmlCom::message(((scan) ? "scan " : "reverse ") + path);

        // go after <?[php]
        Lex::mark();

        bool redo;
        bool before_class;

        do {
            redo = FALSE;
            before_class = TRUE;

            WrapperStr s;
            char c = Lex::read_word_bis();

            while (c != 0) {
                if (c == '<') {
                    c = Lex::read_word_bis();

                    if (c == '?') {
                        if (!scan) file_start = Lex::region();

                        s = Lex::read_word();

                        if (s.lower() == "php") {
                            if (!scan) file_start = Lex::region();

                            s = Lex::read_word();
                        }

                        break;
                    }
                }
                else
                    c = Lex::read_word_bis();
            }

            aVisibility visibility = PackageVisibility;
            bool abstractp = FALSE;
            bool finalp = FALSE;
            bool inside_namespace_brace = FALSE;

            while (!s.isEmpty()) {
                if ((s == "class") || (s == "interface")) {
#ifdef REVERSE

                    if (!scan && (art == 0)) {
                        UmlPackage * pack = get_uml(TRUE);

                        if ((art = UmlBaseArtifact::create(pack->get_deploymentview(Namespace::current()), name)) == 0) {
                            UmlCom::trace(WrapperStr("<font face=helvetica><b>cannot create<i> artifact ")
                                          + name + "</i></b></font><br>");
                            Namespace::exit();
                            Lex::close();
                            return;
                        }

                        art->set_Stereotype("source");
                    }

#endif

                    if (!Class::reverse(this, s, abstractp, finalp, path, art))
                        break;

                    visibility = PackageVisibility;
                    abstractp = FALSE;
                    finalp = FALSE;

                    before_class = FALSE;
                    Lex::mark();
                }
                else if (s == "public")
                    visibility = PublicVisibility;
                else if (s == "protected")
                    visibility = ProtectedVisibility;
                else if (s == "private")
                    visibility = PrivateVisibility;
                else if (s == "final")
                    finalp = TRUE;
                else if (s == "abstract")
                    abstractp = TRUE;
                else if ((s == "namespace") && before_class) {
                    Namespace::exit();

                    s = Lex::read_word();

                    if (s == "{")
                        inside_namespace_brace = TRUE;
                    else if (s.isEmpty()) {
                        if (!scan)
                            Lex::premature_eof();

                        break;
                    }
                    else {
                        Namespace::enter(s);
                        s = Lex::read_word();

                        if (s == "{")
                            inside_namespace_brace = TRUE;

                        // else is ';'
                    }
                }
                else if ((s == "use") && before_class) {
                    if (!scan)
                        use();
                    else
                        UmlOperation::skip_body(0);

                    Lex::finish_line();
                    Lex::clear_comments();
                }
                else if ((s == "}") && inside_namespace_brace) {
                    inside_namespace_brace = FALSE;
                    Namespace::exit();
                }
                else if (s != ";") {
                    if (before_class) {
                        if ((s == "?") && ((s = Lex::read_word()) == ">")) {
                            // this <?php ..?> doesn't contains classes
                            // search for a next <?php ..?>
                            redo = TRUE;
                            Lex::clear_comments();

                            if (!scan)
                                file_start = Lex::region();

                            break;
                        }

                        UmlOperation::skip_body(0);
                        Lex::finish_line();
                        Lex::clear_comments();

                        if (!scan)
                            file_start = Lex::region();
                    }
                    else if (!scan) {
                        // go to end of file
                        while (Lex::read_word_bis() != 0)
                            ;

                        file_end = Lex::region();
                        break;
                    }
                    else
                        break;
                }

                s = Lex::read_word();
            }
        }
        while (redo);

#ifdef REVERSE

        if (! scan) {
            if (art == 0) {
                UmlPackage * pack = get_uml(TRUE);

                if ((art = UmlBaseArtifact::create(pack->get_deploymentview(Namespace::current()), name)) == 0) {
                    UmlCom::trace(WrapperStr("<font face=helvetica><b>cannot create<i> artifact ")
                                  + name + "</i></b></font><br>");
                    Namespace::exit();
                    Lex::close();
                    return;
                }

                art->set_Stereotype("source");
            }

            if (before_class)
                art->set_PhpSource(file_start);
            else if (!Namespace::current().isEmpty()) {
                int p1 = file_start.operator QString().lastIndexOf("namespace");
                int p2 = file_start.find(';', p1);
                int p3 = file_start.find('{', p1);

                if ((p3 != -1) && ((p3 < p2) || (p2 == -1)))
                    file_start.replace(p1, p3 - p1 + 1, "${namespace}");
                else
                    file_start.replace(p1, p2 - p1 + 1, "${namespace}");

                art->set_PhpSource(file_start + "\n${definition}\n\n" + file_end);
            }
            else
                art->set_PhpSource(file_start + "\n${definition}\n\n" + file_end);

            art->unload();
        }

#endif

        Namespace::exit();

        Lex::close();
    }
}
Beispiel #15
0
void UmlPackage::fileControl(bool ci)
{
    UmlPackage * prj = getProject();
    QByteArray prjfile = prj->supportFile();
    BooL rec;
    BooL reload;
    QByteArray cmd;

    if (! prj->propertyValue((ci) ? "check-in-cmd" : "check-out-cmd", cmd))
        cmd = "specify the command containing %file and %dir or %dironly";

    Dialog dialog(ci, cmd, rec, reload);	// the dialog execution set 'cmd' and 'rec'

    if (dialog.exec() == QDialog::Accepted) {
        // save the command for a future usage
        prj->set_PropertyValue((ci) ? "check-in-cmd" : "check-out-cmd", cmd);

        if (reload)
            saveProject();

        // get files list
        QHash<QString,void*> files;

        getFiles(files, (rec) ? ~0u : 1);

        if (this == prj)
            getAuxFiles(files);

        // apply the command on each file
        QHashIterator<QString,void*> it(files);
        QFileInfo prjpath(prjfile);
        QString dir = prjpath.path();
        QString dironly = dir;
        int index;

        if ((dironly.length() > 3) &&
            (dironly[1] == ':') &&
            (dironly[2] == '/'))
            dironly = dironly.mid(2);

        while ((index = cmd.indexOf("%dironly")) != -1)
            cmd.replace(index, 8, dironly.toLatin1());

        while ((index = cmd.indexOf("%dir")) != -1)
            cmd.replace(index, 4, dir.toLatin1());

        while (it.hasNext()) {
            it.next();
            QString s = cmd;

            while ((index = s.indexOf("%file")) != -1)
                s.replace(index, 5, it.key().toLatin1());

            system((const char *) s.toLatin1().constData());
            //++it;
        }

        UmlCom::trace("Done.");

        if (reload)
            loadProject(prjfile);
    }
}
Beispiel #16
0
void UmlPackage::importIt(FileIn & in, Token & token, UmlItem * where)
{
    while (where->kind() != aPackage)
        where = where->parent();

    WrapperStr s = token.valueOf("name");

    if (s.isEmpty()) {
        static unsigned n = 0;

        s.sprintf("anonymous %u", ++n);
    }

    UmlPackage * pack = create((UmlPackage *) where, s);

    if (pack == 0)
        in.error("cannot create package '" + s + "' in '" + where->name() + "'");

    bool profile =
        (token.what() == "uml:profile") || (token.xmiType() == "uml:Profile");

    if (profile) {
        pack->set_Stereotype("profile");
        pack->set_PropertyValue("xmiId", token.xmiId());
        NumberOf -= 1;
        NumberOfProfile += 1;

        if (!(s = token.valueOf("metamodelreference")).isEmpty())
            pack->set_PropertyValue("metamodelReference", s);

        if (!(s = token.valueOf("metaclassreference")).isEmpty())
            pack->set_PropertyValue("metaclassReference", s);
    }

    s = token.xmiId();

    if (!s.isEmpty()) {
        pack->addItem(s, in);

        if (! token.closed()) {
            WrapperStr k = token.what();
            const char * kstr = k;

            if (profile) {
                while (in.read(), !token.close(kstr)) {
                    if ((token.what() == "packagedelement") &&
                        (token.xmiType() == "uml:Extension")) {
                        if (! token.closed())
                            in.finish(token.what());
                    }
                    else if (token.what() == "packageimport")
                        pack->packageImport(in, token);
                    else
                        pack->UmlItem::import(in, token);
                }

                updateProfiles();
            }
            else
                while (in.read(), !token.close(kstr))
                    pack->UmlItem::import(in, token);
        }
    }
    else if (! token.valueOf("href", s))
        in.error("xmi:id is missing"); // doesn't return
    else {
        in.warning("bypass external package " + s);

        if (! token.closed())
            in.finish(token.what());
    }

    pack->unload(TRUE, FALSE);
}
Beispiel #17
0
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";
                    srcform = "#include \"" + p->header_path(art->name(), srcdir) + "\"\n";
                }
                else
                    srcform = hform = "#include \"" + art->name() + '.' +
                                      CppSettings::headerExtension() + "\"\n";
            }
            else if (cl->parent()->kind() != aClass) {
                write_trace_header();
                UmlCom::trace(WrapperStr("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b> class<i> ") + cl->name() +
                              "</i> referenced but does not have associated <i>artifact</i></b></font><br>");
                incr_warning();
                continue;
            }
        }

        if (included) {
            // #include must be placed in the header file
            if ((h_incl.find(hform) == -1) && (hdef.find(hform) == -1))
                h_incl += hform;
        }
        else if ((cl != 0) &&
                 (cl->parent()->kind() != aClass)) {	// else too complicated
            // #include useless in header file, place it in the source file
            if ((src_incl.find(srcform) == -1) && (h_incl.find(hform) == -1) &&
                (hdef.find(hform) == -1) && (srcdef.find(srcform) == -1))
                src_incl += srcform;

            if (!cl->isCppExternal()) {
                // header file must contains the declaration
                hform = cl->decl();

                if (decl.find(hform) == -1)
                    decl += hform;

                if ((cl->associatedArtifact() == 0) &&
                    (cl->parent()->kind() != aClass)) {
                    write_trace_header();
                    UmlCom::trace(WrapperStr("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b> class<i> ") + cl->name() +
                                  "</i> referenced but does not have associated <i>artifact</i></b></font><br>");
                    incr_warning();
                }
            }
        }
        else if (!hform.isEmpty()) {
            // have the #include form but does not know if it is a class or other,
            // generate the #include in the header file EXCEPT if the #include is
            // already in the header/source file to allow to optimize the generated
            // code
            if ((src_incl.find(srcform) == -1) && (h_incl.find(hform) == -1) &&
                (hdef.find(hform) == -1) && (srcdef.find(srcform) == -1))
                h_incl += hform;
        }
    }
}
Beispiel #18
0
void UmlArtifact::generate() {
  if (! managed) {
    managed = TRUE;
    
    if (stereotype() == "text") {
      generate_text();
      return;
    }
    else if (stereotype() != "source")
      return;
    
    package_of_generated_artifact = package();
    
    const Q3CString def = idlSource();
    
    if (def.isEmpty())
      return;
    
    const Q3CString & name = this->name();    
    UmlPackage * pack = package();
    Q3CString path = pack->path(name);
    Q3CString mod_start;
    Q3CString mod_end;
    Q3CString mod = pack->idlModule();
    
    if (! mod.isEmpty()) {
      int index = 0;
      int index2;
      Q3CString closed = "\n}; // module ";
      
      while ((index2 = mod.find(':', index)) != -1) {
	Q3CString mo = mod.mid(index, index2 - index);
	
	mod_start += Q3CString("module ") + mo + " {\n\n";
	closed += mo;
	mod_end = closed + "\n" + mod_end;
	closed += "::";
	mod.replace(index2, 2, "_");
	index = index2 + 1;
      }
      
      mod_start += Q3CString("module ") + mod.mid(index) + " {\n\n";
      closed += mod.mid(index);
      mod_end = closed + "\n" + mod_end;
    }
    
    UmlCom::message(name);
    if (verbose())
      UmlCom::trace(Q3CString("<hr><font face=helvetica>Generate code for <i> ")
		    + name + "</i> in <i>" + path + "</i></font><br>");
    else
      set_trace_header(Q3CString("<font face=helvetica>Generate code for <i> ")
		       + name + "</i> in <i>" + path + "</i></font><br>");
    
#if 0
    // compute dependencies
    
    Q3PtrList<CppRefType> dependencies;
#endif
    const Q3PtrVector<UmlClass> & cls = associatedClasses();
    unsigned n = cls.count();
    unsigned index;
    
#if 0
    for (index = 0; index != n; index += 1)
      cls[index]->compute_dependencies(dependencies);
#endif
    
    // generate source file
    
    QByteArray file;
    QTextOStream f(&file);
    const char * p = def;
    const char * pp = 0;
    
    for (;;) {
      if (*p == 0) {
	if (pp == 0)
	  break;
	
	// comment management done
	p = pp;
	pp = 0;
	if (*p == 0)
	  break;
      }
      
      if (*p == '@')
	manage_alias(p, f);
      else if (*p != '$')
	f << *p++;
      else if (!strncmp(p, "${comment}", 10))
	manage_comment(p, pp);
      else if (!strncmp(p, "${description}", 14))
	manage_description(p, pp);
      else if (!strncmp(p, "${name}", 7)) {
	p += 7;
	f << name;
      }
      else if (!strncmp(p, "${Name}", 7)) {
	p += 7;
	f << capitalize(name);
      }
      else if (!strncmp(p, "${NAME}", 7)) {
	p += 7;
	f << name.upper();
      }
      else if (!strncmp(p, "${nAME}", 7)) {
	p += 7;
	f << name.lower();
      }
      else if (!strncmp(p, "${module}", 9)) {
	p += 9;
	f << mod;
      }
      else if (!strncmp(p, "${MODULE}", 9)) {
	p += 9;
	f << mod.upper();
      }
      else if (!strncmp(p, "${includes}", 11)) {
	p += 11;
	/*if (!incl_computed) {
	  incl_computed = TRUE;
	  CppRefType::compute(dependencies, hdef, srcdef, h_incl, decl, incl, this);
	}
	if (!incl.isEmpty()) {
	  f << incl;
	  if (*p != '\n')
	    f << '\n';
	}
	else*/ if (*p == '\n')
	  p += 1;
      }
      else if (!strncmp(p, "${definition}", 13)) {
	p += 13;
	for (index = 0; index != n; index += 1)
	  cls[index]->generate(f);
	if (*p == '\n')
	  p += 1;
      }
      else if (!strncmp(p, "${module_start}", 15)) {
	p += 15;
	if (!mod_start.isEmpty())
	  f << mod_start;
	if (*p == '\n')
	  p += 1;
      }
      else if (!strncmp(p, "${module_end}", 13)) {
	p += 13;
	if (!mod_end.isEmpty())
	  f << mod_end;
	if (*p == '\n')
	  p += 1;
      }
      else
	// strange
	f << *p++;
    }
    
    f << '\000';
    
    if (must_be_saved(path, file)) {
      write_trace_header();
	
      FILE * fp;
      
      if ((fp = fopen((const char *) path, "wb")) == 0) {
	write_trace_header();
	UmlCom::trace(Q3CString("<font color=\"red\"><b><i> ")
		      + name + " : </i> cannot open <i> " 
		      + path + "</i>, edit the <i> generation settings</i> (tab directory) or the <i>"
		      + pack->name() + "</i> Idl directory specification</b></font><br>");
	incr_error();
      }
      else {
	fputs((const char *) file, fp);
	fclose(fp);
      }
    }
    else if (get_trace_header().isEmpty())
      UmlCom::trace(Q3CString("<font face=helvetica><i> ")
		    + path + "</i> not modified</font><br>");
  }
}
Beispiel #19
0
void UmlArtifact::generate()
{
    if (! managed) {
        managed = TRUE;

        if (stereotype() == "text") {
            generate_text();
            return;
        }
        else if (stereotype() != "source")
            return;

        package_of_generated_artifact = package();

        const WrapperStr hdef = cppHeader();
        QLOG_INFO() << "Read header as: " + hdef.operator QString();
        const WrapperStr srcdef = cppSource();

        if (hdef.isEmpty() && srcdef.isEmpty()) {
            if (verbose())
                UmlCom::trace(WrapperStr("<hr><font face=helvetica>artifact <i>")
                              + name() + "</i> has an empty C++ definition</font><br>");

            return;
        }

        const WrapperStr & name = UmlArtifact::name();
        UmlPackage * pack = package();
        WrapperStr h_path = pack->header_path(name);
        WrapperStr src_path = pack->source_path(name);
        WrapperStr nasp_start;
        WrapperStr nasp_end;
        const char * cnasp = pack->cppNamespace();
        WrapperStr nasp = ((cnasp[0] == ':') && (cnasp[1] == ':'))
                         ? cnasp + 2 : cnasp;

        if (!nasp.isEmpty()) {
            int index = 0;
            int index2;
            WrapperStr closed = "\n} // namespace ";

            while ((index2 = nasp.find(':', index)) != -1) {
                WrapperStr na = nasp.mid(index, index2 - index);

                nasp_start += WrapperStr("namespace ") + na + " {\n\n";
                closed += na;
                nasp_end = closed + "\n" + nasp_end;
                closed += "::";
                nasp.replace(index2, 2, "_");
                index = index2 + 1;
            }

            nasp_start += WrapperStr("namespace ") + nasp.mid(index) + " {\n\n";
            closed += nasp.mid(index);
            nasp_end = closed + "\n" + nasp_end;
        }
        else {
            WrapperStr s;

            if (!hdef.isEmpty())
                s = " in <i> " + h_path + "</i>";

            if (!srcdef.isEmpty()) {
                if (!hdef.isEmpty())
                    s += " and <i> " + src_path + "</i>";
                else
                    s = " in <i> " + src_path + "</i>";
            }

            UmlCom::message(name);

            if (verbose())
                UmlCom::trace(WrapperStr("<hr><font face=helvetica>Generate code for <i> ")
                              + name + "</i>" + s + "</font><br>");
            else
                set_trace_header(WrapperStr("<font face=helvetica>Generate code for <i> ")
                                 + name + "</i>" + s + "</font><br>");
        }

        // get bodies if preserve
        const Q3PtrVector<UmlClass> & cls = associatedClasses();

        if (preserve())
            UmlOperation::read_bodies(h_path, src_path);

        // compute dependencies

        bool all_in_h = (hdef.find("${all_includes}") != -1);
        Q3PtrList<CppRefType> dependencies;
        unsigned n = cls.count();
        unsigned index;

        for (index = 0; index != n; index += 1)
            cls[index]->compute_dependencies(dependencies, all_in_h);

        // generate header file

        WrapperStr h_incl;
        WrapperStr src_incl;
        WrapperStr decl;
        bool incl_computed = FALSE;

        if (!hdef.isEmpty()) {


            //headerFile->append("Test DAta");

            QLOG_INFO() << "openign file for writing: ";
            //QTextStream f_h(file.data()); //[lgfreitas] Now QTextStream receives a pointer to a byte array...
            QSharedPointer<QByteArray> headerFile(new QByteArray());
            QTextStream f_h(headerFile.data(), QFile::WriteOnly);
            f_h.setCodec(QTextCodec::codecForLocale());
            //QTextStream f_h(headerFile.data(), QIODevice::WriteOnly);
            //QString h_copy = QString(hdef.operator QString());
            const char * p = hdef;
            const char * pp = 0;

            for (;;)
            {
                QLOG_INFO() << "At this point P is: " << QString(p);
                if (*p == 0) {
                    if (pp == 0)
                        break;

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

                    if (*p == 0)
                        break;
                }


                if (*p == '@')
                    manage_alias(p, f_h);
                else if (*p != '$')
                {
                    QTextCodec* codec = QTextCodec::codecForLocale();
                    //f_h << codec->fromUnicode(*p,1);
                    //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, "${name}", 7)) {
                    p += 7;
                    f_h << name;
                }
                else if (!strncmp(p, "${Name}", 7)) {
                    p += 7;
                    //QLOG_INFO() << "Outputting name: " << name;
                    f_h << capitalize(name);
                }
                else if (!strncmp(p, "${NAME}", 7)) {
                    p += 7;
                    f_h << name.upper();
                }
                else if (!strncmp(p, "${nAME}", 7)) {
                    p += 7;
                    f_h << name.lower();
                }
                else if (!strncmp(p, "${namespace}", 12)) {
                    p += 12;
                    f_h << nasp;
                }
                else if (!strncmp(p, "${NAMESPACE}", 12)) {
                    p += 12;
                    f_h << nasp.upper();
                }
                else if (!strncmp(p, "${includes}", 11)
                         || !strncmp(p, "${all_includes}", 15))
                {
                    QLOG_INFO() << "REaDING INCLUDES";
                    p += (p[2] == 'a') ? 15 : 11;
                    QLOG_INFO() << "Modified p 1 to be" << QString(p);
                    if (!incl_computed)
                    {
                        incl_computed = TRUE;
                        CppRefType::compute(dependencies, hdef.operator QString(), srcdef, h_incl, decl, src_incl, this);
                        QLOG_INFO() << "Modified hdef to be: " << hdef.operator QString();

                    }
                    QLOG_INFO() << "Modified p 2 to be" << QString(p);
                    if (!h_incl.isEmpty())
                    {
                        f_h << h_incl;

                        if (*p != '\n')
                            f_h << '\n';
                    }
                    else if (*p == '\n')
                        p += 1;
                    QLOG_INFO() << "FINISHED INCLUDES";
                }
                else if (!strncmp(p, "${declarations}", 15))
                {
                    p += 15;

                    if (!incl_computed)
                    {
                        incl_computed = TRUE;
                        CppRefType::compute(dependencies, hdef.operator QString(), srcdef, h_incl, decl, src_incl, this);
                    }
                    QLOG_INFO() << "DECLS IS: " << decl.operator QString();
                    if (!decl.isEmpty())
                    {
                        f_h << decl;

                        if (*p != '\n')
                            f_h << '\n';
                    }
                    else if (*p == '\n')
                        p += 1;
                }
                else if (!strncmp(p, "${namespace_start}", 18)) {
                    p += 18;

                    if (!nasp_start.isEmpty())
                        f_h << nasp_start;

                    if (*p == '\n')
                        p += 1;
                }
                else if (!strncmp(p, "${namespace_end}", 16)) {
                    p += 16;

                    if (!nasp_end.isEmpty())
                        f_h << nasp_end;

                    if (*p == '\n')
                        p += 1;
                }
                else if (!strncmp(p, "${definition}", 13)) {
                    p += 13;

                    for (index = 0; index != n; index += 1)
                        cls[index]->generate_decl(f_h, current_indent(p, hdef.operator QString()));

                    if (*p == '\n')
                        p += 1;
                }
                else
                    // strange
                    f_h << toLocale(p);
            }

            f_h << '\000';
            f_h.flush();

            if (must_be_saved(h_path, headerFile->data())) {
                QLOG_INFO() << "this is essentially what goes to the header file: " << headerFile->size();
                write_trace_header();

                //FILE * fp_h;
                 QFile file(h_path);
                if (!file.open(QFile::WriteOnly))
                {
                    UmlCom::trace(WrapperStr("<font color=\"red\"><b><i> ")
                                  + name + "</i> : cannot open <i> "
                                  + h_path + "</i>, edit the <i> generation settings</i> (tab directory) or the <i>"
                                  + pack->name() + "</i> C++ directory specification</b></font><br>");
                    incr_error();
                }
                else {
                    QLOG_INFO() << "this is essentially what goes to the file: " << headerFile->constData();

                    QTextCodec* codec = QTextCodec::codecForLocale();
                    QTextStream out(&file);
                    out.setCodec(QTextCodec::codecForLocale());
                    QString temp(*headerFile.data());
                    out << codec->toUnicode(temp);
                    //out << *headerFile.data();
                    out.flush();
                }
            }
            else {
                WrapperStr th = get_trace_header();

                if (th.isEmpty())
                    UmlCom::trace(WrapperStr("<br><font face=helvetica><i> ")
                                  + h_path + "</i> not modified</font><br>");
                else
                    set_trace_header(th + "<font face=helvetica><i> "
                                     + h_path + "</i> not modified</font><br>");
            }
        }

        // generate source file

        if (!srcdef.isEmpty()) {
            QSharedPointer<QByteArray> file(new QByteArray());
            QTextStream f_src(file.data(), QIODevice::WriteOnly);
            const char * p = srcdef;
            const char * pp = 0;

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

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

                    if (*p == 0)
                        break;
                }

                if (*p == '@')
                    manage_alias(p, f_src);
                else if (*p != '$')
                    f_src << 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, "${name}", 7)) {
                    // for file header
                    p += 7;
                    f_src << name;
                }
                else if (!strncmp(p, "${includes}", 11)) {
                    p += 11;

                    if (!incl_computed) {
                        incl_computed = TRUE;
                        CppRefType::compute(dependencies, hdef.operator QString(), srcdef, h_incl, decl, src_incl, this);
                    }

                    if (!src_incl.isEmpty()) {
                        f_src << src_incl;

                        if (*p != '\n')
                            f_src << '\n';
                    }
                    else if (*p == '\n')
                        p += 1;
                }
                else if (!strncmp(p, "${members}", 10)) {
                    p += 10;

                    for (index = 0; index != n; index += 1)
                        cls[index]->generate_def(f_src, current_indent(p, srcdef), FALSE);

                    if (*p == '\n')
                        p += 1;
                }
                else if (!strncmp(p, "${namespace_start}", 18)) {
                    p += 18;

                    if (!nasp_start.isEmpty())
                        f_src << nasp_start;

                    if (*p == '\n')
                        p += 1;
                }
                else if (!strncmp(p, "${namespace_end}", 16)) {
                    p += 16;

                    if (!nasp_end.isEmpty())
                        f_src << nasp_end;

                    if (*p == '\n')
                        p += 1;
                }
                else
                    // strange
                    f_src << toLocale(p);
            }

            f_src << '\000';
            f_src.flush();

            if (must_be_saved(src_path, file->data())) {
                write_trace_header();

                FILE * fp_src;

                if ((fp_src = fopen((const char *) src_path, "wb")) == 0) {
                    write_trace_header();
                    UmlCom::trace(WrapperStr("<font color=\"red\"><b><i> ")
                                  + name + " : </i> cannot open <i> "
                                  + src_path + "</i>, edit the <i> generation settings</i> (tab directory) or the <i>"
                                  + pack->name() + "</i> C++ directory specification</b></font><br>");
                    incr_error();
                }
                else {
                    fputs((const char *) file->data(), fp_src);
                    fclose(fp_src);
                }
            }
            else if (get_trace_header().isEmpty())
                UmlCom::trace(WrapperStr("<font face=helvetica><i> ")
                              + src_path + "</i> not modified</font><br>");
        }
    }
}