示例#1
0
WrapperStr UmlPackage::header_path(const WrapperStr & f)
{
    if (!dir.read) {
        source_path(f);

        if (dir.h.isEmpty()) {
            UmlCom::trace(WrapperStr("<font color=\"red\"><b><b> The generation directory "
                                    "must be specified for the package<i> ") + name()
                          + "</i>, edit the <i> generation settings</i> (tab 'directory') "
                          "or edit the package (tab 'C++')</b></font><br>");
            UmlCom::bye(n_errors() + 1);
            UmlCom::fatal_error("UmlPackage::source_path");
        }

        if (QDir::isRelativePath(dir.h)) {
            UmlCom::trace(WrapperStr("<font color=\"red\"><b><i>")
                          + name() + "</i>'s header path <i>(" + dir.h
                          + "</i>) is not absolute, edit the <i> generation settings</i> "
                          "(tab 'directory'), or edit the package (tab 'C++')</b></font><br>");
            UmlCom::bye(n_errors() + 1);
            UmlCom::fatal_error("UmlPackage::source_path");
        }
    }

    QDir d(dir.h);

    return WrapperStr(d.filePath(f).toLatin1().constData()) + WrapperStr(".") + CppSettings::headerExtension();
}
示例#2
0
int main(int argc, char ** argv)
{
  int port_index;
  bool cpp;
  bool java;
  bool php;
  bool python;
  
  if (argc == 3) {
    port_index = 2;
    cpp = (argv[1][0] == 'c');
    java = (argv[1][0] == 'j');
    php = (argv[1][1] == 'h');
    python = (argv[1][1] == 'y');
  }
  else if (argc == 4) {
    set_verbose();
    cpp = (argv[2][0] == 'c');
    java = (argv[2][0] == 'j');
    php = (argv[2][1] == 'h');
    python = (argv[2][1] == 'y');
    port_index = 3;
  }
  else
    return 0;
  
  if (UmlCom::connect(QCString(argv[port_index]).toUInt())) {
    try {
      UmlCom::trace("<b>Roundtrip body</b> release 1.13<br>");
      UmlCom::traceAutoRaise(FALSE);
      if (cpp) 
	UmlCom::targetItem()->roundtrip_cpp();  
      else if (java)
	UmlCom::targetItem()->roundtrip_java();  
      else if (php)
	UmlCom::targetItem()->roundtrip_php();  
      else if (python)
	UmlCom::targetItem()->roundtrip_python(); 
      
      QCString s;
      
      s.sprintf("<hr><font face=helvetica>Roundtrip done : %d errors</font><br>",
		n_errors());
      UmlCom::trace(s);
    
      UmlCom::showTrace();
      UmlCom::message("");
    
      UmlCom::bye(n_errors());
    }
    catch (...) {
    }
  }
  
  UmlCom::close();
  return 0;
}
示例#3
0
Q3CString UmlPackage::path(const Q3CString & f) {
  if (!read) {
    dir = idlDir();
    
    if (! RootDirRead) {
      RootDirRead = TRUE;
      RootDir = IdlSettings::rootDir();

      if (!RootDir.isEmpty() && // empty -> error
	  QDir::isRelativePath(RootDir)) {
	QFileInfo f(getProject()->supportFile());
	QDir d(f.dirPath());

	RootDir = d.filePath(RootDir);
      }
    }

    QDir d_root(RootDir);
    
    if (dir.isEmpty())
      dir = RootDir;
    else if (QDir::isRelativePath(dir))
      dir = d_root.filePath(dir);

    if (dir.isEmpty()) {
      UmlCom::trace(Q3CString("<font color=\"red\"><b><b> The generation directory "
			    "must be specified for the package<i> ") + name()
			    + "</i>, edit the <i> generation settings</i> (tab 'directory') "
			    "or edit the package (tab 'Idl')</b></font><br>");
      UmlCom::bye(n_errors() + 1);
      UmlCom::fatal_error("UmlPackage::file_path");
    }
    
    if (QDir::isRelativePath(dir)) {
      UmlCom::trace(Q3CString("<font color=\"red\"><b><i>")
		    + name() + "</i>'s source path <i>(" + dir
		    + "</i>) is not absolute, edit the <i> generation settings</i> "
		    "(tab 'directory'), or edit the package (tab 'Idl')</b></font><br>");
      UmlCom::bye(n_errors() + 1);
      UmlCom::fatal_error("UmlPackage::file_path");
    }

    read = TRUE;
  }
  
  QDir d(dir);
  
  if (! d.exists())
    create_directory(dir);	// don't return on error
  
  return Q3CString(d.filePath(f).toAscii().constData()) + Q3CString(".") + 
    IdlSettings::sourceExtension();
}
示例#4
0
static void create_directory(WrapperStr s)
{
    int index = 0;
    QChar sep = QDir::separator(); //[lgfreitas] QChar does not

    if (sep != '/') {
        while ((index = s.find(sep, index)) != -1)
            s.replace(index++, 1, "/");
    }

    s = QDir::cleanPath(s) + "/";
    index = s.find("/");

    int index2;

    while ((index2 = s.find("/", index + 1)) != -1) {
        WrapperStr s2 = s.left(index2);
        QDir sd(s2);

        if (!sd.exists()) {
            if (!sd.mkdir(s2)) {
                UmlCom::trace(WrapperStr("<font color=\"red\"><b> cannot create directory <i>")
                              + s2 + "</i></b></font><br>");
                UmlCom::bye(n_errors() + 1);
                UmlCom::fatal_error("UmlPackage::file_path");
            }
        }

        index = index2;
    }
}
示例#5
0
WrapperStr UmlPackage::source_path(const WrapperStr & f)
{
    if (!dir.read) {
        dir.src = cppSrcDir();
        dir.h = cppHDir();

        QDir d_root(rootDir(cppLanguage));

        if (dir.src.isEmpty())
            dir.src = RootDir;
        else if (QDir::isRelativePath(dir.src))
            dir.src = d_root.filePath(dir.src);

        if (dir.h.isEmpty())
            dir.h = RootDir;
        else if (QDir::isRelativePath(dir.h))
            dir.h = d_root.filePath(dir.h);

        if (dir.src.isEmpty()) {
            UmlCom::trace(WrapperStr("<font color=\"red\"><b><b> The generation directory "
                                    "must be specified for the package<i> ") + name()
                          + "</i>, edit the <i> generation settings</i> (tab 'directory') "
                          "or edit the package (tab 'C++')</b></font><br>");
            UmlCom::bye(n_errors() + 1);
            UmlCom::fatal_error("UmlPackage::source_path");
        }

        dir.read = TRUE;
    }

    QDir d(dir.src);

    return WrapperStr(d.filePath(f).toLatin1().constData()) + WrapperStr(".") + CppSettings::sourceExtension();
}
示例#6
0
int main(int argc, char ** argv)
{
  int port_index;
  
  if (argc == 2)
    port_index = 1;
  else if (argc == 3) {
    if (argv[1][1] == 'v')
      set_verbose();
    else
      set_preserve();
    port_index = 2;
  }
  else if (argc == 4) {
    set_verbose();
    set_preserve();
    port_index = 3;
  }
  else
    return 0;
  
  if (UmlCom::connect(QCString(argv[port_index]).toUInt())) {
    try {
      UmlCom::trace("<b>Php generator</b> release 1.10.1<br>");
      UmlCom::traceAutoRaise(FALSE);
      
      UmlCom::targetItem()->generate();
      
      QCString s;
      
      s.sprintf("<hr><font face=helvetica>Generation done : %d warnings, %d errors</font><br>",
		n_warnings(), n_errors());
      UmlCom::trace(s);

      UmlCom::showTrace();
      UmlCom::message("");
    
      UmlCom::bye(n_errors());
    }
    catch (...) {
    }
  }
  
  UmlCom::close();
  return 0;
}
示例#7
0
文件: main.cpp 项目: harmegnies/douml
int main(int argc, char ** argv)
{
    int port_index;

    if (argc == 2)
        port_index = 1;
    else if (argc == 3) {
        if (argv[1][1] == 'v')
            set_verbose();
        else
            set_preserve();

        port_index = 2;
    }
    else if (argc == 4) {
        set_verbose();
        set_preserve();
        port_index = 3;
    }
    else
        return 0;

    if (UmlCom::connect(WrapperStr(argv[port_index]).operator QString().toUInt())) {
        try {
            UmlCom::trace("<b>Java generator</b> release 2.22<br>");
            UmlCom::traceAutoRaise(FALSE);

            UmlCom::targetItem()->generate();

            QString s("<hr><font face=helvetica>Generation done : %1 warnings, %2 errors</font><br>");
            s=s.arg(QString::number(n_warnings())).arg(QString::number(n_errors()));
            UmlCom::trace(s);

            UmlCom::showTrace();
            UmlCom::message("");

            UmlCom::bye(n_errors());
        }
        catch (...) {
        }
    }

    UmlCom::close();
    return 0;
}
示例#8
0
WrapperStr UmlPackage::source_path(const WrapperStr & f, WrapperStr relto)
{
    if (!dir.read) {
        dir.src = cppSrcDir();
        dir.h = cppHDir();
        dir.src_absolute = dir.h_absolute = FALSE;

        QDir d_root(rootDir());

        if (dir.src.isEmpty())
            // considered given relative
            dir.src = RootDir;
        else if (QDir::isRelativePath(dir.src))
            dir.src = d_root.filePath(dir.src);
        else
            dir.src_absolute = TRUE;

        if (dir.h.isEmpty())
            // considered given relative
            dir.h = RootDir;
        else if (QDir::isRelativePath(dir.h))
            dir.h = d_root.filePath(dir.h);
        else
            dir.h_absolute = TRUE;

        if (dir.src.isEmpty()) {
            UmlCom::trace(WrapperStr("<font color=\"red\"><b><b> The generation directory "
                                    "must be specified for the package<i> ") + name()
                          + "</i>, edit the <i> generation settings</i> (tab 'directory') "
                          "or edit the package (tab 'C++')</b></font><br>");
            UmlCom::bye(n_errors() + 1);
            UmlCom::fatal_error("UmlPackage::source_path");
        }

        dir.read = TRUE;
    }

    if (f.isEmpty())
        return dir.src;

    QDir d(dir.src);

    if (! d.exists())
        create_directory(dir.src);	// don't return on error

    QByteArray temp = d.filePath(f).toLatin1();
    WrapperStr df = (dir.src_absolute || relto.isEmpty())
                   ? WrapperStr(temp.constData())
                   : relative_path(d, relto) + f;

    return df + WrapperStr(".") + CppSettings::sourceExtension();
}
示例#9
0
WrapperStr UmlPackage::header_path(const WrapperStr & f, WrapperStr relto)
{
    if (!dir.read) {
        source_path(f);

        if (dir.h.isEmpty()) {
            UmlCom::trace(WrapperStr("<font color=\"red\"><b><b> The generation directory "
                                    "must be specified for the package<i> ") + name()
                          + "</i>, edit the <i> generation settings</i> (tab 'directory') "
                          "or edit the package (tab 'C++')</b></font><br>");
            UmlCom::bye(n_errors() + 1);
            UmlCom::fatal_error("UmlPackage::source_path");
        }

        if (QDir::isRelativePath(dir.h)) {
            UmlCom::trace(WrapperStr("<font color=\"red\"><b><i>")
                          + name() + "</i>'s header path <i>(" + dir.h
                          + "</i>) is not absolute, edit the <i> generation settings</i> "
                          "(tab 'directory'), or edit the package (tab 'C++')</b></font><br>");
            UmlCom::bye(n_errors() + 1);
            UmlCom::fatal_error("UmlPackage::source_path");
        }
    }

    if (f.isEmpty())
        return dir.h;

    QDir d(dir.h);

    if (! d.exists())
        create_directory(dir.h);	// don't return on error
    QByteArray temp = d.filePath(f).toLatin1();

    WrapperStr df = (dir.h_absolute || relto.isEmpty())
                   ? WrapperStr(temp.constData())
                   : relative_path(d, relto) + f;

    return df + WrapperStr(".") + CppSettings::headerExtension();
}
示例#10
0
文件: main.cpp 项目: SciBoy/douml
int main(int argc, char ** argv)
{
  int port_index;
  
  if (argc == 2)
    port_index = 1;
  else if (argc == 3) {
    set_verbose();
    port_index = 2;
  }
  else
    return 0;
  
  if (UmlCom::connect(Q3CString(argv[port_index]).toUInt())) {
    try {
      UmlCom::trace("<b>IDL generator</b> release 2.15<br>");
      
      UmlCom::targetItem()->generate();
      
      Q3CString s;
      
      s.sprintf("<hr><font face=helvetica>Generation done : %d warnings, %d errors</font><br>",
		n_warnings(), n_errors());
      UmlCom::trace(s);
      
      UmlCom::message("");
    
      UmlCom::bye(n_errors());
    }
    catch (...) {
    }
  }
  
  UmlCom::close();
  return 0;
}
示例#11
0
bool datalog_definition::err_elements_exist(byte patchlvl) {
  if(n_errors(patchlvl) == 0) return false;
  return true;
}
示例#12
0
static void read_bodies(const char * path, Q3IntDict<char> & bodies)
{
    char * s = read_file(path);

    if (s != 0) {
        char * p1 = s;
        char * p2;

        while ((p2 = strstr(p1, BodyPrefix)) != 0) {
            p2 += BodyPrefixLength;

            char * body;
            long id = strtol(p2, &body, 16);

            if (body != (p2 + 8)) {
                UmlCom::trace(WrapperStr("<font color =\"red\"> Error in ") + path +
                              " : invalid preserve body identifier</font><br>");
                UmlCom::bye(n_errors() + 1);
                UmlCom::fatal_error("read_bodies 1");
            }

            if (bodies.find(id) != 0) {
                UmlCom::trace(WrapperStr("<font  color =\"red\"> Error in ") + path +
                              " : preserve body identifier used twice</font><br>");
                UmlCom::bye(n_errors() + 1);
                UmlCom::fatal_error("read_bodies 2");
            }

            if (*body == '\r')
                body += 1;

            if (*body == '\n')
                body += 1;
            else {
                UmlCom::trace(WrapperStr("<font  color =\"red\"> Error in ") + path +
                              " : invalid preserve body block, end of line expected</font><br>");
                UmlCom::bye(n_errors() + 1);
                UmlCom::fatal_error("read_bodies 3");
            }

            if (((p1 = strstr(body, BodyPostfix)) == 0) ||
                (strncmp(p1 + BodyPostfixLength, p2, 8) != 0)) {
                UmlCom::trace(WrapperStr("<font  color =\"red\"> Error in ") + path +
                              " : invalid preserve body block, wrong balanced</font><br>");
                UmlCom::bye(n_errors() + 1);
                UmlCom::fatal_error("read_bodies 4");
            }

            p2 = p1;

            while ((p2 != body) && (p2[-1] != '\n'))
                p2 -= 1;

            *p2 = 0;

            int len = p2 - body + 1;
            char * b = new char[len];

            memcpy(b, body, len);
            bodies.insert(id, b);

            p1 += BodyPostfixLength + 8;
        }

        delete [] s;
    }
}
示例#13
0
QCString UmlPackage::file_path(const QCString & f) {
  if (!dir.read) {
    dir.file = pythonDir();
    
    if (! RootDirRead) {
      RootDirRead = TRUE;
      RootDir = PythonSettings::rootDir();

      if (!RootDir.isEmpty() && // empty -> error
	  QDir::isRelativePath(RootDir)) {
	QFileInfo f(getProject()->supportFile());
	QDir d(f.dirPath());

	RootDir = d.filePath(RootDir);
      }
    }

    QDir d_root(RootDir);
    
    if (dir.file.isEmpty())
      dir.file = RootDir;
    else if (QDir::isRelativePath(dir.file))
      dir.file = d_root.filePath(dir.file);
   
    if (dir.file.isEmpty()) {
      UmlCom::trace(QCString("<font color=\"red\"><b><b> The generation directory "
			    "must be specified for the package<i> ") + name()
			    + "</i>, edit the <i> generation settings</i> (tab 'directory') "
			    "or edit the package (tab 'Python')</b></font><br>");
      UmlCom::bye(n_errors() + 1);
      UmlCom::fatal_error("UmlPackage::file_path");
    }
    
    dir.read = TRUE;
  }
  
  QDir d(dir.file);
  
  if (! d.exists()) {
    // create directory including the intermediates
    QCString s = dir.file;
    int index = 0;
    char sep = QDir::separator();
    
    if (sep != '/') {
      while ((index = s.find(sep, index)) != -1)
	s.replace(index++, 1, "/");
    }
    
    s = QDir::cleanDirPath(s) + "/";
    index = s.find("/");

    int index2;
    
    while ((index2 = s.find("/", index + 1)) != -1) {
      QCString s2 = s.left(index2);
      QDir sd(s2);
      
      if (!sd.exists()) {
	if (!sd.mkdir(s2)) {
	  UmlCom::trace(QCString("<font color=\"red\"><b> cannot create directory <i>")
			+ s2 + "</i></b></font><br>");
	  UmlCom::bye(n_errors() + 1);
	  UmlCom::fatal_error("UmlPackage::file_path");
	}
      }
      index = index2;
    }
  }
  
  return QCString(d.filePath(f)) + QCString(".") + 
    PythonSettings::sourceExtension();
}
示例#14
0
int main(int argc, char ** argv)
{
#ifdef DEBUG
    QsLogging::Logger & logger = QsLogging::Logger::instance();
    logger.setLoggingLevel(QsLogging::TraceLevel);
    QDir dir;
    dir.setPath(qApp->applicationDirPath());
    dir.remove(QString("cpp_utils") + QString(".log"));
    const QString sLogPath(QDir(qApp->applicationDirPath()).filePath(QString("cpp_generator") + QString(".log")));
    QsLogging::DestinationPtr fileDestination(QsLogging::DestinationFactory::MakeFileDestination(sLogPath));
    QsLogging::DestinationPtr debugDestination(QsLogging::DestinationFactory::MakeDebugOutputDestination());
    logger.addDestination(debugDestination.get());
    logger.addDestination(fileDestination.get());

    QSettings settings(QSettings::IniFormat, QSettings::UserScope, "DoUML", "settings");
    settings.setIniCodec(QTextCodec::codecForName("UTF-8"));
    QString locale = settings.value("Main/encoding").toString();
    QTextCodec* codec = QTextCodec::codecForName(locale.toLatin1().constData());
    QTextCodec::setCodecForLocale(codec);

    QLOG_INFO() << " STARTING CPP_GENERATOR";

#endif
    //QTest::qSleep(7000);
    int port_index;
#ifndef _RUN_PLUGOUT_EXTERNAL_
    if (argc == 2) {
        port_index = 1;
        QLOG_INFO() << "Got two arguments from Douml as argv";
        QLOG_INFO() << "Using first port index mode";
    }
    else if (argc == 3) {
        QLOG_INFO() << "Got three arguments from Douml as argv";
        if (argv[1][1] == 'v') {
            QLOG_INFO() << "Using verbose mode";
            set_verbose();
        }
        else {
            QLOG_INFO() << "Using preserve mode";
            set_preserve();
        }
        QLOG_INFO() << "Using second port index mode";
        port_index = 2;
    }
    else if (argc == 4) {
        QLOG_INFO() << "Got four arguments from Douml as argv";
        QLOG_INFO() << "Using preserve mode";
        QLOG_INFO() << "Using verbose mode";
        QLOG_INFO() << "Using third port index mode";
        set_verbose();
        set_preserve();
        port_index = 3;
    }
    else {
        QLOG_INFO() << "Got too little or too much arguments from Douml, exiting";
        return 0;
    }
    if (UmlCom::connect(QString(argv[port_index]).toUInt())) {
#else
    port_index = 1;
    if (UmlCom::connect(5000)) {
#endif
        try {

            UmlCom::trace("<b>C++ generator</b> release 2.18<br>");
            UmlCom::traceAutoRaise(FALSE);
            UmlCom::targetItem()->generate();

            QString s;

            s = "<hr><font face=helvetica>Generation done : %1 warnings, %2 errors</font><br>";
            s=s.arg(QString::number(n_warnings())).arg(QString::number(n_errors()));

            UmlCom::trace(s.toLatin1().constData());

            UmlCom::showTrace();
            UmlCom::message("");

            UmlCom::bye(n_errors());
        }
        catch (...) {
            QLOG_INFO() << "unhandled exception caught";
        }
    }

    UmlCom::close();
    return 0;
}
示例#15
0
void UmlOperation::roundtrip(const char * path, aLanguage who)
{
    char * s = read_file(path);

    if (s != 0) {
        char * p1 = s;
        char * p2;
        WrapperStr(UmlOperation::*get_body)();
        bool (UmlOperation::*set_body)(const char * s);
        bool (UmlOperation::*set_contextualbodyindent)(bool v);
        const char * prefix;
        const char * postfix;

        switch (who) {
        case cppLanguage:
            get_body = &UmlOperation::cppBody;
            set_body = &UmlOperation::set_CppBody;
            set_contextualbodyindent = &UmlOperation::set_CppContextualBodyIndent;
            prefix = BodyPrefix;
            postfix = BodyPostfix;
            break;

        case javaLanguage:
            get_body = &UmlOperation::javaBody;
            set_body = &UmlOperation::set_JavaBody;
            set_contextualbodyindent = &UmlOperation::set_JavaContextualBodyIndent;
            prefix = BodyPrefix;
            postfix = BodyPostfix;
            break;

        case phpLanguage:
            get_body = &UmlOperation::phpBody;
            set_body = &UmlOperation::set_PhpBody;
            set_contextualbodyindent = &UmlOperation::set_PhpContextualBodyIndent;
            prefix = BodyPrefix;
            postfix = BodyPostfix;
            break;

        default:
            // python
            get_body = &UmlOperation::pythonBody;
            set_body = &UmlOperation::set_PythonBody;
            set_contextualbodyindent = &UmlOperation::set_PythonContextualBodyIndent;
            prefix = BodyPythonPrefix;
            postfix = BodyPythonPostfix;
        }

        while ((p2 = strstr(p1, prefix)) != 0) {
            p2 += BodyPrefixLength;

            char * body;
            long id = strtol(p2, &body, 16);

            if (body != (p2 + 8)) {
                UmlCom::trace(WrapperStr("<font color =\"red\"> Error in ") + path +
                              linenumber(s, p2 - BodyPrefixLength) +
                              " : invalid preserve body identifier</font><br>");
                UmlCom::bye(n_errors() + 1);
                UmlCom::fatal_error("read_bodies 1");
            }

            if (*body == '\r')
                body += 1;

            if (*body == '\n')
                body += 1;
            else {
                UmlCom::trace(WrapperStr("<font  color =\"red\"> Error in ") + path +
                              linenumber(s, p2 - BodyPrefixLength) +
                              " : invalid preserve body block, end of line expected</font><br>");
                UmlCom::bye(n_errors() + 1);
                UmlCom::fatal_error("read_bodies 2");
            }

            UmlOperation * op = (UmlOperation *)
                                UmlBaseItem::from_id((unsigned) id, anOperation);

            if (op == 0) {
                QString n("%1");
                n.arg(QString::number((unsigned) id));
                UmlCom::trace(WrapperStr("<font  color =\"red\"> Error in ") + path +
                              linenumber(s, p2 - BodyPrefixLength) +
                              " : invalid operation id " + n + "</font><br>");
                UmlCom::bye(n_errors() + 1);
                UmlCom::fatal_error("read_bodies 3");
                return;
            }

            if (((p1 = strstr(body, postfix)) == 0) ||
                (strncmp(p1 + BodyPostfixLength, p2, 8) != 0)) {
                UmlCom::trace(WrapperStr("<font  color =\"red\"> Error in ") + path +
                              linenumber(s, p2 - BodyPrefixLength) +
                              " : invalid preserve body block, wrong balanced</font><br>");
                UmlCom::bye(n_errors() + 1);
                UmlCom::fatal_error("read_bodies 4");
            }

            p2 = p1;

            while ((p2 != body) && (p2[-1] != '\n'))
                p2 -= 1;

            char c = *p2;

            *p2 = 0;

            WrapperStr previous = (op->*get_body)();

            if (!op->isBodyGenerationForced() && (body != previous)) {
                if (!(op->*set_body)(body)) {
                    write_trace_header();
                    UmlCom::trace("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b>cannot update body of <i>"
                                  + op->name() +
                                  ((op->isWritable()) ? "</i>, it is probably deleted</b></font><br>"
                                   : "</i>, it is read-only</b></font><br>"));
                    incr_error();
                }
                else {
                    (op->*set_contextualbodyindent)(FALSE);

                    write_trace_header();
                    UmlCom::trace("&nbsp;&nbsp;&nbsp;&nbsp;update body of <i>"
                                  + op->name() + "</i><br>");
                }
            }
            else if (verbose()) {
                write_trace_header();
                UmlCom::trace("&nbsp;&nbsp;&nbsp;&nbsp;body of <i>"
                              + op->name() + "</i> unchanged<br>");
            }

            *p2 = c;
            p1 += BodyPostfixLength + 8;
        }

        delete [] s;
    }
}
示例#16
0
Q3CString UmlPackage::file_path(const Q3CString & f, Q3CString relto) {
  if (!dir.read) {
    dir.file = phpDir();
    dir.file_absolute = FALSE;
    
    QDir d_root(rootDir());
    
    if (dir.file.isEmpty())
      dir.file = RootDir;
    else if (QDir::isRelativePath(dir.file))
      dir.file = d_root.filePath(dir.file);
    else
      dir.file_absolute = TRUE;
   
    if (dir.file.isEmpty()) {
      UmlCom::trace(Q3CString("<font color=\"red\"><b><b> The generation directory "
			    "must be specified for the package<i> ") + name()
			    + "</i>, edit the <i> generation settings</i> (tab 'directory') "
			    "or edit the package (tab 'Php')</b></font><br>");
      UmlCom::bye(n_errors() + 1);
      UmlCom::fatal_error("UmlPackage::file_path");
    }
    
    dir.read = TRUE;
  }
  
  if (f.isEmpty())
    return dir.file;
  
  QDir d(dir.file);
  
  if (! d.exists()) {
    // create directory including the intermediates
    Q3CString s = dir.file;
    int index = 0;
    QChar sep = QDir::separator();
    
    if (sep != '/') {
      while ((index = s.find(sep, index)) != -1)
	s.replace(index++, 1, "/");
    }
    
    s = QDir::cleanDirPath(s) + "/";
    index = s.find("/");

    int index2;
    
    while ((index2 = s.find("/", index + 1)) != -1) {
      Q3CString s2 = s.left(index2);
      QDir sd(s2);
      
      if (!sd.exists()) {
	if (!sd.mkdir(s2)) {
	  UmlCom::trace(Q3CString("<font color=\"red\"><b> cannot create directory <i>")
			+ s2 + "</i></b></font><br>");
	  UmlCom::bye(n_errors() + 1);
	  UmlCom::fatal_error("UmlPackage::file_path");
	}
      }
      index = index2;
    }
  }
  
  Q3CString df = (dir.file_absolute || relto.isEmpty())
    ? Q3CString(d.filePath(f).toAscii().constData())
    : relative_path(d, relto) + f;
  
  if (PhpSettings::isRelativePath() && (df[0] != '/') && (df[0] != '.'))
    df = "./" + df;
  
  return df + Q3CString(".") + PhpSettings::sourceExtension();
}