Esempio n. 1
0
void tst_Q3CString::stripWhiteSpace()
{
    Q3CString a;
    a="Text";
    QCOMPARE(a,(Q3CString)"Text");
    QCOMPARE(a.stripWhiteSpace(),(Q3CString)"Text");
    QCOMPARE(a,(Q3CString)"Text");
    a=" ";
    QCOMPARE(a.stripWhiteSpace(),(Q3CString)"");
    QCOMPARE(a,(Q3CString)" ");
    a=" a   ";
    QCOMPARE(a.stripWhiteSpace(),(Q3CString)"a");
}
Esempio n. 2
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. 3
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. 4
0
void UmlClass::write(QTextOStream & f, bool with_formals, BooL * is_template,
		     const Q3ValueList<UmlActualParameter> & actuals) {
  if (context.findRef(this) == -1) {
    if (parent()->kind() == aClass) {
      if (context.findRef((UmlClass *) parent()) == -1) {
	// parent cannot have formals, but may have actuals
	((UmlClass *) parent())->write(f, FALSE, 0, actuals);
	f << "::";
      }
    }
    else {
      UmlArtifact * cp = associatedArtifact();
      Q3CString nasp = ((UmlPackage *)
		       ((cp != 0) ? (UmlItem *) cp : (UmlItem *) this)->package())
	->cppNamespace();
      
      if (CppSettings::isForceNamespacePrefixGeneration() ||
	  (nasp != UmlArtifact::generation_package()->cppNamespace()))
	f << nasp << "::";
    }
  }
  
  Q3CString s;
  
  if (isCppExternal()) {
    s = cppDecl();
    
    int index = s.find('\n');
    
    s = (index == -1) ? s.stripWhiteSpace()
		      : s.left(index).stripWhiteSpace();
      
    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());
  }
  else 
    s = name();	// true_name
  
  if (! s.isEmpty()){
    f << s;
    
    if (is_template != 0)
      *is_template = (s.at(s.length() - 1) == '>');
  }
  else if (is_template != 0)
    *is_template = FALSE;
    
  if (with_formals) {
    Q3ValueList<UmlFormalParameter> formals = this->formals();
    
    if (! formals.isEmpty()) {
      const char * sep = "<";
      Q3ValueList<UmlFormalParameter>::ConstIterator it;
      
      for (it = formals.begin(); it != formals.end(); ++it) {
	f << sep << (*it).name();
	sep = ", ";
      }
      
      f << '>';
      
      if (is_template != 0)
	*is_template = TRUE;
    }
  }
  else if (!actuals.isEmpty()) {
    Q3ValueList<UmlActualParameter>::ConstIterator ita;
    BooL need_space = FALSE;
    bool used = FALSE;
    
    for (ita = actuals.begin(); ita != actuals.end(); ++ita) {
      if ((*ita).superClass() == this) {
	used = TRUE;
	(*ita).generate(f, need_space);
      }
    }
    
    if (used) {
      if (need_space)
	f << " >";
      else
	f << '>';
      
      if (is_template != 0)
	*is_template = TRUE;
    }
  }
}
Esempio n. 5
0
bool ClassData::tool_cmd(ToolCom * com, const char * args,
			 BrowserNode * bn,
			 const QString & comment) {
  if (((unsigned char) args[-1]) >= firstSetCmd) {
    if (!bn->is_writable() && !root_permission())
      com->write_ack(FALSE);
    else {
      switch ((unsigned char) args[-1]) {
      case setIsAbstractCmd:
	if ((*args == 0) && 
	    strcmp(browser_node->get_stereotype(), "enum") &&
	    ((BrowserClass *) browser_node)->have_abstract_operation()) {
	  com->write_ack(FALSE);
	  return TRUE;
	}
	else
	  is_abstract = (*args != 0);
	break;
      case setActiveCmd:
	is_active = (*args != 0);
	break;
      case setVisibilityCmd:
	{
	  UmlVisibility v;
	  
	  if (! com->get_visibility(v, args)) {
	    com->write_ack(FALSE);
	    return TRUE;
	  }
	  else
	    uml_visibility = v;
	}
	break;
      case setBaseTypeCmd:
	if (stereotype != "typedef") {
	  com->write_ack(FALSE);
	  return TRUE;
	}
	else {
	  AType t;
	  
	  com->get_type(t, args);
	  set_base_type(t);	  
	}
	break;
      case setConstraintCmd:
	constraint = args;
	break;
      case setIsCppExternalCmd:
	cpp_external = (*args != 0);
	break;
      case setCppVisibilityCmd:
	{
	  UmlVisibility v;
	  
	  if (! com->get_extended_visibility(v, args)) {
	    com->write_ack(FALSE);
	    return TRUE;
	  }
	  else
	    cpp_visibility = v;
	}
	break;
      case setCppDeclCmd:
	cpp_decl = args;
	break;
      case setIsJavaExternalCmd:
	java_external = (*args != 0);
	break;
      case setJavaDeclCmd:
	java_decl = args;
	break;
      case setJavaAnnotationCmd:
	{
	  Q3CString s = args;
	  
	  s = s.stripWhiteSpace();
	  if (! s.isEmpty())
	    s += '\n';
	  java_annotation = s;
	}
	break;
      case setIsJavaPublicCmd:
	{
	  UmlVisibility v = (*args != 0) ? UmlPublic : UmlPackageVisibility;
	  
	  if ((cpp_visibility == UmlDefaultVisibility) &&
	      (uml_visibility != UmlPublic) &&
	      (uml_visibility != UmlPackageVisibility))
	    cpp_visibility = uml_visibility;
	  uml_visibility = v;
	}
	break;
      case setIsJavaFinalCmd:
	java_final = (*args != 0);
	break;
      case setIsPhpExternalCmd:
	php_external = (*args != 0);
	break;
      case setPhpDeclCmd:
	php_decl = args;
	break;
      case setIsPhpFinalCmd:
	php_final = (*args != 0);
	break;
      case setIsPythonExternalCmd:
	python_external = (*args != 0);
	break;
      case setPythonDeclCmd:
	python_decl = args;
	break;
      case setIsPython2_2Cmd:
	python_2_2 = (*args != 0);
	break;
      case setIdlDeclCmd:
	idl_decl = args;
	break;
      case setSwitchTypeCmd:
	if (GenerationSettings::idl_class_stereotype(stereotype) != "union") {
	  com->write_ack(FALSE);
	  return TRUE;
	}
	else {
	  AType t;
	  
	  com->get_type(t, args);
	  set_switch_type(t);
	}
	break;
      case setIsIdlExternalCmd:
	idl_external = (*args != 0);
	break;
      case setIsIdlLocalCmd:
	idl_local = (*args != 0);
	break;
      case setIsIdlCustomCmd:
	idl_custom = (*args != 0);
	break;
      case setIsClassMemberCmd:
      case setIsVolatileCmd:
	com->write_ack(FALSE);
	return TRUE;
      case removeFormalCmd:
	{
	  unsigned rank = com->get_unsigned(args);
	  
	  if (rank < nformals) {
	    if (nformals == 1) {
	      delete [] formals;
	      formals = 0;
	    }
	    else
	      while (++rank != nformals)
		formals[rank - 1] = formals[rank];
	    nformals -= 1;
	    DontUpdateActuals = FALSE;
	  }
	  else {
	    com->write_ack(FALSE);
	    return TRUE;
	  }
	}
	break;
      case addFormalCmd:
	{
	  unsigned rank = com->get_unsigned(args);
	  
	  if (rank <= nformals) {
	    FormalParamData * new_formals = new FormalParamData[++nformals];
	    unsigned index;
	    
	    for (index = 0; index != rank; index += 1)
	      new_formals[index] = formals[index];
	    
	    new_formals[index].read(com, args);
	    
	    while (++index != nformals)
	      new_formals[index] = formals[index - 1];
	    
	    delete [] formals;
	    formals = new_formals;
	    DontUpdateActuals = FALSE;
	  }
	  else {
	    FormalParamData::skip(com, args);
	    com->write_ack(FALSE);
	    return TRUE;
	  }
	}
	break;
      case replaceFormalCmd:
	{
	  unsigned rank = com->get_unsigned(args);
	  
	  if (rank < nformals) {
	    formals[rank].read(com, args);
	    DontUpdateActuals = FALSE;
	  }
	  else {
	    FormalParamData::skip(com, args);
	    com->write_ack(FALSE);
	    return TRUE;
	  }
	}
	break;
      case replaceActualCmd:
	{
	  unsigned rank = com->get_unsigned(args);
	  
	  if (rank < actuals.count()) {
	    AType t;
	    
	    com->get_type(t, args);
	    actuals.at(rank)->set_value(t);
	  }
	  else {
	    com->write_ack(FALSE);
	    return TRUE;
	  }
	}
	break;
      default:
	return BasicData::tool_cmd(com, args, bn, comment);
      }
  
      // ok case
      bn->modified();	// call modified
      bn->package_modified();
      com->write_ack(TRUE);
    }
  }
  else {
    // get only !
    switch ((unsigned char) args[-1]) {
    case formalsCmd:
      {
	com->write_unsigned((unsigned) nformals);
	for (int index = 0; index != nformals; index += 1)
	  formals[index].send_uml_def(com);
      }
      break;
    case actualsCmd:
      {
	com->write_unsigned((unsigned) actuals.count());
	for (ActualParamData * a = actuals.first(); a != 0; a = actuals.next())
	  a->send_uml_def(com);
      }
      break;
    default:
      return BasicData::tool_cmd(com, args, bn, comment);
    }
  }
  
  return TRUE;
}