コード例 #1
0
ファイル: canalyze.c プロジェクト: yonatana/espl
      int main (int argc, char **argv){
      //varibales
      namelist nl = make_namelist();  
      FILE *stream; 
      char *fileName;
      char name[64];
      int FLAG = 0;
      int i = 1;
      int j = 0;     
      
      //upload files in a loop and gets the name to an array
    for (i=1;i!=argc;i++){//each file
     fileName = argv[i];//get the file
     stream = fopen(fileName, "r");//read the file
     
     while(fgetname(name, sizeof(name), stream)) {
       if(legalName(name)){
       printf("%s ", name);
	add_name(nl, name);
	//printf("\n");
	}
     }
     fclose(stream);
      }
      qsort(nl->names,nl->size,sizeof(struct namestat),compare);
  
  for(i=0;i<nl->size;i++){
    printf("%s %d\n",nl->names[i].name,nl->names[i].count);
  }
  
   
      return 0;
      }
コード例 #2
0
ファイル: UmlClass.cpp プロジェクト: SciBoy/douml
void UmlClass::importIdlConstant(UmlItem * parent, const Q3CString & id, const Q3CString & s, const Q3CString & doc, Q3Dict<Q3CString> & prop)
{
  // use a class to define the constant !
  UmlClass * x;

  if ((x = UmlClass::create(parent, legalName(s))) == 0) {
    UmlCom::trace("<br>cannot create class '" + s + "' in " +
		  parent->fullName());
    throw 0;
  }

  newItem(x, id);
  x->lang = Corba;
  x->set_Stereotype("constant");
  
  if (!doc.isEmpty())
    x->set_Description(doc);

  Q3CString type;
  Q3CString value;
  Q3CString * v;
  
  if ((v = prop.find("CORBA/ImplementationType")) != 0) {
    type = *v;
    prop.remove("CORBA/ImplementationType");
  }

  if ((v = prop.find("CORBA/ConstValue")) != 0) {
    if (!v->isEmpty())
      value = " = " + *v;
    prop.remove("CORBA/ConstValue");
  }

  Q3CString d = IdlSettings::constDecl();
  int index;
  
  if ((index = d.find("${type}")) != -1)
    d.replace(index, 7, type);
    
  if ((index = d.find("${value}")) != -1)
    d.replace(index, 8, value);
  
  x->setProperties(prop);
  x->set_IdlDecl(d);
}
コード例 #3
0
ファイル: UmlClass.cpp プロジェクト: daniel7solis/douml
void UmlClass::importIt(FileIn & in, Token & token, UmlItem * where)
{
    where = where->container(aClass, token, in);	// can't be null

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

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

        s.sprintf("anonymous_%u", ++n);
    }
    else
        s = legalName(s);

    UmlClass * cl = create(where, s);
    Association * assocclass = 0;
    bool stereotype = FALSE;

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

    cl->addItem(token.xmiId(), in);

    do
        where = where->parent();

    while (where->kind() != aPackage);

    if (where->stereotype() == "profile")
        cl->set_PropertyValue("xmiId", token.xmiId());

    if (token.xmiType() == "uml:Actor")
        cl->set_Stereotype("actor");
    else if (token.xmiType() == "uml:Interface")
        cl->set_Stereotype("interface");
    else if (token.xmiType() == "uml:Enumeration")
        cl->set_Stereotype("enum");
    else if (token.xmiType() == "uml:Stereotype") {
        cl->set_Stereotype("stereotype");
        NumberOf -= 1;
        NumberOfStereotype += 1;
        stereotype = TRUE;
    }
    else if (token.xmiType() == "uml:AssociationClass") {
        assocclass = &Association::get(token.xmiId(), token.valueOf("name"));
        assocclass->set_class_association();
    }

    cl->setVisibility(token.valueOf("visibility"));

    if (token.valueOf("isabstract") == "true")
        cl->set_isAbstract(TRUE);

    if (token.valueOf("isactive") == "true")
        cl->set_isActive(TRUE);

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

        while (in.read(), !token.close(kstr)) {
            s = token.what();

            if ((s == "ownedtemplatesignature") &&
                ((token.xmiType() == "uml:TemplateSignature") ||
                 (token.xmiType() == "uml:RedefinableTemplateSignature")))
                cl->readFormal(in, token);
            else if ((s == "templatebinding") &&
                     (token.xmiType() == "uml:TemplateBinding")) {
                Binding::import(in, token, cl);
            }
            else if ((assocclass != 0) && (s == "memberend")) {
                if (assocclass_ref1.isEmpty())
                    assocclass_ref1 = token.xmiIdref();
                else
                    assocclass_ref2 = token.xmiIdref();

                if (! token.closed())
                    in.finish(s);
            }
            else if ((assocclass != 0) &&
                     (s == "ownedend") &&
                     (token.xmiType() == "uml:Property"))
                assocclass->import(in, token);
            else if (s == "ownedrule")
                cl->set_Constraint(UmlItem::readConstraint(in, token));
            else if (stereotype &&
                     (s == "icon") &&
                     (token.xmiType() == "uml:Image")) {
                WrapperStr path = token.valueOf("location");

                if (! path.isEmpty())
                    cl->set_PropertyValue("stereotypeIconPath", path);

                if (! token.closed())
                    in.finish(s);
            }
            else
                cl->UmlItem::import(in, token);
        }
    }

    cl->unload(TRUE, FALSE);
}
コード例 #4
0
ファイル: UmlClass.cpp プロジェクト: SciBoy/douml
UmlClass * UmlClass::import(File & f, UmlItem * parent, const Q3CString & knd)
{
  Q3CString s;

  if (f.read(s) != STRING)
    f.syntaxError(s, "class's name");
    
  Q3CString id;
  Q3CString ste;
  Q3CString doc;
  Q3Dict<Q3CString> prop;
  Q3CString s2;
  int k;
  
  do {
    k = f.readDefinitionBeginning(s2, id, ste, doc, prop);
  } while (id.isEmpty());

  if (ste == "CORBAConstant") {
    // not a class !
    if (!scanning) {
      if (parent->kind() == aClass)
	UmlAttribute::importIdlConstant((UmlClass *) parent, id, s, doc, prop);
      else
	importIdlConstant(parent, id, s, doc, prop);
    }
    
    if (k != ')')
      f.skipBlock();
    
    return 0;
  }

  UmlClass * cl;
  
  if (scanning) {
    if (((cl = UmlBaseClass::create(parent, s)) == 0) &&
	((cl = UmlBaseClass::create(parent, legalName(s))) == 0)) {
      UmlCom::trace("<br>cannot create class '" + s + "' in " +
		    parent->fullName());
      throw 0;
    }
    newItem(cl, id);
    
    if (!ste.isEmpty()) {
      if (ste.left(5) == "CORBA") {
	if (ste != "CORBAValue")
	  cl->set_Stereotype(ste.mid(5).lower());
      }
      else 
	cl->set_Stereotype(((ste == "Actor") || (ste == "Interface"))
			   ? ste.lower() : ste);
    }
    
    if (!doc.isEmpty())
      cl->set_Description(doc);
    
    cl->lang = None;  
  }
  else if ((cl = (UmlClass *) findItem(id, aClass)) == 0) {
    UmlCom::trace("<br>unknown class '" + s + "' in " +
		  parent->fullName());
    throw 0;
  }
  
  Q3CString art_path;
  
  for (;;) {
    switch (k) {
    case ')':
      switch (cl->lang) {
      case Cplusplus:
      case AnsiCplusplus:
      case VCplusplus:
	cl->cplusplus(prop);
	break;
      case Oracle8:
	cl->oracle8(prop);
	break;
      case Corba:
	cl->corba(prop);
	break;
      case Java:
	cl->java(prop);
	break;
      default:
	break;
      }
      
      if (!scanning) {
	cl->setProperties(prop);
	cl->unload(TRUE);
      }
      return cl;
    case ATOM:
      if (s2 == "operations")
	cl->importOperations(f);
      else if (s2 == "class_attributes")
	cl->importAttributes(f);
      else if (!scanning &&
	       ((s2 == "superclasses") ||
		(s2 == "used_nodes") ||
		(s2 == "realized_interfaces")))
	cl->importRelations(f);
      else if (s2 == "nestedClasses")
	cl->importClasses(f);
      else if (s2 == "abstract") {
	if (f.readBool())
	  cl->set_isAbstract(TRUE);
      }
      else if (s2 == "language")
	cl->lang = f.readLanguage();
      else if (s2 == "instantiation_relationship") 
	cl->importInstantiate(f);
      else if (s2 == "parameters") {
	if (knd == "Parameterized_Class")
	  cl->importFormals(f);
        else
	  cl->importActuals(f);
      }
      else if (s2 == "module") {
	if (f.read(art_path) != STRING)
	  f.syntaxError(art_path, "module's name");
      }
      else if (!scanning && (s2 == "quidu")) {
	f.read(s2);
	cl->assocArtifact(Artifact::find(s2), art_path);
      }
      else
	f.skipNextForm();
      k = f.read(s2);
      break;
    default:
      f.syntaxError(s);
    }
  }
}
コード例 #5
0
void UmlAttribute::importIt(FileIn & in, Token & token, UmlItem * where)
{
  if (!token.valueOf("association").isNull())
    UmlRelation::importAsAttribute(in, token, where);
  else {
    where = where->container(anAttribute, token, in);
    
    if (where != 0) {
      QCString s = token.valueOf("name");
      
      if (s.isEmpty()) {
	static unsigned n = 0;
	
	s.sprintf("anonymous_attribute_%u", ++n);
      }
      else
        s = legalName(s);
      
      UmlAttribute * att = create((UmlClass *) where, s);
      
      if (att == 0)
	in.error("cannot create attribute '" + s +
		 "' in '" + where->name() + "'");
      
      att->addItem(token.xmiId(), in);
      
      if (token.what() == "ownedliteral")
	att->set_Visibility(PublicVisibility);
      else
	att->setVisibility(token.valueOf("visibility"));
      
      if (token.valueOf("isreadonly") == "true")
	 att->set_isReadOnly(TRUE);
      
      if (token.valueOf("isderived") == "true")
	 att->set_isDerived(TRUE, (token.valueOf("isderivedunion") == "true"));
      
      if (token.valueOf("isordered") == "true")
	 att->set_isOrdered(TRUE);
      
      if (token.valueOf("isunique") == "true")
	 att->set_isUnique(TRUE);
      
      if (!(s = token.valueOf("type")).isEmpty()) {
	UmlTypeSpec ts;
	
	if (att->setType(s, ts))
	  att->set_Type(ts);
      }
      
      if (!(s = token.valueOf("defaultvalue")).isEmpty())
	att->set_DefaultValue(s);
      
      if (token.valueOf("isstatic") == "true")
	att->set_isClassMember(TRUE);
	  
      if (! token.closed()) {
	QCString k = token.what();
	const char * kstr = k;
	
	while (in.read(), !token.close(kstr)) {
	  s = token.what();
	  
	  if (s == "type") {
	    UmlTypeSpec ts;
	    
	    if (att->setType(token, ts))
	      att->set_Type(ts);
	    if (! token.closed())
	      in.finish(s);
	  }
	  else if (s == "defaultvalue") {
	    att->set_DefaultValue(token.valueOf("value"));
	    if (! token.closed())
	      in.finish(s);
	  }
	  else if (s == "lowervalue")
	    att->importMultiplicity(in, token, FALSE);
	  else if (s == "uppervalue")
	    att->importMultiplicity(in, token, TRUE);
	  else if (s == "upperbound") {
	    if (! token.closed())
	      in.finish(s);
	  }
	  else if ((s == "specification") && (k == "ownedliteral")) {
	    if (! token.closed())
	      in.finish(s);
	  }
	  else if (s == "ownedrule")
	    att->set_Constraint(UmlItem::readConstraint(in, token));
	  else
	    att->UmlItem::import(in, token);
	}
      }
    }
  }
}
コード例 #6
0
ファイル: UmlOperation.cpp プロジェクト: DoUML/douml
void UmlOperation::import(File & f, UmlClass * parent)
{
    QByteArray s;

    if (f.read(s) != STRING)
        f.syntaxError(s, "operations's name");

    QByteArray id;
    QByteArray ste;
    QByteArray doc;
    QHash<QByteArray, QByteArray*> prop;
    QByteArray s2;
    int k;

    do {
        k = f.readDefinitionBeginning(s2, id, ste, doc, prop);
    }
    while (id.isEmpty());

    UmlOperation * x;

    if (scanning) {
        QByteArray name;

        if (s.left(8) != "operator")
            name = (s.at(0) == '~')
                   ? ("~" + legalName(s.mid(1)))
                   : legalName(s);
        else
            name = s;

        if ((x = UmlBaseOperation::create(parent, name)) == 0) {
            UmlCom::trace("<br>cannot create operation '" + s + "' in " +
                          parent->fullName());
            throw 0;
        }

        newItem(x, id);

        if (!ste.isEmpty()) {
            bool managed = FALSE;
            QStringList l = QString(ste).split(",");

            for (QStringList::Iterator it = l.begin();
                 it != l.end();
                 ++it) {
                if ((*it) == "const") {
                    managed = TRUE;
                    x->set_isCppConst(TRUE);
                }
                else if ((*it) == "abstract") {
                    managed = TRUE;
                    x->set_isAbstract(TRUE);
                    x->set_isCppVirtual(TRUE);
                }
                else if ((*it) == "virtual") {
                    managed = TRUE;
                    x->set_isCppVirtual(TRUE);
                }
                else if ((*it) == "static") {
                    managed = TRUE;
                    x->set_isClassMember(TRUE);
                }
            }

            if (!managed)
                x->set_Stereotype(ste);
        }

        if (!doc.isEmpty())
            x->set_Description(doc);
    }
    else if ((x = (UmlOperation *) findItem(id, anOperation)) == 0) {
        UmlCom::trace("<br>unknown operation '" + s + "' in " +
                      parent->fullName());
        throw 0;
    }
    else {
        switch (((UmlClass *) x->parent())->language()) {
        case Cplusplus:
        case AnsiCplusplus:
        case VCplusplus:
            x->cplusplus(prop);
            break;

        case Oracle8:
            x->oracle8(prop);
            break;

        case Corba:
            x->corba(prop);
            break;

        case Java:
            x->java(prop);
            break;

        default:
            break;
        }

        x->setProperties(prop);
    }

    f.unread(k, s2);
    x->import(f);
}