8 #include "memberlist.h"
9 #include "definition.h"
12 #include "arguments.h"
14 #define HEADER ('D'<<24)+('O'<<16)+('X'<<8)+'!'
16 void marshalInt(StorageIntf *s,int v)
20 b[1]=(((uint)v)>>16)&0xff;
21 b[2]=(((uint)v)>>8)&0xff;
23 s->write((const char *)b,4);
26 void marshalUInt(StorageIntf *s,uint v)
33 s->write((const char *)b,4);
36 void marshalBool(StorageIntf *s,bool b)
39 s->write(&c,sizeof(char));
42 void marshalQCString(StorageIntf *s,const QCString &str)
46 if (l>0) s->write(str.data(),l);
49 void marshalQGString(StorageIntf *s,const QGString &str)
53 if (l>0) s->write(str.data(),l);
56 void marshalArgumentList(StorageIntf *s,ArgumentList *argList)
58 ArgumentList::marshal(s,argList);
61 void marshalArgumentLists(StorageIntf *s,QList<ArgumentList> *argLists)
65 marshalUInt(s,NULL_LIST); // null pointer representation
69 marshalUInt(s,argLists->count());
70 QListIterator<ArgumentList> ali(*argLists);
72 for (ali.toFirst();(al=ali.current());++ali)
74 marshalArgumentList(s,al);
79 void marshalBaseInfoList(StorageIntf *s, QList<BaseInfo> *baseList)
83 marshalUInt(s,NULL_LIST); // null pointer representation
87 marshalUInt(s,baseList->count());
88 QListIterator<BaseInfo> bli(*baseList);
90 for (bli.toFirst();(bi=bli.current());++bli)
92 marshalQCString(s,bi->name);
93 marshalInt(s,(int)bi->prot);
94 marshalInt(s,(int)bi->virt);
99 void marshalGroupingList(StorageIntf *s, QList<Grouping> *groups)
103 marshalUInt(s,NULL_LIST); // null pointer representation
107 marshalUInt(s,groups->count());
108 QListIterator<Grouping> gli(*groups);
110 for (gli.toFirst();(g=gli.current());++gli)
112 marshalQCString(s,g->groupname);
113 marshalInt(s,(int)g->pri);
118 void marshalSectionInfoList(StorageIntf *s, QList<SectionInfo> *anchors)
122 marshalUInt(s,NULL_LIST); // null pointer representation
126 marshalUInt(s,anchors->count());
127 QListIterator<SectionInfo> sli(*anchors);
129 for (sli.toFirst();(si=sli.current());++sli)
131 marshalQCString(s,si->label);
132 marshalQCString(s,si->title);
133 marshalQCString(s,si->ref);
134 marshalInt(s,(int)si->type);
135 marshalQCString(s,si->fileName);
136 marshalInt(s,si->level);
141 void marshalItemInfoList(StorageIntf *s, QList<ListItemInfo> *sli)
145 marshalUInt(s,NULL_LIST); // null pointer representation
149 marshalUInt(s,sli->count());
150 QListIterator<ListItemInfo> liii(*sli);
152 for (liii.toFirst();(lii=liii.current());++liii)
154 marshalQCString(s,lii->type);
155 marshalInt(s,lii->itemId);
160 void marshalObjPointer(StorageIntf *s,void *obj)
162 char *b = (char *)&obj;
163 s->write(b,sizeof(void *));
166 void marshalSectionDict(StorageIntf *s,SectionDict *sections)
170 marshalUInt(s,NULL_LIST); // null pointer representation
174 marshalUInt(s,sections->count());
175 SDict<SectionInfo>::IteratorDict sli(*sections);
177 for (sli.toFirst();(si=sli.current());++sli)
179 marshalQCString(s,sli.currentKey());
180 marshalObjPointer(s,si);
185 void marshalMemberSDict(StorageIntf *s,MemberSDict *memberSDict)
189 marshalUInt(s,NULL_LIST); // null pointer representation
193 marshalUInt(s,memberSDict->count());
194 //printf(" marshalMemberSDict: items=%d\n",memberSDict->count());
195 SDict<MemberDef>::IteratorDict mdi(*memberSDict);
198 for (mdi.toFirst();(md=mdi.current());++mdi)
200 //printf(" marshalMemberSDict: %d: key=%s value=%p\n",count,mdi.currentKey().data(),md);
201 marshalQCString(s,mdi.currentKey());
202 marshalObjPointer(s,md);
205 assert(count==memberSDict->count());
209 void marshalDocInfo(StorageIntf *s,DocInfo *docInfo)
213 marshalUInt(s,NULL_LIST); // null pointer representation
218 marshalQCString(s,docInfo->doc);
219 marshalInt(s,docInfo->line);
220 marshalQCString(s,docInfo->file);
224 void marshalBriefInfo(StorageIntf *s,BriefInfo *briefInfo)
228 marshalUInt(s,NULL_LIST); // null pointer representation
233 marshalQCString(s,briefInfo->doc);
234 marshalQCString(s,briefInfo->tooltip);
235 marshalInt(s,briefInfo->line);
236 marshalQCString(s,briefInfo->file);
240 void marshalBodyInfo(StorageIntf *s,BodyInfo *bodyInfo)
244 marshalUInt(s,NULL_LIST); // null pointer representation
249 marshalInt(s,bodyInfo->startLine);
250 marshalInt(s,bodyInfo->endLine);
251 marshalObjPointer(s,bodyInfo->fileDef);
255 void marshalGroupList(StorageIntf *s,GroupList *groupList)
259 marshalUInt(s,NULL_LIST); // null pointer representation
263 marshalUInt(s,groupList->count());
264 QListIterator<GroupDef> gli(*groupList);
266 for (gli.toFirst();(gd=gli.current());++gli)
268 marshalObjPointer(s,gd);
273 void marshalMemberList(StorageIntf *s,MemberList *ml)
277 marshalUInt(s,NULL_LIST); // null pointer representation
281 marshalUInt(s,ml->count());
282 MemberListIterator mli(*ml);
285 for (mli.toFirst();(md=mli.current());++mli)
287 marshalObjPointer(s,md);
290 assert(count==ml->count());
296 void marshalExampleSDict(StorageIntf *s,ExampleSDict *ed)
300 marshalUInt(s,NULL_LIST); // null pointer representation
304 marshalUInt(s,ed->count());
305 //printf(" marshalMemberSDict: items=%d\n",memberSDict->count());
306 SDict<Example>::IteratorDict edi(*ed);
308 for (edi.toFirst();(e=edi.current());++edi)
310 //printf(" marshalMemberSDict: %d: key=%s value=%p\n",count,mdi.currentKey().data(),md);
311 marshalQCString(s,edi.currentKey());
312 marshalQCString(s,e->anchor);
313 marshalQCString(s,e->name);
314 marshalQCString(s,e->file);
319 void marshalMemberLists(StorageIntf *s,SDict<MemberList> *mls)
323 marshalUInt(s,NULL_LIST); // null pointer representation
327 marshalUInt(s,mls->count());
328 //printf(" marshalMemberSDict: items=%d\n",memberSDict->count());
329 SDict<MemberList>::IteratorDict mli(*mls);
331 for (mli.toFirst();(ml=mli.current());++mli)
333 //printf(" marshalMemberSDict: %d: key=%s value=%p\n",count,mdi.currentKey().data(),md);
334 marshalQCString(s,mli.currentKey());
335 marshalObjPointer(s,ml); // assume we are not owner of the list
340 void marshalEntry(StorageIntf *s,Entry *e)
342 marshalUInt(s,HEADER);
343 marshalQCString(s,e->name);
344 marshalQCString(s,e->type);
345 marshalInt(s,e->section);
346 marshalInt(s,(int)e->protection);
347 marshalInt(s,(int)e->mtype);
348 marshalInt(s,e->spec);
349 marshalInt(s,e->initLines);
350 marshalBool(s,e->stat);
351 marshalBool(s,e->explicitExternal);
352 marshalBool(s,e->proto);
353 marshalBool(s,e->subGrouping);
354 marshalBool(s,e->callGraph);
355 marshalBool(s,e->callerGraph);
356 marshalInt(s,(int)e->virt);
357 marshalQCString(s,e->args);
358 marshalQCString(s,e->bitfields);
359 marshalArgumentList(s,e->argList);
360 marshalArgumentLists(s,e->tArgLists);
361 marshalQGString(s,e->program);
362 marshalQGString(s,e->initializer);
363 marshalQCString(s,e->includeFile);
364 marshalQCString(s,e->includeName);
365 marshalQCString(s,e->doc);
366 marshalInt(s,e->docLine);
367 marshalQCString(s,e->docFile);
368 marshalQCString(s,e->brief);
369 marshalInt(s,e->briefLine);
370 marshalQCString(s,e->briefFile);
371 marshalQCString(s,e->inbodyDocs);
372 marshalInt(s,e->inbodyLine);
373 marshalQCString(s,e->inbodyFile);
374 marshalQCString(s,e->relates);
375 marshalInt(s,e->relatesType);
376 marshalQCString(s,e->read);
377 marshalQCString(s,e->write);
378 marshalQCString(s,e->inside);
379 marshalQCString(s,e->exception);
380 marshalArgumentList(s,e->typeConstr);
381 marshalInt(s,e->bodyLine);
382 marshalInt(s,e->endBodyLine);
383 marshalInt(s,e->mGrpId);
384 marshalBaseInfoList(s,e->extends);
385 marshalGroupingList(s,e->groups);
386 marshalSectionInfoList(s,e->anchors);
387 marshalQCString(s,e->fileName);
388 marshalInt(s,e->startLine);
389 marshalItemInfoList(s,e->sli);
390 marshalInt(s,(int)e->lang);
391 marshalBool(s,e->hidden);
392 marshalBool(s,e->artificial);
393 marshalInt(s,(int)e->groupDocType);
396 void marshalEntryTree(StorageIntf *s,Entry *e)
399 marshalUInt(s,e->children()->count());
400 QListIterator<Entry> eli(*e->children());
402 for (eli.toFirst();(child=eli.current());++eli)
404 marshalEntryTree(s,child);
408 //------------------------------------------------------------------
410 int unmarshalInt(StorageIntf *s)
413 s->read((char *)b,4);
414 int result=(int)((((uint)b[0])<<24)+((uint)b[1]<<16)+((uint)b[2]<<8)+(uint)b[3]);
415 //printf("unmarshalInt: %x %x %x %x: %x offset=%llx\n",b[0],b[1],b[2],b[3],result,f.pos());
419 uint unmarshalUInt(StorageIntf *s)
422 s->read((char *)b,4);
423 uint result=(((uint)b[0])<<24)+((uint)b[1]<<16)+((uint)b[2]<<8)+(uint)b[3];
424 //printf("unmarshalUInt: %x %x %x %x: %x offset=%llx\n",b[0],b[1],b[2],b[3],result,f.pos());
428 bool unmarshalBool(StorageIntf *s)
431 s->read(&result,sizeof(result));
432 //printf("unmarshalBool: %x offset=%llx\n",result,f.pos());
436 QCString unmarshalQCString(StorageIntf *s)
438 uint len = unmarshalUInt(s);
439 //printf("unmarshalQCString: len=%d offset=%llx\n",len,f.pos());
440 QCString result(len+1);
444 s->read(result.data(),len);
446 //printf("unmarshalQCString: result=%s\n",result.data());
450 QGString unmarshalQGString(StorageIntf *s)
452 uint len = unmarshalUInt(s);
453 //printf("unmarshalQCString: len=%d offset=%llx\n",len,f.pos());
454 QGString result(len+1);
458 s->read(result.data(),len);
460 //printf("unmarshalQCString: result=%s\n",result.data());
464 ArgumentList *unmarshalArgumentList(StorageIntf *s)
466 return ArgumentList::unmarshal(s);
469 QList<ArgumentList> *unmarshalArgumentLists(StorageIntf *s)
472 uint count = unmarshalUInt(s);
473 if (count==NULL_LIST) return 0; // null list
474 QList<ArgumentList> *result = new QList<ArgumentList>;
475 result->setAutoDelete(TRUE);
476 assert(count<1000000);
477 //printf("unmarshalArgumentLists: %d\n",count);
478 for (i=0;i<count;i++)
480 result->append(unmarshalArgumentList(s));
485 QList<BaseInfo> *unmarshalBaseInfoList(StorageIntf *s)
488 uint count = unmarshalUInt(s);
489 if (count==NULL_LIST) return 0; // null list
490 QList<BaseInfo> *result = new QList<BaseInfo>;
491 result->setAutoDelete(TRUE);
492 assert(count<1000000);
493 for (i=0;i<count;i++)
495 QCString name = unmarshalQCString(s);
496 Protection prot = (Protection)unmarshalInt(s);
497 Specifier virt = (Specifier)unmarshalInt(s);
498 result->append(new BaseInfo(name,prot,virt));
503 QList<Grouping> *unmarshalGroupingList(StorageIntf *s)
506 uint count = unmarshalUInt(s);
507 if (count==NULL_LIST) return 0; // null list
508 QList<Grouping> *result = new QList<Grouping>;
509 result->setAutoDelete(TRUE);
510 assert(count<1000000);
511 for (i=0;i<count;i++)
513 QCString name = unmarshalQCString(s);
514 Grouping::GroupPri_t prio = (Grouping::GroupPri_t)unmarshalInt(s);
515 result->append(new Grouping(name,prio));
520 QList<SectionInfo> *unmarshalSectionInfoList(StorageIntf *s)
523 uint count = unmarshalUInt(s);
524 if (count==NULL_LIST) return 0; // null list
525 QList<SectionInfo> *result = new QList<SectionInfo>;
526 result->setAutoDelete(TRUE);
527 assert(count<1000000);
528 for (i=0;i<count;i++)
530 QCString label = unmarshalQCString(s);
531 QCString title = unmarshalQCString(s);
532 QCString ref = unmarshalQCString(s);
533 SectionInfo::SectionType type = (SectionInfo::SectionType)unmarshalInt(s);
534 QCString fileName = unmarshalQCString(s);
535 int level = unmarshalInt(s);
536 result->append(new SectionInfo(fileName,label,title,type,level,ref));
541 QList<ListItemInfo> *unmarshalItemInfoList(StorageIntf *s)
544 uint count = unmarshalUInt(s);
545 if (count==NULL_LIST) return 0; // null list
546 QList<ListItemInfo> *result = new QList<ListItemInfo>;
547 result->setAutoDelete(TRUE);
548 assert(count<1000000);
549 for (i=0;i<count;i++)
551 ListItemInfo *lii = new ListItemInfo;
552 lii->type = unmarshalQCString(s);
553 lii->itemId = unmarshalInt(s);
559 void *unmarshalObjPointer(StorageIntf *s)
562 s->read((char *)&result,sizeof(void*));
566 SectionDict *unmarshalSectionDict(StorageIntf *s)
569 uint count = unmarshalUInt(s);
570 //printf("unmarshalSectionDict count=%d\n",count);
571 if (count==NULL_LIST) return 0; // null list
572 SectionDict *result = new SectionDict(17);
573 assert(count<1000000);
574 for (i=0;i<count;i++)
576 QCString key = unmarshalQCString(s);
577 SectionInfo *si = (SectionInfo *)unmarshalObjPointer(s);
578 //printf(" unmarshalSectionDict i=%d key=%s si=%s\n",count,key.data(),si->label.data());
579 result->append(key,si);
584 MemberSDict *unmarshalMemberSDict(StorageIntf *s)
587 uint count = unmarshalUInt(s);
588 //printf("--- unmarshalMemberSDict count=%d\n",count);
589 if (count==NULL_LIST)
591 //printf("--- end unmarshalMemberSDict\n");
592 return 0; // null list
594 MemberSDict *result = new MemberSDict;
595 assert(count<1000000);
596 //printf("Reading %d key-value pairs\n",count);
597 for (i=0;i<count;i++)
599 //printf(" unmarshaling pair %d\n",i);
600 QCString key = unmarshalQCString(s);
601 //printf(" unmarshaling key %s\n",key.data());
602 MemberDef *md = (MemberDef *)unmarshalObjPointer(s);
603 //printf(" unmarshalMemberSDict i=%d key=%s md=%p\n",i,key.data(),md);
604 result->append(key,md);
607 //printf("--- end unmarshalMemberSDict\n");
611 DocInfo *unmarshalDocInfo(StorageIntf *s)
613 uint count = unmarshalUInt(s);
614 if (count==NULL_LIST) return 0;
615 DocInfo *result = new DocInfo;
616 result->doc = unmarshalQCString(s);
617 result->line = unmarshalInt(s);
618 result->file = unmarshalQCString(s);
622 BriefInfo *unmarshalBriefInfo(StorageIntf *s)
624 uint count = unmarshalUInt(s);
625 if (count==NULL_LIST) return 0;
626 BriefInfo *result = new BriefInfo;
627 result->doc = unmarshalQCString(s);
628 result->tooltip = unmarshalQCString(s);
629 result->line = unmarshalInt(s);
630 result->file = unmarshalQCString(s);
634 BodyInfo *unmarshalBodyInfo(StorageIntf *s)
636 uint count = unmarshalUInt(s);
637 if (count==NULL_LIST) return 0;
638 BodyInfo *result = new BodyInfo;
639 result->startLine = unmarshalInt(s);
640 result->endLine = unmarshalInt(s);
641 result->fileDef = (FileDef*)unmarshalObjPointer(s);
645 GroupList *unmarshalGroupList(StorageIntf *s)
648 uint count = unmarshalUInt(s);
649 if (count==NULL_LIST) return 0; // null list
650 assert(count<1000000);
651 GroupList *result = new GroupList;
652 for (i=0;i<count;i++)
654 GroupDef *gd = (GroupDef *)unmarshalObjPointer(s);
660 MemberList *unmarshalMemberList(StorageIntf *s)
663 uint count = unmarshalUInt(s);
664 if (count==NULL_LIST) return 0;
665 MemberList *result = new MemberList;
666 assert(count<1000000);
667 for (i=0;i<count;i++)
669 MemberDef *md = (MemberDef*)unmarshalObjPointer(s);
672 result->unmarshal(s);
676 ExampleSDict *unmarshalExampleSDict(StorageIntf *s)
679 uint count = unmarshalUInt(s);
680 if (count==NULL_LIST) return 0;
681 ExampleSDict *result = new ExampleSDict;
682 assert(count<1000000);
683 for (i=0;i<count;i++)
685 QCString key = unmarshalQCString(s);
686 Example *e = new Example;
687 e->anchor = unmarshalQCString(s);
688 e->name = unmarshalQCString(s);
689 e->file = unmarshalQCString(s);
690 result->inSort(key,e);
695 SDict<MemberList> *unmarshalMemberLists(StorageIntf *s)
698 uint count = unmarshalUInt(s);
699 if (count==NULL_LIST) return 0;
700 SDict<MemberList> *result = new SDict<MemberList>(7);
701 assert(count<1000000);
702 for (i=0;i<count;i++)
704 QCString key = unmarshalQCString(s);
705 MemberList *ml = (MemberList *)unmarshalObjPointer(s);
706 result->append(key,ml);
711 Entry * unmarshalEntry(StorageIntf *s)
713 Entry *e = new Entry;
714 uint header=unmarshalUInt(s);
715 ASSERT(header==HEADER);
716 e->name = unmarshalQCString(s);
717 e->type = unmarshalQCString(s);
718 e->section = unmarshalInt(s);
719 e->protection = (Protection)unmarshalInt(s);
720 e->mtype = (MethodTypes)unmarshalInt(s);
721 e->spec = unmarshalInt(s);
722 e->initLines = unmarshalInt(s);
723 e->stat = unmarshalBool(s);
724 e->explicitExternal = unmarshalBool(s);
725 e->proto = unmarshalBool(s);
726 e->subGrouping = unmarshalBool(s);
727 e->callGraph = unmarshalBool(s);
728 e->callerGraph = unmarshalBool(s);
729 e->virt = (Specifier)unmarshalInt(s);
730 e->args = unmarshalQCString(s);
731 e->bitfields = unmarshalQCString(s);
733 e->argList = unmarshalArgumentList(s);
734 e->tArgLists = unmarshalArgumentLists(s);
735 e->program = unmarshalQGString(s);
736 e->initializer = unmarshalQGString(s);
737 e->includeFile = unmarshalQCString(s);
738 e->includeName = unmarshalQCString(s);
739 e->doc = unmarshalQCString(s);
740 e->docLine = unmarshalInt(s);
741 e->docFile = unmarshalQCString(s);
742 e->brief = unmarshalQCString(s);
743 e->briefLine = unmarshalInt(s);
744 e->briefFile = unmarshalQCString(s);
745 e->inbodyDocs = unmarshalQCString(s);
746 e->inbodyLine = unmarshalInt(s);
747 e->inbodyFile = unmarshalQCString(s);
748 e->relates = unmarshalQCString(s);
749 e->relatesType = (RelatesType)unmarshalInt(s);
750 e->read = unmarshalQCString(s);
751 e->write = unmarshalQCString(s);
752 e->inside = unmarshalQCString(s);
753 e->exception = unmarshalQCString(s);
754 e->typeConstr = unmarshalArgumentList(s);
755 e->bodyLine = unmarshalInt(s);
756 e->endBodyLine = unmarshalInt(s);
757 e->mGrpId = unmarshalInt(s);
759 e->extends = unmarshalBaseInfoList(s);
761 e->groups = unmarshalGroupingList(s);
763 e->anchors = unmarshalSectionInfoList(s);
764 e->fileName = unmarshalQCString(s);
765 e->startLine = unmarshalInt(s);
766 e->sli = unmarshalItemInfoList(s);
767 e->lang = (SrcLangExt)unmarshalInt(s);
768 e->hidden = unmarshalBool(s);
769 e->artificial = unmarshalBool(s);
770 e->groupDocType = (Entry::GroupDocType)unmarshalInt(s);
774 Entry * unmarshalEntryTree(StorageIntf *s)
776 Entry *e = unmarshalEntry(s);
777 uint count = unmarshalUInt(s);
779 for (i=0;i<count;i++)
781 e->addSubEntry(unmarshalEntryTree(s));