static void ExtractIds(char *fname) { strCollection *text = istrCollection.CreateFromFile(fname); Iterator *it = istrCollection.NewIterator(text); char *p; for (p = it->GetFirst(it); p != NULL; p = it->GetNext(it)) { char buf[512]; if (strstr(p,"typedef") && strstr(p,"struct") && strchr(p,'{')) { char *q = strstr(p,"struct"); char *name; q += 6; while (*q == ' ' || *q == '\t') q++; if (*q == 't' && q[1] == 'a' && q[2] == 'g') q += 3; if (*q == '{') { strcpy(buf,"ValArray"); doFile(buf,it); } else { int i = 0; while (*q != ' ' && *q != '{' && *q) buf[i++] = *q++; buf[i]=0; q = strstr(buf,"Interface"); if (q) *q=0; if (FindType(buf) >= 0) { doFile(buf,it); } else if (strstr(buf,"WDictionary")) { strcpy(buf,"WDictionary"); doFile(buf,it); } else if (strstr(buf,"HeapAllocator")) { strcpy(buf,"ContainerHeap"); doFile(buf,it); } } } } for (p = it->GetFirst(it); p != NULL; p = it->GetNext(it)) { int r = ScanOneLine(p); } istrCollection.DeleteIterator(it); istrCollection.Finalize(text); }
//} ostream& operator <<(ostream& out,const polynomial& A) { //cout << "AHEAD = " << *A.head; //node *walker = A.head; Iterator<polyterm> P = A.Begin(); while(P.GetNext() != NULL) { if(P.GetNode()->GetData().Coef() == 0) { cout << ""; // walker=walker->next; P.GetNext(); } else { if(P.GetNext()->GetData().Coef() > 0) { out << P; cout << " + "; //walker = walker->next; P.Next(); } else if(P.GetNext()->GetData().Coef()<0) { out << P; //walker = walker->next; P.Next(); } else if(P.GetNext()->GetData().Coef()==0) { out << P; out << " + "; //walker = walker->next; P.Next(); } } } out << P; //P.Next(); return out; }
static void EliminateComments(strCollection *sc) { Iterator *it = istrCollection.NewIterator(sc); char *p; for (p = it->GetFirst(it); p; p = it->GetNext(it)) { char *q = strstr(p,"/*"); if (q) *q = 0; } }
static int Apply(TreeMap *tree,int (*Applyfn)(const void *data,void *arg),void *arg) { Iterator *it = newIterator(tree); void *obj; for (obj = it->GetFirst(it); obj != NULL; obj = it->GetNext(it)) { Applyfn(obj,arg); } return 1; }
static int Clear(TreeMap *tree) { if (tree->DestructorFn) { Iterator *it = newIterator(tree); void *obj; for (obj = it->GetFirst(it); obj != NULL; obj = it->GetNext(it)) { tree->DestructorFn(obj); } } iHeap.Finalize(tree->Heap); tree->Heap = iHeap.Create(tree->ElementSize+sizeof(struct Node),CurrentMemoryManager); tree->count = 0; tree->root=0; tree->max_size=0; /* Max size since last complete rebalance. */ tree->Flags=0; tree->timestamp=0; return 1; }
static PQueue *Copy(const PQueue *src) { PQueue *result; Iterator *it; int r; PQueueElement *obj; if (src == NULL) return NULL; result = CreateWithAllocator(src->ElementSize,src->Allocator); if (result == NULL) return NULL; it = iHeap.NewIterator(src->Heap); for (obj = it->GetFirst(it); obj != NULL; obj = it->GetNext(it)) { if (obj->Key != INT_MIN) { r = Add(result,obj->Key,obj->Data); if (r < 0) { Finalize(result); return NULL; } } } iHeap.deleteIterator(it); return result; }
int main(void) { Iterator *it; DataPoint *d; strCollection *Output = istrCollection.CreateWithAllocator(100,&iDebugMalloc); int j,APITotals=0; int totals[1+NbContainers]; char buf[4096]; memset(totals,0,sizeof(totals)); Exceptions = istrCollection.InitializeWith(sizeof(ExceptionsTable)/sizeof(ExceptionsTable[0]),ExceptionsTable); ContainerTable = istrCollection.InitializeWith(NbContainers,ContainerNames); ExtractIds("../containers.h"); ExtractIds("../valarraygen.h"); ExtractIds("../stringlistgen.h"); it = iDictionary.NewIterator(Data); iDictionary.SetDestructor(Data,destroyDataPoint); for (d = it->GetFirst(it); d != NULL; d = it->GetNext(it)) { int len = strlen(d->ApiName); if (len > 15) sprintf(buf,"%-20s\t&",d->ApiName); else if (len > 12) sprintf(buf,"%-20s\t&",d->ApiName); else sprintf(buf,"%-20s\t&",d->ApiName); for (j=0; j<NbContainers;j++) { if (d->type[j]) { sprintf(buf+strlen(buf)," \\X "); totals[j] += 1; } else sprintf(buf+strlen(buf)," "); if (j != NbContainers-1) strcat(buf,"&"); } strcat(buf,"\\\\\n"); istrCollection.Add(Output,buf); } istrCollection.Sort(Output); istrCollection.Add(Output,"\\hline\n"); sprintf(buf,"%-20s\t&","Totals"); for (j=0; j<NbContainers;j++) { sprintf(buf+strlen(buf),"%3d&",totals[j]); APITotals += totals[j]; } buf[strlen(buf)-1]=0; /* Eliminate the last '&' */ strcat(buf,"\\\\\n"); istrCollection.Add(Output,buf); sprintf(buf,"%-20s\t& %d & ","Total APIs",APITotals); for (j=0; j<NbContainers-2;j++) { sprintf(buf+strlen(buf)," & "); } strcat(buf,"\\\\\n"); istrCollection.Add(Output,buf); istrCollection.WriteToFile(Output,"table.tex"); istrCollection.Finalize(Output); iDictionary.DeleteIterator(it); iDictionary.Finalize(Data); Data = NULL; return 0; }