Esempio n. 1
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");
}
Esempio n. 2
0
void UmlExitPointPseudoState::html(Q3CString pfix, unsigned int rank, unsigned int level) {
  define();

  UmlCom::message(name());

  Q3CString s = sKind();
  
  s.replace(0, 1, s.left(1).upper());
  UmlItem::html(s, (UmlDiagram *) 0);
  
  fw.write("<p>Defined in ");
  if (parent()->kind() == aRegion)
    parent()->parent()->write();
  else
    parent()->write();
  fw.write("</p>");
  
  if (reference() != 0) {
    fw.write("<p>References ");
    reference()->write();
    fw.write("</p>");
  }

  write_children(pfix, rank, level);

  unload(FALSE, FALSE);
}
Esempio n. 3
0
void UmlClassMember::write_annotation(FileOut & out) {
    if (_lang == Java) {
        Q3CString a = javaAnnotations();

        if (!a.isEmpty()) {
            switch (_taggedvalue_mode) {
            case 1:
                out.indent();
                out << "<UML:ModelElement.taggedValue>\n";
                out.indent();
                out << "\t<UML:TaggedValue tag=\"annotations\" value=\"";
                out.quote(a);
                out << "\"/>\n";
                out.indent();
                out << "</UML:ModelElement.taggedValue>\n";
                break;
            case 2:
                out.indent();
                out << "<UML:ModelElement.taggedValue>\n";
                out.indent();
                out << "\t<UML:TaggedValue.tag>annotations</UML:TaggedValue.tag>\n";
                out.indent();
                out << "\t<UML:TaggedValue.value>";
                out.quote(a);
                out << "</UML:TaggedValue.value>\n";
                out.indent();
                out << "</UML:ModelElement.taggedValue>\n";
            }
        }
    }
}
Esempio n. 4
0
void UmlAcceptEventAction::write(FileOut & out) {
  write_begin(out, "AcceptEventAction");
  
  if (isUnmarshall())
    out << " isUnmarshall=\"true\"";
  
  Q3CString trig;
  
  switch (_lang) {
  case Uml:
    trig = trigger();
    break;
  case Cpp:
    trig = cppTrigger();
    break;
  default:
    // java
    trig = javaTrigger();
  }

  if (! trig.isEmpty()) {
    out.ref(this, "trigger", "TRIGGER_");
    write_end(out);
    
    out.indent();
    out << "<trigger xmi:type=\"uml:Trigger\"";
    out.id_prefix(this, "TRIGGER_");
    out << " name=\"";
    out.quote(trig);
    out << "\"/>\n";
  }
  else
    write_end(out);

}
Esempio n. 5
0
void UmlOpaqueAction::write(FileOut & out) {
  write_begin(out, "OpaqueAction");
  write_end(out, TRUE);
  
  Q3CString body;
  
  switch(_lang) {
  case Uml:
    body = behavior();
    break;
  case Cpp:
    body = cppBehavior();
    break;
  default:
    // Java
    body = javaBehavior();
  }

  if (!body.isEmpty()) {
    out.indent();
    out << "<body>";
    out.quote(body);
    out << "</body>\n";
  }

  write_close(out);

}
Esempio n. 6
0
void UmlReplyAction::write(FileOut & out) {
  write_begin(out, "ReplyAction");
  
  Q3CString trig;
  
  switch (_lang) {
  case Uml:
    trig = replyToCall();
    break;
  case Cpp:
    trig = cppReplyToCall();
    break;
  default:
    // java
    trig = javaReplyToCall();
  }

  if (! trig.isEmpty()) {
    out.ref(this, "replyToCall", "TRIGGER_");
    write_end(out);
    
    out.indent();
    out << "<trigger xmi:type=\"uml:Trigger\"";
    out.id_prefix(this, "TRIGGER_");
    out << " name=\"";
    out.quote(trig);
    out << "\"/>\n";
  }
  else
    write_end(out);
}
Esempio n. 7
0
Q3CString UmlClassMember::true_name(Q3CString decl) {
    int index = decl.find("${name}", 0); //[rageek] Removed CS=FALSE param - rethink this, case sensitive

    if (index == -1)
        // too complicated, return the Uml one
        return name();

    int begin = index;

    while ((begin != 0) && identChar(decl[begin - 1]))
        begin -= 1;

    int sup = index + 7;

    while (identChar(decl[sup]))
        sup += 1;

    Q3CString r = decl.mid(begin, index - begin);
    Q3CString k = decl.mid(index + 2, 4);

    if (k == "name")
        r += name();
    else if (k == "Name")
        r += name().left(1).upper() + name().mid(1);
    else
        // NAME
        r += name().upper();

    r += decl.mid(index + 7, sup - index - 7);

    return r;
}
Esempio n. 8
0
Q3CString Lex::read_list_elt()
{
  const char * p = _context.pointer;  
  int level = 1;
  Q3CString s;
  
  while (!((s = read_word(TRUE)).isEmpty())) {
    int c = *s;
    
    if ((c == '>') || (c == ')') || (c == ']')) {
      if (--level == 0)
	break;
    }
    else if (c == ',') {
      if (level == 1)
	break;
    }
    else if ((c == '<') || (c == '(') || (c == '['))
      level += 1;
  }
  
  if (! s.isEmpty())
    unread_word();
  
  char c = *_context.pointer;
  
  *_context.pointer = 0;
  s = p;  
  *_context.pointer = c;
  
  return s.stripWhiteSpace();
}
Esempio n. 9
0
static void manage_decorators(QTextOStream & f, const Q3CString & decorators,
			      QString indent, BooL & indent_needed)
{
  if (! decorators.isEmpty()) {
    int index = 0;
    int index2;
    
    while ((index2 = decorators.find("\n", index)) != -1){
      if (indent_needed)
	f << indent;
      else
	indent_needed = TRUE;
      f << decorators.mid(index, index2 + 1 - index);
      index = index2 + 1;
    }
    
    if (index != (int) decorators.length()) {
      if (indent_needed) {
	f << indent;
	indent_needed = FALSE;
      }
      f << decorators.mid(index);
    }
  }
}
Esempio n. 10
0
QByteArray K3BookmarkDrag::encodedData( const char* mime ) const
{
    QByteArray a;
    Q3CString mimetype( mime );
    if ( mimetype == "text/uri-list" )
        return Q3UriDrag::encodedData( mime );
    else if ( mimetype == "application/x-xbel" )
    {
        a = m_doc.toByteArray();
        //kDebug(7043) << "K3BookmarkDrag::encodedData " << m_doc.toCString();
    }
    else if ( mimetype == "text/plain" )
    {
        KUrl::List m_lstDragURLs;
        if ( K3URLDrag::decode( this, m_lstDragURLs ) )
        {
            QStringList uris;
            KUrl::List::ConstIterator uit = m_lstDragURLs.constBegin();
            KUrl::List::ConstIterator uEnd = m_lstDragURLs.constEnd();
            for ( ; uit != uEnd ; ++uit )
                uris.append( (*uit).prettyUrl() );

            Q3CString s = uris.join( "\n" ).toLocal8Bit();
            a.resize( s.length() + 1 ); // trailing zero
            memcpy( a.data(), s.data(), s.length() + 1 );
        }
    }
    return a;
}
Esempio n. 11
0
File: ndns.cpp Progetto: hummbl/psi
void NDnsWorker::run()
{
	hostent *h = 0;

#ifdef HAVE_GETHOSTBYNAME_R
	hostent buf;
	char char_buf[1024];
	int err;
	gethostbyname_r(host.data(), &buf, char_buf, sizeof(char_buf), &h, &err);
#else
	// lock for gethostbyname
	QMutexLocker locker(workerMutex);

	// check for cancel
	workerCancelled->lock();
	bool cancel = cancelled;
	workerCancelled->unlock();

	if(!cancel)
		h = gethostbyname(host.data());
#endif

	// FIXME: not ipv6 clean, currently.
	if(!h || h->h_addrtype != AF_INET) {
		success = false;
		QApplication::postEvent(par, new NDnsWorkerEvent(this));
		return;
	}

	in_addr a = *((struct in_addr *)h->h_addr_list[0]);
	addr.setAddress(ntohl(a.s_addr));
	success = true;

	QApplication::postEvent(par, new NDnsWorkerEvent(this));
}
Esempio n. 12
0
Q3CString UmlOperation::compute_name() {
  Q3CString get_set_spec = pythonNameSpec();
  
  if (! get_set_spec.isEmpty()) {
    UmlClassMember * it;
    
    if ((it = getOf()) == 0)
      it = setOf();
    
    int index;
    Q3CString s = (it->kind() == aRelation)
      ? ((UmlRelation *) it)->roleName()
      : it->name();
    
    if ((index = get_set_spec.find("${name}")) != -1)
      get_set_spec.replace(index, 7, s);
    else if ((index = get_set_spec.find("${Name}")) != -1)
      get_set_spec.replace(index, 7, capitalize(s));
    else if ((index = s.find("${NAME}")) != -1)
      get_set_spec.replace(index, 7, s.upper());
    else if ((index = s.find("${nAME}")) != -1)
      get_set_spec.replace(index, 7, s.lower());
    
    return get_set_spec;
  }
  else
    return name();
}
Esempio n. 13
0
File: Lex.cpp Progetto: SciBoy/douml
bool nequal(const Q3CString & s1, const Q3CString & s2)
{
  // don't take into account first and last white spaces (like a stripWhiteSpace())
  const char * p1 = (s1.isNull()) ? "" : (const char *) s1;
  const char * p2 = (s2.isNull()) ? "" : (const char *) s2;
  const char * e1 = p1 + s1.length();
  const char * e2 = p2 + s2.length();
  
  while ((p1 != e1) && is_white_space(p1[0]))
    p1 += 1;
  
  while ((p2 != e2) && is_white_space(p2[0]))
    p2 += 1;
  
  while ((e1 != p1) && is_white_space(e1[-1]))
    e1 -= 1;
  
   while ((e2 != p2) && is_white_space(e2[-1]))
    e2 -= 1;
  
  for (;;) {
    if (p1 >= e1)
      return (p2 < e2);
    if (*p1 != *p2)
      return TRUE;
    
    while (*++p1 == '\r') ;
    while (*++p2 == '\r') ;
  }
}
Esempio n. 14
0
void UmlUseCase::importIt(FileIn & in, Token & token, UmlItem * where)
{
  where = where->container(anUseCase, token, in);
    
  if (where != 0) {
    Q3CString s = token.valueOf("name");
    
    if (s.isEmpty()) {
      static unsigned n = 0;
      
      s.sprintf("anonymous_usecase_%u", ++n);
    }
    
    UmlUseCase * uc = create(where, s);
    
    if (uc == 0)
      in.error("cannot create use case '" + s +
	       "' in '" + where->name() + "'");
    
    uc->addItem(token.xmiId(), in);
    
    if (! token.closed()) {
      Q3CString k = token.what();
      const char * kstr = k;
      
      while (in.read(), !token.close(kstr))
	uc->UmlItem::import(in, token);
    }

    uc->unload(TRUE, FALSE);
  }
}
Esempio n. 15
0
void tst_Q3CString::constructor()
{
    Q3CString a;
    Q3CString b; //b(10);
    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,9);
    Q3CString ca(a);
    Q3CString cb(b);
    Q3CString cc(c);

    QCOMPARE(a,ca);
    QVERIFY(a.isNull());
    QVERIFY(a == Q3CString(""));
    QCOMPARE(b,cb);
    QCOMPARE(c,cc);
    QCOMPARE(d,(Q3CString)"String D");

    Q3CString null(0);
    QVERIFY( null.isNull() );
    QVERIFY( null.isEmpty() );
    Q3CString empty("");
    QVERIFY( !empty.isNull() );
    QVERIFY( empty.isEmpty() );
}
Esempio n. 16
0
void UmlRelation::write_relation(FileOut & out) {
  // note : it is the first side
 
  if (_assoc_class != 0)
    // generated in the association class
    return;
    
  const char * k = (_uml_20) ? "ownedElement" : "packagedElement";

  out.indent();
  out << '<' << k << " xmi:type=\"uml:Association\"";
  out.id_prefix(this, "ASSOC_");
  
  Q3CString s = name();
  int i1 = s.find("(");
  int i2 = s.findRev(")");
  
  if ((i1 != -1) && (i2 != -1) && (i2 > i1) && (s[i1+1] != '<')  && (s[i2-1] != '>')) {
    s = s.mid(i1 + 1, i2 - i1 - 1);
    
    if (!s.isEmpty()) {
      out << " name=\"";
      out.quote((const char*)s);//[jasa] ambiguous call
      out << '"';
    }
  }
  write_visibility(out);
  out << ">\n";
  
  write_ends(out);
  
  out.indent();
  out << "</" << k << ">\n";

}
Esempio n. 17
0
bool UmlArtifact::is_imported(Q3CString path, Q3CString class_name) {
  if (imports == 0) {
    imports = new Q3AsciiDict<UmlArtifact>(17);
    
    Q3CString s = javaSource();
    int index = 0;
    
    while ((index = s.find("import", index)) != -1) {
      if ((index == 0) || (s[index - 1] < ' ')) {
	int index2 = index + 6;
	
	while ((s[index2] == ' ') || (s[index2] == '\t'))
	  index2 += 1;
	
	if ((index2 != (index + 6)) &&
	    ((index = s.find(';', index2)) != -1) &&
	    (index != index2)) {
	 Q3CString p = s.mid(index2, index - index2);
	 
	 imports->insert(p, this);
	}
	else
	  index = index2;
      }
      else
	index += 6;
    }
  }
  
  return ((imports->find(path + '.' + class_name) != 0) ||
	  (imports->find(path + ".*") != 0));
}
Esempio n. 18
0
void tst_Q3CString::isEmpty()
{
    Q3CString a;
    QVERIFY(a.isEmpty());
    Q3CString c("Not empty");
    QVERIFY(!c.isEmpty());
}
Esempio n. 19
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);
  }
}
Esempio n. 20
0
void UmlItem::write_multiplicity(FileOut & out, Q3CString s, UmlItem * who)
{
  if (!s.isEmpty()) {
    Q3CString min;
    Q3CString max;
    int index = s.find("..");
    
    if (index != -1) {
      min = s.left(index).stripWhiteSpace();
      max = s.mid(index+2).stripWhiteSpace();
    }
    else
      min = max = s.stripWhiteSpace();
    
    out.indent();
    out << "<lowerValue xmi:type=\"uml:LiteralString\"";
    out.id_prefix(who, "MULTIPLICITY_L_");
    out << " value=\"" << min << "\"/>\n";
    
    out.indent();
    out << "<upperValue xmi:type=\"uml:LiteralString\"";
    out.id_prefix(who, "MULTIPLICITY_U_");
    out << " value=\"" << max << "\"/>\n";
  }
}
Esempio n. 21
0
void Trigger::add(FileIn & in, Token & token, Q3CString & name, Q3CString & idref)
{
  // token is <trigger ...>
  Q3CString t = token.xmiIdref();
  
  if (! t.isEmpty()) {
    QMap<Q3CString, Q3CString>::Iterator iter = All.find(t);
    
    if (iter == All.end()) {
      idref = t;
      name = "";
    }
    else {
      name = *iter;
      idref = "";
    }
  }
  else {
    name = token.valueOf("name");
    idref = "";
    All.insert(token.xmiId(), name);
  }

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

}
Esempio n. 22
0
static void create_directory(Q3CString s)
{
  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;
  }
}
Esempio n. 23
0
void Q3Url::encode( QString& url )
{
    if ( url.isEmpty() )
	return;

    Q3CString curl = url.utf8();
    int oldlen = curl.length();

    const Q3CString special( "+<>#@\"&%$:,;?={}|^~[]\'`\\ \n\t\r" );
    QString newUrl;
    int newlen = 0;

    for ( int i = 0; i < oldlen ;++i ) {
	uchar inCh = (uchar)curl[ i ];

	if ( inCh >= 128 || special.contains(inCh) ) {
	    newUrl[ newlen++ ] = QLatin1Char( '%' );

	    ushort c = inCh / 16;
	    c += c > 9 ? 'A' - 10 : '0';
	    newUrl[ newlen++ ] = c;

	    c = inCh % 16;
	    c += c > 9 ? 'A' - 10 : '0';
	    newUrl[ newlen++ ] = c;
	} else {
	    newUrl[ newlen++ ] = inCh;
	}
    }

    url = newUrl;
}
Esempio n. 24
0
void UmlClass::java(Q3Dict<Q3CString> & prop) {
  if (!scanning) {
    Q3CString d = (stereotype() == "interface") 
      ? JavaSettings::interfaceDecl()
      : JavaSettings::classDecl();
    
    Q3CString * v;
    
    if ((v = prop.find("Java/Final")) != 0) {
      if (*v == "TRUE")
	set_isJavaFinal(TRUE);
      prop.remove("Java/Final");
    }
    
    if ((v = prop.find("Java/Strictfp")) != 0) {
      if (*v == "TRUE") {
	int index;
	
	if ((index = d.find("${public}")) != -1)
	  d.insert((unsigned) index + 9, "strictfp ");
	else if ((index = d.find("${visibility}")) != -1)
	  d.insert((unsigned) index + 13, "strictfp ");
      }
      prop.remove("Java/Strictfp");
    }
    
    set_JavaDecl(d);
  }
}
Esempio n. 25
0
int XmlProtocol::internalWriteString(const QString &s, TrackItem::Type t, int id)
{
	QString out=ensureGTEncoded(s);
	Q3CString cs = s.utf8();
	QByteArray a(cs.length());
	memcpy(a.data(), cs.data(), a.size());
	return internalWriteData(a, t, id);
}
Esempio n. 26
0
void UmlPackage::html(Q3CString pfix, unsigned int rank, unsigned int level) {
  define();
  
  if (stereotype() == "profile")
    chapter("Profile", pfix, rank, "profile", level);
  else
    chapter("Package", pfix, rank, "package", level);

  Q3CString s = description();
  
  if (!s.isEmpty()) {
    fw.write("<p>");
    writeq(s);
    fw.write("<br /></p>");
  }
  
  bool ul = FALSE;
  
  s = cppNamespace();
  
  if (!s.isEmpty()) {
    fw.write("<p></p><ul>\n");
    ul = TRUE;
    fw.write("<li>C++ namespace : ");
    writeq(s);
    fw.write("</li>\n");
  }

  s = javaPackage();
  
  if (!s.isEmpty()) {
    if (! ul)
      fw.write("<p></p><ul>");
    ul = TRUE;
    fw.write("<li>Java package : ");
    writeq(s);
    fw.write("</li>\n");
  }
    
  if (ul)
    fw.write("</ul>\n");
    
  write_dependencies();
    
  UmlDiagram * d = associatedDiagram();
  
  if (d != 0) {
    fw.write("<p>Diagram : ");
    d->write();
    fw.write("</p>\n");
  }

  write_properties();

  write_children(pfix, rank, level);

  unload(FALSE, FALSE);
}
Esempio n. 27
0
bool UmlAttribute::new_one(Class * container, Q3CString name,
			   aVisibility visibility, bool constp,
			   bool staticp, const Q3CString & value,
			   Q3CString comment, Q3CString description)
{
#ifdef TRACE
  cout << "ATTRIBUTE '" << name << "'\n";
#endif
  
#ifndef REVERSE
  if (visibility == PrivateVisibility)
    return TRUE;
#endif
  
  if (((const char *) name)[0] == '$')
    name = name.mid(1);
  
  UmlClass * cl = container->get_uml();
  UmlAttribute * at = UmlBaseAttribute::create(cl, name);
  
  if (at == 0) {
    PhpCatWindow::trace(Q3CString("<font face=helvetica><b>cannot add attribute <i>")
			 + name + "</i> in <i>" + cl->name() 
			 + "</i></b></font><br>");  
    return FALSE;
  }
#ifdef REVERSE
  Statistic::one_attribute_more();
#endif
  
  if (!comment.isEmpty()) {
    Q3CString s = (at->phpDecl().find("${description}") != -1)
      ? description : comment;
    UmlTypeSpec t;
    int index;
    
    if (! (t.explicit_type = value_of(s, "@var", index)).isEmpty()) {
      at->set_Type(t);
      s.replace(index, t.explicit_type.length(), "${type}");
    }
    
    at->set_Description(s);
    
  }
  
  if (constp)
    at->set_isReadOnly(TRUE);
  
  if (staticp)
    at->set_isClassMember(TRUE);
  
  if (! value.isEmpty())
    at->set_DefaultValue(value);
  
  at->set_Visibility(visibility);
  
  return TRUE;
}
Esempio n. 28
0
void tst_Q3CString::isNull()
{
    Q3CString a;
    QVERIFY( a.isNull() );

    const char *str = "foo";
    a.sprintf( str );
    QVERIFY( !a.isNull() );
}
Esempio n. 29
0
void tst_Q3CString::copy()
{
    Q3CString e;
    e = "String E";
    Q3CString ce = e.copy();
    QCOMPARE(ce,(Q3CString)"String E");
    e = "XXX";
    QCOMPARE(ce,(Q3CString)"String E");
    QCOMPARE(e,(Q3CString)"XXX");
}
Esempio n. 30
0
unsigned UmlSettings::multiplicity_column(const Q3CString & mult)
{
  if (mult.isEmpty() || (mult == "1"))
    return 0;

  if ((mult == "*") || (mult.find("..") != -1))
    return 1;

  return 2;
}