void tst_Q3CString::replace_string_data() { QTest::addColumn<Q3CString>("string"); QTest::addColumn<Q3CString>("before"); QTest::addColumn<Q3CString>("after"); QTest::addColumn<Q3CString>("result"); QTest::newRow( "rem00" ) << Q3CString("") << Q3CString("") << Q3CString("") << Q3CString(""); QTest::newRow( "rem01" ) << Q3CString("A") << Q3CString("") << Q3CString("") << Q3CString("A"); QTest::newRow( "rem02" ) << Q3CString("A") << Q3CString("A") << Q3CString("") << Q3CString(""); QTest::newRow( "rem03" ) << Q3CString("A") << Q3CString("B") << Q3CString("") << Q3CString("A"); QTest::newRow( "rem04" ) << Q3CString("AA") << Q3CString("A") << Q3CString("") << Q3CString(""); QTest::newRow( "rem05" ) << Q3CString("AB") << Q3CString("A") << Q3CString("") << Q3CString("B"); QTest::newRow( "rem06" ) << Q3CString("AB") << Q3CString("B") << Q3CString("") << Q3CString("A"); QTest::newRow( "rem07" ) << Q3CString("AB") << Q3CString("C") << Q3CString("") << Q3CString("AB"); QTest::newRow( "rem08" ) << Q3CString("ABA") << Q3CString("A") << Q3CString("") << Q3CString("B"); QTest::newRow( "rem09" ) << Q3CString("ABA") << Q3CString("B") << Q3CString("") << Q3CString("AA"); QTest::newRow( "rem10" ) << Q3CString("ABA") << Q3CString("C") << Q3CString("") << Q3CString("ABA"); QTest::newRow( "rem11" ) << Q3CString("banana") << Q3CString("an") << Q3CString("") << Q3CString("ba"); QTest::newRow( "rem12" ) << Q3CString("") << Q3CString("A") << Q3CString("") << Q3CString(""); QTest::newRow( "rem13" ) << Q3CString("") << Q3CString("A") << Q3CString(0) << Q3CString(""); QTest::newRow( "rem14" ) << Q3CString(0) << Q3CString("A") << Q3CString("") << Q3CString(0); QTest::newRow( "rem15" ) << Q3CString(0) << Q3CString("A") << Q3CString(0) << Q3CString(0); QTest::newRow( "rem17" ) << Q3CString(0) << Q3CString("") << Q3CString("") << Q3CString(0); // ### how should the one below behave in Q3CString???? // QTest::newRow( "rem18" ) << Q3CString("") << Q3CString(0) << Q3CString("A") << Q3CString("A"); QTest::newRow( "rem19" ) << Q3CString("") << Q3CString(0) << Q3CString("") << Q3CString(""); QTest::newRow( "rep00" ) << Q3CString("ABC") << Q3CString("B") << Q3CString("-") << Q3CString("A-C"); QTest::newRow( "rep01" ) << Q3CString("$()*+.?[\\]^{|}") << Q3CString("$()*+.?[\\]^{|}") << Q3CString("X") << Q3CString("X"); QTest::newRow( "rep02" ) << Q3CString("ABCDEF") << Q3CString("") << Q3CString("X") << Q3CString("XAXBXCXDXEXFX"); QTest::newRow( "rep03" ) << Q3CString("") << Q3CString("") << Q3CString("X") << Q3CString("X"); }
void tst_Q3CString::length_data() { QTest::addColumn<Q3CString>("s1"); QTest::addColumn<int>("res"); QTest::newRow( "data0" ) << Q3CString("Test") << 4; QTest::newRow( "data1" ) << Q3CString("The quick brown fox jumps over the lazy dog") << 43; QTest::newRow( "data2" ) << Q3CString(0) << 0; QTest::newRow( "data3" ) << Q3CString("A") << 1; QTest::newRow( "data4" ) << Q3CString("AB") << 2; QTest::newRow( "data5" ) << Q3CString("AB\n") << 3; QTest::newRow( "data6" ) << Q3CString("AB\nC") << 4; QTest::newRow( "data7" ) << Q3CString("\n") << 1; QTest::newRow( "data8" ) << Q3CString("\nA") << 2; QTest::newRow( "data9" ) << Q3CString("\nAB") << 3; QTest::newRow( "data10" ) << Q3CString("\nAB\nCDE") << 7; QTest::newRow( "data11" ) << Q3CString("shdnftrheid fhgnt gjvnfmd chfugkh bnfhg thgjf vnghturkf chfnguh bjgnfhvygh hnbhgutjfv dhdnjds dcjs d") << 100; }
void tst_Q3CString::replace_uint_uint_data() { QTest::addColumn<Q3CString>("string"); QTest::addColumn<int>("index"); QTest::addColumn<int>("len"); QTest::addColumn<Q3CString>("after"); QTest::addColumn<Q3CString>("result"); QTest::newRow( "rem00" ) << Q3CString("-<>ABCABCABCABC>") << 0 << 3 << Q3CString("") << Q3CString("ABCABCABCABC>"); QTest::newRow( "rem01" ) << Q3CString("ABCABCABCABC>") << 1 << 4 <<Q3CString("") <<Q3CString("ACABCABC>"); QTest::newRow( "rem02" ) << Q3CString("ACABCABC>") << 999 << 4 << Q3CString("") << Q3CString("ACABCABC>"); QTest::newRow( "rem03" ) << Q3CString("ACABCABC>") << 9 << 4 << Q3CString("") << Q3CString("ACABCABC>"); QTest::newRow( "rem04" ) << Q3CString("ACABCABC>") << 8 << 4 << Q3CString("") << Q3CString("ACABCABC"); QTest::newRow( "rem05" ) << Q3CString("ACABCABC") << 7 << 1 << Q3CString("") << Q3CString("ACABCAB"); QTest::newRow( "rem06" ) << Q3CString("ACABCAB") << 4 << 0 << Q3CString("") << Q3CString("ACABCAB"); QTest::newRow( "rep00" ) << Q3CString("ACABCAB") << 4 << 0 << Q3CString("X") << Q3CString("ACABXCAB"); QTest::newRow( "rep01" ) << Q3CString("ACABXCAB") << 4 << 1 << Q3CString("Y") << Q3CString("ACABYCAB"); QTest::newRow( "rep02" ) << Q3CString("ACABYCAB") << 4 << 1 << Q3CString("") << Q3CString("ACABCAB"); QTest::newRow( "rep03" ) << Q3CString("ACABCAB") << 0 << 9999 << Q3CString("XX") << Q3CString("XX"); QTest::newRow( "rep04" ) << Q3CString("XX") << 0 << 9999 << Q3CString("") << Q3CString(""); }
void UmlRelation::generate_inherit(const char *& sep, QTextOStream & f, const Q3CString & cl_stereotype, BooL & already) { if ((relationKind() == aGeneralisation) || (relationKind() == aRealization)) { UmlClass * role_type = roleType(); Q3CString other_stereotype = role_type->idl_stereotype(); if (other_stereotype == "ignored") return; if ((cl_stereotype == "union") || (cl_stereotype == "enum")) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>an <i>") + cl_stereotype + "</i> cannot inherits</b></font><br>"); incr_warning(); return; } if ((other_stereotype == "union") || (other_stereotype == "struct") || (other_stereotype == "enum") || (other_stereotype == "typedef")) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>cannot inherits an <i>") + other_stereotype + "</i></b></font><br>"); incr_warning(); return; } if (cl_stereotype == "valuetype") { if (other_stereotype == "valuetype") { if (isIdlTruncatableInheritance()) f << sep << "truncatable "; else f << sep; } else { // other_stereotype == "interface" if (!already) { already = TRUE; f << " supports "; } else f << sep; } } else f << sep; const char * p = idlDecl(); while (*p) { if (!strncmp(p, "${type}", 7)) { role_type->write(f); p += 7; } else if (*p == '@') manage_alias(p, f); else f << *p++; } sep = ", "; } }
void UmlRelation::generate_inherit(const char *& sep, QTextOStream & f_h, const Q3ValueList<UmlActualParameter> & actuals, const Q3CString & cl_stereotype) { switch (relationKind()) { default: break; case aGeneralisation: case aRealization: if ((cl_stereotype == "union") || (cl_stereotype == "enum")) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>an <i>") + cl_stereotype + "</i> cannot inherits</b></font><br>"); incr_warning(); return; } else if (cl_stereotype == "typedef") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>a <i>typedef</i> cannot inherits</b></font><br>"); incr_warning(); return; } UmlClass * role_type = roleType(); const Q3CString & other_stereotype = role_type->stereotype(); if ((other_stereotype == "union") || (other_stereotype == "enum")) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>cannot inherits an <i>") + other_stereotype + "</i></b></font><br>"); incr_warning(); return; } f_h << sep; sep = ", "; if (cppVirtualInheritance()) f_h << "virtual "; aVisibility visibility = (cppVisibility() == DefaultVisibility) ? this->visibility() : cppVisibility(); switch (visibility) { case PublicVisibility: case PackageVisibility: f_h << "public "; break; case ProtectedVisibility: f_h << "protected "; break; default: f_h << "private "; } const char * p = cppDecl(); while (*p) { if (!strncmp(p, "${type}", 7)) { role_type->write(f_h, FALSE, 0, actuals); p += 7; } else if (*p == '@') manage_alias(p, f_h); else f_h << *p++; } } }
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(Q3CString("<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(Q3CString("<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(Q3CString("<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(Q3CString("<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; } }
void UmlRelation::generate_decl(QTextOStream & f, const Q3CString & cl_stereotype, Q3CString indent, bool) { if ((relationKind() != aGeneralisation) && (relationKind() != aRealization) && (relationKind() != aDependency)) { if (cl_stereotype == "enum") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>an <i>enum</i> cannot have relation</b></font><br>"); incr_warning(); return; } if (cl_stereotype == "typedef") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>a <i>typedef</i> cannot have relation</b></font><br>"); incr_warning(); return; } if (!idlDecl().isEmpty()) { const char * p = idlDecl(); const char * pp = 0; Q3CString s; while ((*p == ' ') || (*p == '\t')) indent += *p++; if (*p != '#') f << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; if (*p != '#') f << indent; } if (*p == '\n') { f << *p++; if (*p && (*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); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${readonly}", 11)) { p += 11; if (isReadOnly()) f << "readonly "; } else if (!strncmp(p, "${attribut}", 11)) { // old version p += 11; if (cl_stereotype == "interface") f << "attribute "; } else if (!strncmp(p, "${attribute}", 12)) { p += 12; if (cl_stereotype == "interface") f << "attribute "; } else if (!strncmp(p, "${visibility}", 13)) { p += 13; if (cl_stereotype == "valuetype") { switch (visibility()) { case PublicVisibility: case PackageVisibility: f << "public "; break; default: f << "private "; } } } else if (!strncmp(p, "${case}", 7)) { p += 7; Q3CString idl_case = idlCase(); if (idl_case.isEmpty()) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>unspecified <i>case</i> for <i>") + name() + "</b></font><br>"); incr_error(); } else f << idlCase(); } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(f); } 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, "${stereotype}", 13)) { p += 13; f << IdlSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; f << multiplicity(); } else if (!strncmp(p, "${association}", 14)) { p += 14; f << IdlSettings::type(association().toString()); } else // strange f << *p++; } f << '\n'; } } }
Q3CString UmlPackage::file_path(const Q3CString & f) { if (!dir.read) { dir.file = javaDir(); if (! RootDirRead) { RootDirRead = TRUE; RootDir = JavaSettings::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(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 'Java')</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 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; } } return Q3CString(d.filePath(f).toAscii().constData()) + Q3CString(".") + JavaSettings::sourceExtension(); }
void UmlRelation::generate_extends(const char *& sep, QTextStream & f, const Q3CString & cl_stereotype) { switch (relationKind()) { default: return; case aGeneralisation: case aRealization: if (phpDecl().isEmpty()) return; UmlClass * role_type = roleType(); const Q3CString & other_stereotype = role_type->php_stereotype(); if ((cl_stereotype == "interface") || (cl_stereotype == "@interface")) { if ((other_stereotype != "interface") && (other_stereotype != "@interface")) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>cannot extends a <i>") + other_stereotype + "</i></b></font><br>"); incr_warning(); return; } } else if ((other_stereotype != "interface") && (other_stereotype != "@interface")) { if (cl_stereotype == "union") { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>an <i>") + cl_stereotype + "</i> cannot extends</b></font><br>"); incr_warning(); return; } else if ((other_stereotype == "union") || (other_stereotype == "enum")) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>cannot extends an <i>") + other_stereotype + "</i></b></font><br>"); incr_warning(); return; } else if (*sep == ',') { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>extend several classes</b></font><br>"); incr_warning(); return; } } else return; // here the code is legal f << sep; sep = ", "; const char * p = phpDecl(); while (*p) { if (!strncmp(p, "${type}", 7)) { role_type->write(f); p += 7; } else if (*p == '@') manage_alias(p, f); else f << *p++; } } }
void UmlArtifact::generate() { if (! managed) { managed = TRUE; if (stereotype() == "text") { generate_text(); return; } else if (stereotype() != "source") return; package_of_generated_artifact = package(); current = this; const Q3CString filedef = javaSource(); if (filedef.isEmpty()) return; const Q3CString & name = this->name(); Q3CString path = package_of_generated_artifact->file_path(name); UmlCom::message(name); if (verbose()) UmlCom::trace(Q3CString("<hr><font face=helvetica>Generate code for <i> ") + name + "</i> in " + path + "</i></font><br>"); else set_trace_header(Q3CString("<font face=helvetica>Generate code for <i> ") + name + "</i> in " + path + "</i></font><br>"); // get bodies if preserve const Q3PtrVector<UmlClass> & cls = associatedClasses(); if (preserve()) UmlOperation::read_bodies(path); // generate file unsigned n = cls.count(); unsigned index; Q3CString incl; QByteArray file; // note : QTextOStream(FILE *) does not work under windows QTextOStream f(&file); // [lgfreitas] it expects a pointer to a byte array... const char * p = filedef; 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, JavaSettings::isGenerateJavadocStyleComment()); 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, "${imports}", 10)) { Q3CString indent = current_indent(p, filedef); for (index = 0; index != n; index += 1) cls[index]->generate_import(f, indent); p += 10; if (*p == '\n') p += 1; } else if (!strncmp(p, "${package}", 10)) { p += 10; const Q3CString & package = package_of_generated_artifact->javaPackage(); if (!package.isEmpty()) f << "package " << package << ";\n\n"; if (*p == '\n') p += 1; } else if (!strncmp(p, "${definition}", 13)) { Q3CString indent = current_indent(p, filedef); for (index = 0; index != n; index += 1) cls[index]->generate(f, indent); p += 13; 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>" + package_of_generated_artifact->name() + "</i> Java 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>"); if (imports != 0) { delete imports; imports = 0; } } }
void Statistic::produce() { UmlCom::trace(Q3CString("<br><hr><br><font face=helvetica>Php reverse done</font><br><br>") + Q3CString("<font face=helvetica> ") + Q3CString().setNum(n_classes) + Q3CString(" classes </font><br>") + Q3CString("<font face=helvetica> ") + Q3CString().setNum(n_attributes) + Q3CString(" attributes </font><br>") + Q3CString("<font face=helvetica> ") + Q3CString().setNum(n_relations) + " relations </font><br>" + Q3CString("<font face=helvetica> ") + Q3CString().setNum(n_operations) + " operations </font><br><hr><br>"); }
static Q3CString relative_path(const QDir & destdir, Q3CString relto) { QDir fromdir(relto); Q3CString from = Q3CString(fromdir.absPath().toAscii().constData()); Q3CString to = Q3CString(destdir.absPath().toAscii().constData()); const char * cfrom = from; const char * cto = to; int lastsep = -1; int index = 0; for (;;) { char f = cfrom[index]; char t = cto[index]; if (f == 0) { switch (t) { case 0: // same path return ""; case '/': // to = .../aze/qsd/wxc, from = .../aze => qsd/wxc/ return (cto + index + 1) + Q3CString("/"); default: // to = .../aze/qsd/wxc, from = .../az => ../aze/qsd/wxc/ return "../" + Q3CString(cto + lastsep + 1) + "/"; } } else if (t == f) { if (t == '/') lastsep = index; index += 1; } else if (t == 0) { Q3CString r; const char * p = cfrom+index; do { if (*p == '/') r += "../"; } while (*++p != 0); if (f == '/') // to = .../aze, from = .../aze/qsd/wxc => ../../ return r; else // to = .../az, from = .../aze/qsd/wxc => ../../../az/ return ("../" + r + (cto + lastsep + 1)) + "/"; } else { // to = .../aze, from = .../iop/klm => ../../aze/ Q3CString r = "../"; const char * p = cfrom + lastsep + 1; while (*p != 0) if (*p++ == '/') r += "../"; return (r + (cto + lastsep + 1)) + "/"; } } }
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(); }
int main(int argc, char ** argv) { if (argc != 2) return 0; if (UmlCom::connect(Q3CString(argv[1]).toUInt())) { try { //UmlCom::with_ack(FALSE); UmlCom::trace("<b>Php reverse</b> release 1.8.1<br><hr>"); UmlCom::traceAutoRaise(FALSE); UmlItem * item = UmlCom::targetItem(); if (item->kind() != aPackage) UmlCom::trace("<font face=helvetica><b>must be applied on a <i>package</i></b></font><br><hr><br>"); else { char * argv = 0; int argc = 0; QApplication * app = new QApplication(argc, &argv); Package::init((UmlPackage *) item, app); QString here = QDir::currentDirPath(); /* QString path; QFile fp(QDir::home().absFilePath(".boumlcat")); if (fp.open(IO_ReadOnly)) { QTextStream ts(&fp); path = ts.readLine(); fp.close(); } while (!(path = QFileDialog::getOpenFileName(path, "*.cat", 0, 0, "select a php catalog file to read it, or cancel")) .isEmpty()) { QFile f(path); if (f.open(IO_ReadOnly)) { if (fp.open(IO_WriteOnly)) { QTextStream ts(&fp); ts.writeRawBytes((const char *) path, path.length()); ts.writeRawBytes("\n", 1); } QDataStream dt(&f); Package::get_root()->restore_children(dt); } } */ QDir::setCurrent(here); Package * p = Package::scan_dir(); if (p != 0) { PhpSettings::set_UseDefaults(TRUE); p->send_dir(TRUE); Statistic::produce(); } } } catch (...) { } try { // socket may be already closed UmlCom::message(""); UmlCom::showTrace(); UmlCom::bye(0); // application must not be deleted } catch (...) { } } UmlCom::close(); // application must not be deleted return 0; }
void tst_Q3CString::remove_regexp_data() { QTest::addColumn<Q3CString>("string"); QTest::addColumn<Q3CString>("regexp"); QTest::addColumn<Q3CString>("after"); QTest::addColumn<Q3CString>("result"); QTest::newRow( "rem00" ) << Q3CString("alpha") << Q3CString("a+") << Q3CString("") << Q3CString("lph"); QTest::newRow( "rem01" ) << Q3CString("banana") << Q3CString("^.a") << Q3CString("") << Q3CString("nana"); QTest::newRow( "rem02" ) << Q3CString("") << Q3CString("^.a") << Q3CString("") << Q3CString(""); QTest::newRow( "rem03" ) << Q3CString("") << Q3CString("^.a") << Q3CString(0) << Q3CString(""); QTest::newRow( "rem04" ) << Q3CString(0) << Q3CString("^.a") << Q3CString("") << Q3CString(0); QTest::newRow( "rem05" ) << Q3CString(0) << Q3CString("^.a") << Q3CString(0) << Q3CString(0); QTest::newRow( "rep00" ) << Q3CString("A <i>bon mot</i>.") << Q3CString("<i>([^<]*)</i>") << Q3CString("\\emph{\\1}") << Q3CString("A \\emph{bon mot}."); QTest::newRow( "rep01" ) << Q3CString("banana") << Q3CString("^.a()") << Q3CString("\\1") << Q3CString("nana"); QTest::newRow( "rep02" ) << Q3CString("banana") << Q3CString("(ba)") << Q3CString("\\1X\\1") << Q3CString("baXbanana"); QTest::newRow( "rep03" ) << Q3CString("banana") << Q3CString("(ba)(na)na") << Q3CString("\\2X\\1") << Q3CString("naXba"); }
int main(int argc, char ** argv) { if (argc != 2) return 0; if (UmlCom::connect(Q3CString(argv[1]).toUInt())) { try { //UmlCom::with_ack(FALSE); UmlCom::trace("<b>Java reverse</b> release 2.18<br><hr>"); UmlCom::traceAutoRaise(FALSE); UmlItem * item = UmlCom::targetItem(); if (item->kind() != aPackage) UmlCom::trace("<font face=helvetica><b>must be applied on a <i>package</i></b></font><br><hr><br>"); else { char * argv = 0; int argc = 0; QApplication * app = new QApplication(argc, &argv); Package::init((UmlPackage *) item, app); QString here = QDir::currentDirPath(); QString path; // note : QFile fp(QDir::home().absFilePath(".boumlcat")) doesn't work // if the path contains non latin1 characters, for instance cyrillic ! QString s = QDir::home().absFilePath(".boumlcat"); FILE * fp = fopen((const char *) s, "r"); if (fp != 0) { char line[512]; if (fgets(line, sizeof(line) - 1, fp) != 0) { remove_crlf(line); path = line; } fclose(fp); } while (!(path = Q3FileDialog::getOpenFileName(path, "*.cat", 0, 0, "select a java catalog file to read it, or cancel")) .isEmpty()) { QFile f(path); if (f.open(QIODevice::ReadOnly)) { if ((fp = fopen((const char *) s, "w")) != 0) { fwrite((const char *) path, 1, path.length(), fp); fputc('\n', fp); fclose(fp); } QDataStream dt(&f); Package::get_root()->restore_children(dt); } } QDir::setCurrent(here); int n; Package * p = Package::scan_dir(n); if (p != 0) { JavaSettings::set_UseDefaults(TRUE); p->send_dir(n); Statistic::produce(); } } } catch (...) { } try { // socket may be already closed UmlCom::message(""); UmlCom::showTrace(); UmlCom::bye(0); // application must not be deleted } catch (...) { } } UmlCom::close(); // application must not be deleted return 0; }
void tst_Q3CString::acc_01() { Q3CString a; Q3CString b; //b(10); Q3CString bb; //bb((int)0); Q3CString c("String C"); char tmp[10]; tmp[0] = 'S'; tmp[1] = 't'; tmp[2] = 'r'; tmp[3] = 'i'; tmp[4] = 'n'; tmp[5] = 'g'; tmp[6] = ' '; tmp[7] = 'D'; tmp[8] = 'X'; tmp[9] = '\0'; Q3CString d(tmp,8); Q3CString ca(a); Q3CString cb(b); Q3CString cc(c); Q3CString n; Q3CString e("String E"); Q3CString f; f = e; f.detach(); f[7]='F'; QCOMPARE(e,(Q3CString)"String E"); char text[]="String f"; f = text; text[7]='!'; QCOMPARE(f,(Q3CString)"String f"); f[7]='F'; QCOMPARE(text[7],'!'); #if 0 a=""; a[0]='A'; Q3CString res = "A"; QCOMPARE(a,res); QCOMPARE(a.length(),(uint)1); compare(a.length(),(uint)1); a[1]='B'; QCOMPARE(a,(Q3CString)"AB"); QCOMPARE(a.length(),(uint)2); a[2]='C'; QCOMPARE(a,(Q3CString)"ABC"); QCOMPARE(a.length(),(uint)3); a = Q3CString(); QVERIFY(a.isNull()); a[0]='A'; QCOMPARE(a,(Q3CString)"A"); QCOMPARE(a.length(),(uint)1); a[1]='B'; QCOMPARE(a,(Q3CString)"AB"); QCOMPARE(a.length(),(uint)2); a[2]='C'; QCOMPARE(a,(Q3CString)"ABC"); QCOMPARE(a.length(),(uint)3); #endif a="123"; b="456"; a[0]=a[1]; QCOMPARE(a,(Q3CString)"223"); a[1]=b[1]; QCOMPARE(b,(Q3CString)"456"); QCOMPARE(a,(Q3CString)"253"); char t[]="TEXT"; a="A"; a=t; QCOMPARE(a,(Q3CString)"TEXT"); QCOMPARE(a,(Q3CString)t); a[0]='X'; QCOMPARE(a,(Q3CString)"XEXT"); QCOMPARE(t[0],'T'); t[0]='Z'; QCOMPARE(a,(Q3CString)"XEXT"); a="ABC"; QCOMPARE(((const char*)a)[1],'B'); QCOMPARE(strcmp(a,(Q3CString)"ABC"),0); a += "DEF"; QCOMPARE(a, (Q3CString)"ABCDEF"); a += 'G'; QCOMPARE(a, (Q3CString)"ABCDEFG"); a += ((const char*)(0)); QCOMPARE(a, (Q3CString)"ABCDEFG"); // non-member operators a="ABC"; b="ABC"; c="ACB"; d="ABCD"; QVERIFY(a==b); QVERIFY(!(a==d)); QVERIFY(!(a!=b)); QVERIFY(a!=d); QVERIFY(!(a<b)); QVERIFY(a<c); QVERIFY(a<d); QVERIFY(!(d<a)); QVERIFY(!(c<a)); QVERIFY(a<=b); QVERIFY(a<=d); QVERIFY(a<=c); QVERIFY(!(c<=a)); QVERIFY(!(d<=a)); QCOMPARE(a+b,(Q3CString)"ABCABC"); QCOMPARE(a +"XXXX",(Q3CString)"ABCXXXX"); QCOMPARE(a+'X',(Q3CString)"ABCX"); QCOMPARE("XXXX"+a,(Q3CString)"XXXXABC"); QCOMPARE('X'+a,(Q3CString)"XABC"); a = (const char*)0; QVERIFY(a.isNull()); QVERIFY(*((const char *)a) == 0); { QFile f("COMPARE.txt"); f.open( QIODevice::WriteOnly ); QTextStream ts( &f ); ts.setEncoding(QTextStream::Unicode); ts << "Abc"; } }
void UmlRelation::generate_extends(const char *& sep, QTextStream & f, const Q3ValueList<UmlActualParameter> & actuals, const Q3CString & cl_stereotype) { switch (relationKind()) { default: return; case aGeneralisation: case aRealization: if (javaDecl().isEmpty()) return; UmlClass * role_type = roleType(); const Q3CString & other_stereotype = role_type->java_stereotype(); if ((cl_stereotype == "interface") || (cl_stereotype == "@interface")) { if ((other_stereotype != "interface") && (other_stereotype != "@interface")) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>cannot extends a <i>") + other_stereotype + "</i></b></font><br>"); incr_warning(); return; } } else if ((other_stereotype != "interface") && (other_stereotype != "@interface")) { if ((cl_stereotype == "union") || (cl_stereotype == "enum_pattern")) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>an <i>") + cl_stereotype + "</i> cannot extends</b></font><br>"); incr_warning(); return; } else if ((other_stereotype == "union") || (other_stereotype == "enum") || (other_stereotype == "enum_pattern")) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>cannot extends an <i>") + other_stereotype + "</i></b></font><br>"); incr_warning(); return; } else if (*sep == ',') { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>extend several classes</b></font><br>"); incr_warning(); return; } } else return; // here the code is legal f << sep; sep = ", "; const char * p = javaDecl(); while (*p) { if (!strncmp(p, "${type}", 7)) { role_type->write(f); p += 7; if (!actuals.isEmpty()) { Q3ValueList<UmlActualParameter>::ConstIterator ita; bool used = FALSE; for (ita = actuals.begin(); ita != actuals.end(); ++ita) { if ((*ita).superClass() == role_type) { used = TRUE; (*ita).generate(f); } } if (used) { f << ">"; } } } else if (*p == '@') manage_alias(p, f); else f << *p++; } } }