Blame src/marshal.cpp

Packit 1c1d7e
#include <qfile.h>
Packit 1c1d7e
#include <assert.h>
Packit 1c1d7e
Packit 1c1d7e
#include "sortdict.h"
Packit 1c1d7e
#include "marshal.h"
Packit 1c1d7e
#include "entry.h"
Packit 1c1d7e
#include "section.h"
Packit 1c1d7e
#include "memberlist.h"
Packit 1c1d7e
#include "definition.h"
Packit 1c1d7e
#include "groupdef.h"
Packit 1c1d7e
#include "example.h"
Packit 1c1d7e
#include "arguments.h"
Packit 1c1d7e
Packit 1c1d7e
#define HEADER ('D'<<24)+('O'<<16)+('X'<<8)+'!'
Packit 1c1d7e
Packit 1c1d7e
void marshalInt(StorageIntf *s,int v)
Packit 1c1d7e
{
Packit 1c1d7e
  uchar b[4];
Packit 1c1d7e
  b[0]=((uint)v)>>24;
Packit 1c1d7e
  b[1]=(((uint)v)>>16)&0xff;
Packit 1c1d7e
  b[2]=(((uint)v)>>8)&0xff;
Packit 1c1d7e
  b[3]=v&0xff;
Packit 1c1d7e
  s->write((const char *)b,4);
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalUInt(StorageIntf *s,uint v)
Packit 1c1d7e
{
Packit 1c1d7e
  uchar b[4];
Packit 1c1d7e
  b[0]=v>>24;
Packit 1c1d7e
  b[1]=(v>>16)&0xff;
Packit 1c1d7e
  b[2]=(v>>8)&0xff;
Packit 1c1d7e
  b[3]=v&0xff;
Packit 1c1d7e
  s->write((const char *)b,4);
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalUInt64(StorageIntf *s,uint64 v)
Packit 1c1d7e
{
Packit 1c1d7e
  marshalUInt(s, uint(v>>32));
Packit 1c1d7e
  marshalUInt(s, uint(v&0xFFFFFFFF));
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalBool(StorageIntf *s,bool b)
Packit 1c1d7e
{
Packit 1c1d7e
  char c = b;
Packit 1c1d7e
  s->write(&c,sizeof(char));
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalQCString(StorageIntf *s,const QCString &str)
Packit 1c1d7e
{
Packit 1c1d7e
  uint l=str.length();
Packit 1c1d7e
  marshalUInt(s,l);
Packit 1c1d7e
  if (l>0) s->write(str.data(),l);
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalQGString(StorageIntf *s,const QGString &str)
Packit 1c1d7e
{
Packit 1c1d7e
  uint l=str.length();
Packit 1c1d7e
  marshalUInt(s,l);
Packit 1c1d7e
  if (l>0) s->write(str.data(),l);
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalArgumentList(StorageIntf *s,ArgumentList *argList)
Packit 1c1d7e
{
Packit 1c1d7e
  ArgumentList::marshal(s,argList);
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalArgumentLists(StorageIntf *s,QList<ArgumentList> *argLists)
Packit 1c1d7e
{
Packit 1c1d7e
  if (argLists==0)
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,NULL_LIST); // null pointer representation
Packit 1c1d7e
  }
Packit 1c1d7e
  else
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,argLists->count());
Packit 1c1d7e
    QListIterator<ArgumentList> ali(*argLists);
Packit 1c1d7e
    ArgumentList *al;
Packit 1c1d7e
    for (ali.toFirst();(al=ali.current());++ali)
Packit 1c1d7e
    {
Packit 1c1d7e
      marshalArgumentList(s,al);
Packit 1c1d7e
    }
Packit 1c1d7e
  }
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalBaseInfoList(StorageIntf *s, QList<BaseInfo> *baseList)
Packit 1c1d7e
{
Packit 1c1d7e
  if (baseList==0)
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,NULL_LIST); // null pointer representation
Packit 1c1d7e
  }
Packit 1c1d7e
  else
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,baseList->count());
Packit 1c1d7e
    QListIterator<BaseInfo> bli(*baseList);
Packit 1c1d7e
    BaseInfo *bi;
Packit 1c1d7e
    for (bli.toFirst();(bi=bli.current());++bli)
Packit 1c1d7e
    {
Packit 1c1d7e
      marshalQCString(s,bi->name);
Packit 1c1d7e
      marshalInt(s,(int)bi->prot);
Packit 1c1d7e
      marshalInt(s,(int)bi->virt);
Packit 1c1d7e
    }
Packit 1c1d7e
  }
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalGroupingList(StorageIntf *s, QList<Grouping> *groups)
Packit 1c1d7e
{
Packit 1c1d7e
  if (groups==0)
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,NULL_LIST); // null pointer representation
Packit 1c1d7e
  }
Packit 1c1d7e
  else
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,groups->count());
Packit 1c1d7e
    QListIterator<Grouping> gli(*groups);
Packit 1c1d7e
    Grouping *g;
Packit 1c1d7e
    for (gli.toFirst();(g=gli.current());++gli)
Packit 1c1d7e
    {
Packit 1c1d7e
      marshalQCString(s,g->groupname);
Packit 1c1d7e
      marshalInt(s,(int)g->pri);
Packit 1c1d7e
    }
Packit 1c1d7e
  }
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalSectionInfoList(StorageIntf *s, QList<SectionInfo> *anchors)
Packit 1c1d7e
{
Packit 1c1d7e
  if (anchors==0)
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,NULL_LIST); // null pointer representation
Packit 1c1d7e
  }
Packit 1c1d7e
  else
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,anchors->count());
Packit 1c1d7e
    QListIterator<SectionInfo> sli(*anchors);
Packit 1c1d7e
    SectionInfo *si;
Packit 1c1d7e
    for (sli.toFirst();(si=sli.current());++sli)
Packit 1c1d7e
    {
Packit 1c1d7e
      marshalQCString(s,si->label);
Packit 1c1d7e
      marshalQCString(s,si->title);
Packit 1c1d7e
      marshalQCString(s,si->ref);
Packit 1c1d7e
      marshalInt(s,(int)si->type);
Packit 1c1d7e
      marshalQCString(s,si->fileName);
Packit 1c1d7e
      marshalInt(s,si->lineNr);
Packit 1c1d7e
      marshalInt(s,si->level);
Packit 1c1d7e
    }
Packit 1c1d7e
  }
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalItemInfoList(StorageIntf *s, QList<ListItemInfo> *sli)
Packit 1c1d7e
{
Packit 1c1d7e
  if (sli==0)
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,NULL_LIST); // null pointer representation
Packit 1c1d7e
  }
Packit 1c1d7e
  else
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,sli->count());
Packit 1c1d7e
    QListIterator<ListItemInfo> liii(*sli);
Packit 1c1d7e
    ListItemInfo *lii;
Packit 1c1d7e
    for (liii.toFirst();(lii=liii.current());++liii)
Packit 1c1d7e
    {
Packit 1c1d7e
      marshalQCString(s,lii->type);
Packit 1c1d7e
      marshalInt(s,lii->itemId);
Packit 1c1d7e
    }
Packit 1c1d7e
  }
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalObjPointer(StorageIntf *s,void *obj)
Packit 1c1d7e
{
Packit 1c1d7e
  char *b = (char *)&ob;;
Packit 1c1d7e
  s->write(b,sizeof(void *));
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalSectionDict(StorageIntf *s,SectionDict *sections)
Packit 1c1d7e
{
Packit 1c1d7e
  if (sections==0)
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,NULL_LIST); // null pointer representation
Packit 1c1d7e
  }
Packit 1c1d7e
  else
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,sections->count());
Packit 1c1d7e
    SDict<SectionInfo>::IteratorDict sli(*sections);
Packit 1c1d7e
    SectionInfo *si;
Packit 1c1d7e
    for (sli.toFirst();(si=sli.current());++sli)
Packit 1c1d7e
    {
Packit 1c1d7e
      marshalQCString(s,sli.currentKey());
Packit 1c1d7e
      marshalObjPointer(s,si);
Packit 1c1d7e
    }
Packit 1c1d7e
  }
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalMemberSDict(StorageIntf *s,MemberSDict *memberSDict)
Packit 1c1d7e
{
Packit 1c1d7e
  if (memberSDict==0)
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,NULL_LIST); // null pointer representation
Packit 1c1d7e
  }
Packit 1c1d7e
  else
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,memberSDict->count());
Packit 1c1d7e
    //printf("  marshalMemberSDict: items=%d\n",memberSDict->count());
Packit 1c1d7e
    SDict<MemberDef>::IteratorDict mdi(*memberSDict);
Packit 1c1d7e
    MemberDef *md;
Packit 1c1d7e
    int count=0;
Packit 1c1d7e
    for (mdi.toFirst();(md=mdi.current());++mdi)
Packit 1c1d7e
    {
Packit 1c1d7e
      //printf("  marshalMemberSDict: %d: key=%s value=%p\n",count,mdi.currentKey().data(),md);
Packit 1c1d7e
      marshalQCString(s,mdi.currentKey());
Packit 1c1d7e
      marshalObjPointer(s,md);
Packit 1c1d7e
      count++;
Packit 1c1d7e
    }
Packit 1c1d7e
    assert(count==memberSDict->count());
Packit 1c1d7e
  }
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalDocInfo(StorageIntf *s,DocInfo *docInfo)
Packit 1c1d7e
{
Packit 1c1d7e
  if (docInfo==0)
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,NULL_LIST); // null pointer representation
Packit 1c1d7e
  }
Packit 1c1d7e
  else
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,1); 
Packit 1c1d7e
    marshalQCString(s,docInfo->doc);
Packit 1c1d7e
    marshalInt(s,docInfo->line);
Packit 1c1d7e
    marshalQCString(s,docInfo->file);
Packit 1c1d7e
  }
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalBriefInfo(StorageIntf *s,BriefInfo *briefInfo)
Packit 1c1d7e
{
Packit 1c1d7e
  if (briefInfo==0)
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,NULL_LIST); // null pointer representation
Packit 1c1d7e
  }
Packit 1c1d7e
  else
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,1); 
Packit 1c1d7e
    marshalQCString(s,briefInfo->doc);
Packit 1c1d7e
    marshalQCString(s,briefInfo->tooltip);
Packit 1c1d7e
    marshalInt(s,briefInfo->line);
Packit 1c1d7e
    marshalQCString(s,briefInfo->file);
Packit 1c1d7e
  }
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalBodyInfo(StorageIntf *s,BodyInfo *bodyInfo)
Packit 1c1d7e
{
Packit 1c1d7e
  if (bodyInfo==0)
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,NULL_LIST); // null pointer representation
Packit 1c1d7e
  }
Packit 1c1d7e
  else
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,1); 
Packit 1c1d7e
    marshalInt(s,bodyInfo->startLine);
Packit 1c1d7e
    marshalInt(s,bodyInfo->endLine);
Packit 1c1d7e
    marshalObjPointer(s,bodyInfo->fileDef);
Packit 1c1d7e
  }
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalGroupList(StorageIntf *s,GroupList *groupList)
Packit 1c1d7e
{
Packit 1c1d7e
  if (groupList==0)
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,NULL_LIST); // null pointer representation
Packit 1c1d7e
  }
Packit 1c1d7e
  else
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,groupList->count());
Packit 1c1d7e
    QListIterator<GroupDef> gli(*groupList);
Packit 1c1d7e
    GroupDef *gd=0;
Packit 1c1d7e
    for (gli.toFirst();(gd=gli.current());++gli)
Packit 1c1d7e
    {
Packit 1c1d7e
      marshalObjPointer(s,gd);
Packit 1c1d7e
    }
Packit 1c1d7e
  }
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalMemberList(StorageIntf *s,MemberList *ml)
Packit 1c1d7e
{
Packit 1c1d7e
  if (ml==0)
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,NULL_LIST); // null pointer representation
Packit 1c1d7e
  }
Packit 1c1d7e
  else
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,ml->count());
Packit 1c1d7e
    MemberListIterator mli(*ml);
Packit 1c1d7e
    MemberDef *md;
Packit 1c1d7e
    uint count=0;
Packit 1c1d7e
    for (mli.toFirst();(md=mli.current());++mli)
Packit 1c1d7e
    {
Packit 1c1d7e
      marshalObjPointer(s,md);
Packit 1c1d7e
      count++;
Packit 1c1d7e
    }
Packit 1c1d7e
    assert(count==ml->count());
Packit 1c1d7e
Packit 1c1d7e
    ml->marshal(s);
Packit 1c1d7e
  }
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalExampleSDict(StorageIntf *s,ExampleSDict *ed)
Packit 1c1d7e
{
Packit 1c1d7e
  if (ed==0)
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,NULL_LIST); // null pointer representation
Packit 1c1d7e
  }
Packit 1c1d7e
  else
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,ed->count());
Packit 1c1d7e
    //printf("  marshalMemberSDict: items=%d\n",memberSDict->count());
Packit 1c1d7e
    SDict<Example>::IteratorDict edi(*ed);
Packit 1c1d7e
    Example *e;
Packit 1c1d7e
    for (edi.toFirst();(e=edi.current());++edi)
Packit 1c1d7e
    {
Packit 1c1d7e
      //printf("  marshalMemberSDict: %d: key=%s value=%p\n",count,mdi.currentKey().data(),md);
Packit 1c1d7e
      marshalQCString(s,edi.currentKey());
Packit 1c1d7e
      marshalQCString(s,e->anchor);
Packit 1c1d7e
      marshalQCString(s,e->name);
Packit 1c1d7e
      marshalQCString(s,e->file);
Packit 1c1d7e
    }
Packit 1c1d7e
  }
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalMemberLists(StorageIntf *s,SDict<MemberList> *mls)
Packit 1c1d7e
{
Packit 1c1d7e
  if (mls==0)
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,NULL_LIST); // null pointer representation
Packit 1c1d7e
  }
Packit 1c1d7e
  else
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalUInt(s,mls->count());
Packit 1c1d7e
    //printf("  marshalMemberSDict: items=%d\n",memberSDict->count());
Packit 1c1d7e
    SDict<MemberList>::IteratorDict mli(*mls);
Packit 1c1d7e
    MemberList *ml;
Packit 1c1d7e
    for (mli.toFirst();(ml=mli.current());++mli)
Packit 1c1d7e
    {
Packit 1c1d7e
      //printf("  marshalMemberSDict: %d: key=%s value=%p\n",count,mdi.currentKey().data(),md);
Packit 1c1d7e
      marshalQCString(s,mli.currentKey());
Packit 1c1d7e
      marshalObjPointer(s,ml); // assume we are not owner of the list
Packit 1c1d7e
    }
Packit 1c1d7e
  }
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalEntry(StorageIntf *s,Entry *e)
Packit 1c1d7e
{
Packit 1c1d7e
  marshalUInt(s,HEADER);
Packit 1c1d7e
  marshalQCString(s,e->name);
Packit 1c1d7e
  marshalQCString(s,e->type);
Packit 1c1d7e
  marshalInt(s,e->section);
Packit 1c1d7e
  marshalInt(s,(int)e->protection);
Packit 1c1d7e
  marshalInt(s,(int)e->mtype);
Packit 1c1d7e
  marshalUInt64(s,e->spec);
Packit 1c1d7e
  marshalInt(s,e->initLines);
Packit 1c1d7e
  marshalBool(s,e->stat);
Packit 1c1d7e
  marshalBool(s,e->explicitExternal);
Packit 1c1d7e
  marshalBool(s,e->proto);
Packit 1c1d7e
  marshalBool(s,e->subGrouping);
Packit 1c1d7e
  marshalBool(s,e->callGraph);
Packit 1c1d7e
  marshalBool(s,e->callerGraph);
Packit 1c1d7e
  marshalInt(s,(int)e->virt);
Packit 1c1d7e
  marshalQCString(s,e->args);
Packit 1c1d7e
  marshalQCString(s,e->bitfields);
Packit 1c1d7e
  marshalArgumentList(s,e->argList);
Packit 1c1d7e
  marshalArgumentLists(s,e->tArgLists);
Packit 1c1d7e
  marshalQGString(s,e->program);
Packit 1c1d7e
  marshalQGString(s,e->initializer);
Packit 1c1d7e
  marshalQCString(s,e->includeFile);
Packit 1c1d7e
  marshalQCString(s,e->includeName);
Packit 1c1d7e
  marshalQCString(s,e->doc);
Packit 1c1d7e
  marshalInt(s,e->docLine);
Packit 1c1d7e
  marshalQCString(s,e->docFile);
Packit 1c1d7e
  marshalQCString(s,e->brief);
Packit 1c1d7e
  marshalInt(s,e->briefLine);
Packit 1c1d7e
  marshalQCString(s,e->briefFile);
Packit 1c1d7e
  marshalQCString(s,e->inbodyDocs);
Packit 1c1d7e
  marshalInt(s,e->inbodyLine);
Packit 1c1d7e
  marshalQCString(s,e->inbodyFile);
Packit 1c1d7e
  marshalQCString(s,e->relates);
Packit 1c1d7e
  marshalInt(s,e->relatesType);
Packit 1c1d7e
  marshalQCString(s,e->read);
Packit 1c1d7e
  marshalQCString(s,e->write);
Packit 1c1d7e
  marshalQCString(s,e->inside);
Packit 1c1d7e
  marshalQCString(s,e->exception);
Packit 1c1d7e
  marshalArgumentList(s,e->typeConstr);
Packit 1c1d7e
  marshalInt(s,e->bodyLine);
Packit 1c1d7e
  marshalInt(s,e->endBodyLine);
Packit 1c1d7e
  marshalInt(s,e->mGrpId);
Packit 1c1d7e
  marshalBaseInfoList(s,e->extends);
Packit 1c1d7e
  marshalGroupingList(s,e->groups);
Packit 1c1d7e
  marshalSectionInfoList(s,e->anchors);
Packit 1c1d7e
  marshalQCString(s,e->fileName);
Packit 1c1d7e
  marshalInt(s,e->startLine);
Packit 1c1d7e
  marshalItemInfoList(s,e->sli);
Packit 1c1d7e
  marshalInt(s,(int)e->lang);
Packit 1c1d7e
  marshalBool(s,e->hidden);
Packit 1c1d7e
  marshalBool(s,e->artificial);
Packit 1c1d7e
  marshalInt(s,(int)e->groupDocType);
Packit 1c1d7e
  marshalQCString(s,e->id);
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void marshalEntryTree(StorageIntf *s,Entry *e)
Packit 1c1d7e
{
Packit 1c1d7e
  marshalEntry(s,e);
Packit 1c1d7e
  marshalUInt(s,e->children()->count());
Packit 1c1d7e
  QListIterator<Entry> eli(*e->children());
Packit 1c1d7e
  Entry *child;
Packit 1c1d7e
  for (eli.toFirst();(child=eli.current());++eli)
Packit 1c1d7e
  {
Packit 1c1d7e
    marshalEntryTree(s,child);
Packit 1c1d7e
  }
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
//------------------------------------------------------------------
Packit 1c1d7e
Packit 1c1d7e
int unmarshalInt(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uchar b[4];
Packit 1c1d7e
  s->read((char *)b,4);
Packit 1c1d7e
  int result=(int)((((uint)b[0])<<24)+((uint)b[1]<<16)+((uint)b[2]<<8)+(uint)b[3]);
Packit 1c1d7e
  //printf("unmarshalInt: %x %x %x %x: %x offset=%llx\n",b[0],b[1],b[2],b[3],result,f.pos());
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
uint unmarshalUInt(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uchar b[4];
Packit 1c1d7e
  s->read((char *)b,4);
Packit 1c1d7e
  uint result=(((uint)b[0])<<24)+((uint)b[1]<<16)+((uint)b[2]<<8)+(uint)b[3];
Packit 1c1d7e
  //printf("unmarshalUInt: %x %x %x %x: %x offset=%llx\n",b[0],b[1],b[2],b[3],result,f.pos());
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
uint64 unmarshalUInt64(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uint64 result=uint64(unmarshalUInt(s))<<32;
Packit 1c1d7e
  result|=unmarshalUInt(s);
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
bool unmarshalBool(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  char result;
Packit 1c1d7e
  s->read(&result,sizeof(result));
Packit 1c1d7e
  //printf("unmarshalBool: %x offset=%llx\n",result,f.pos());
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
QCString unmarshalQCString(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uint len = unmarshalUInt(s);
Packit 1c1d7e
  //printf("unmarshalQCString: len=%d offset=%llx\n",len,f.pos());
Packit 1c1d7e
  QCString result(len+1);
Packit 1c1d7e
  result.at(len)='\0';
Packit 1c1d7e
  if (len>0)
Packit 1c1d7e
  {
Packit 1c1d7e
    s->read(result.rawData(),len);
Packit 1c1d7e
  }
Packit 1c1d7e
  //printf("unmarshalQCString: result=%s\n",result.data());
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
QGString unmarshalQGString(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uint len = unmarshalUInt(s);
Packit 1c1d7e
  //printf("unmarshalQCString: len=%d offset=%llx\n",len,f.pos());
Packit 1c1d7e
  QGString result(len+1);
Packit 1c1d7e
  result.at(len)='\0';
Packit 1c1d7e
  if (len>0)
Packit 1c1d7e
  {
Packit 1c1d7e
    s->read(result.data(),len);
Packit 1c1d7e
  }
Packit 1c1d7e
  //printf("unmarshalQCString: result=%s\n",result.data());
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
ArgumentList *unmarshalArgumentList(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  return ArgumentList::unmarshal(s);
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
QList<ArgumentList> *unmarshalArgumentLists(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uint i;
Packit 1c1d7e
  uint count = unmarshalUInt(s);
Packit 1c1d7e
  if (count==NULL_LIST) return 0; // null list
Packit 1c1d7e
  QList<ArgumentList> *result = new QList<ArgumentList>;
Packit 1c1d7e
  result->setAutoDelete(TRUE);
Packit 1c1d7e
  assert(count<1000000);
Packit 1c1d7e
  //printf("unmarshalArgumentLists: %d\n",count);
Packit 1c1d7e
  for (i=0;i
Packit 1c1d7e
  {
Packit 1c1d7e
    result->append(unmarshalArgumentList(s));
Packit 1c1d7e
  }
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
QList<BaseInfo> *unmarshalBaseInfoList(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uint i;
Packit 1c1d7e
  uint count = unmarshalUInt(s);
Packit 1c1d7e
  if (count==NULL_LIST) return 0; // null list
Packit 1c1d7e
  QList<BaseInfo> *result = new QList<BaseInfo>;
Packit 1c1d7e
  result->setAutoDelete(TRUE);
Packit 1c1d7e
  assert(count<1000000);
Packit 1c1d7e
  for (i=0;i
Packit 1c1d7e
  {
Packit 1c1d7e
    QCString name   = unmarshalQCString(s);
Packit 1c1d7e
    Protection prot = (Protection)unmarshalInt(s);
Packit 1c1d7e
    Specifier virt  = (Specifier)unmarshalInt(s);
Packit 1c1d7e
    result->append(new BaseInfo(name,prot,virt));
Packit 1c1d7e
  }
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
QList<Grouping> *unmarshalGroupingList(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uint i;
Packit 1c1d7e
  uint count = unmarshalUInt(s);
Packit 1c1d7e
  if (count==NULL_LIST) return 0; // null list
Packit 1c1d7e
  QList<Grouping> *result = new QList<Grouping>;
Packit 1c1d7e
  result->setAutoDelete(TRUE);
Packit 1c1d7e
  assert(count<1000000);
Packit 1c1d7e
  for (i=0;i
Packit 1c1d7e
  {
Packit 1c1d7e
    QCString name = unmarshalQCString(s);
Packit 1c1d7e
    Grouping::GroupPri_t prio = (Grouping::GroupPri_t)unmarshalInt(s);
Packit 1c1d7e
    result->append(new Grouping(name,prio));
Packit 1c1d7e
  }
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
QList<SectionInfo> *unmarshalSectionInfoList(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uint i;
Packit 1c1d7e
  uint count = unmarshalUInt(s);
Packit 1c1d7e
  if (count==NULL_LIST) return 0; // null list
Packit 1c1d7e
  QList<SectionInfo> *result = new QList<SectionInfo>;
Packit 1c1d7e
  result->setAutoDelete(TRUE);
Packit 1c1d7e
  assert(count<1000000);
Packit 1c1d7e
  for (i=0;i
Packit 1c1d7e
  { 
Packit 1c1d7e
    QCString label = unmarshalQCString(s);
Packit 1c1d7e
    QCString title = unmarshalQCString(s);
Packit 1c1d7e
    QCString ref   = unmarshalQCString(s);
Packit 1c1d7e
    SectionInfo::SectionType type = (SectionInfo::SectionType)unmarshalInt(s);
Packit 1c1d7e
    QCString fileName = unmarshalQCString(s);
Packit 1c1d7e
    int lineNr = unmarshalInt(s);
Packit 1c1d7e
    int level = unmarshalInt(s);
Packit 1c1d7e
    result->append(new SectionInfo(fileName,lineNr,label,title,type,level,ref));
Packit 1c1d7e
  }
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
QList<ListItemInfo> *unmarshalItemInfoList(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uint i;
Packit 1c1d7e
  uint count = unmarshalUInt(s);
Packit 1c1d7e
  if (count==NULL_LIST) return 0; // null list
Packit 1c1d7e
  QList<ListItemInfo> *result = new QList<ListItemInfo>;
Packit 1c1d7e
  result->setAutoDelete(TRUE);
Packit 1c1d7e
  assert(count<1000000);
Packit 1c1d7e
  for (i=0;i
Packit 1c1d7e
  { 
Packit 1c1d7e
    ListItemInfo *lii = new ListItemInfo;
Packit 1c1d7e
    lii->type   = unmarshalQCString(s);
Packit 1c1d7e
    lii->itemId = unmarshalInt(s);
Packit 1c1d7e
    result->append(lii);
Packit 1c1d7e
  }
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
void *unmarshalObjPointer(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  void *result;
Packit 1c1d7e
  s->read((char *)&result,sizeof(void*));
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
SectionDict *unmarshalSectionDict(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uint i;
Packit 1c1d7e
  uint count = unmarshalUInt(s);
Packit 1c1d7e
  //printf("unmarshalSectionDict count=%d\n",count);
Packit 1c1d7e
  if (count==NULL_LIST) return 0; // null list
Packit 1c1d7e
  SectionDict *result = new SectionDict(17);
Packit 1c1d7e
  assert(count<1000000);
Packit 1c1d7e
  for (i=0;i
Packit 1c1d7e
  {
Packit 1c1d7e
    QCString key    = unmarshalQCString(s);
Packit 1c1d7e
    SectionInfo *si = (SectionInfo *)unmarshalObjPointer(s);
Packit 1c1d7e
    //printf("  unmarshalSectionDict i=%d key=%s si=%s\n",count,key.data(),si->label.data());
Packit 1c1d7e
    result->append(key,si);
Packit 1c1d7e
  }
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
MemberSDict *unmarshalMemberSDict(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uint i;
Packit 1c1d7e
  uint count = unmarshalUInt(s);
Packit 1c1d7e
  //printf("--- unmarshalMemberSDict count=%d\n",count);
Packit 1c1d7e
  if (count==NULL_LIST) 
Packit 1c1d7e
  {
Packit 1c1d7e
    //printf("--- end unmarshalMemberSDict\n");
Packit 1c1d7e
    return 0; // null list
Packit 1c1d7e
  }
Packit 1c1d7e
  MemberSDict *result = new MemberSDict;
Packit 1c1d7e
  assert(count<1000000);
Packit 1c1d7e
  //printf("Reading %d key-value pairs\n",count);
Packit 1c1d7e
  for (i=0;i
Packit 1c1d7e
  {
Packit 1c1d7e
    //printf("  unmarshaling pair %d\n",i);
Packit 1c1d7e
    QCString key    = unmarshalQCString(s);
Packit 1c1d7e
    //printf("  unmarshaling key %s\n",key.data());
Packit 1c1d7e
    MemberDef *md = (MemberDef *)unmarshalObjPointer(s);
Packit 1c1d7e
    //printf("  unmarshalMemberSDict i=%d key=%s md=%p\n",i,key.data(),md);
Packit 1c1d7e
    result->append(key,md); 
Packit 1c1d7e
  }
Packit 1c1d7e
Packit 1c1d7e
  //printf("--- end unmarshalMemberSDict\n");
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
DocInfo *unmarshalDocInfo(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uint count = unmarshalUInt(s); 
Packit 1c1d7e
  if (count==NULL_LIST) return 0;
Packit 1c1d7e
  DocInfo *result = new DocInfo;
Packit 1c1d7e
  result->doc  = unmarshalQCString(s);
Packit 1c1d7e
  result->line = unmarshalInt(s);
Packit 1c1d7e
  result->file = unmarshalQCString(s);
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
BriefInfo *unmarshalBriefInfo(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uint count = unmarshalUInt(s); 
Packit 1c1d7e
  if (count==NULL_LIST) return 0;
Packit 1c1d7e
  BriefInfo *result = new BriefInfo;
Packit 1c1d7e
  result->doc     = unmarshalQCString(s);
Packit 1c1d7e
  result->tooltip = unmarshalQCString(s);
Packit 1c1d7e
  result->line    = unmarshalInt(s);
Packit 1c1d7e
  result->file    = unmarshalQCString(s);
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
BodyInfo *unmarshalBodyInfo(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uint count = unmarshalUInt(s); 
Packit 1c1d7e
  if (count==NULL_LIST) return 0;
Packit 1c1d7e
  BodyInfo *result = new BodyInfo;
Packit 1c1d7e
  result->startLine = unmarshalInt(s);
Packit 1c1d7e
  result->endLine   = unmarshalInt(s);
Packit 1c1d7e
  result->fileDef   = (FileDef*)unmarshalObjPointer(s);
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
GroupList *unmarshalGroupList(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uint i;
Packit 1c1d7e
  uint count = unmarshalUInt(s);
Packit 1c1d7e
  if (count==NULL_LIST) return 0; // null list
Packit 1c1d7e
  assert(count<1000000);
Packit 1c1d7e
  GroupList *result = new GroupList;
Packit 1c1d7e
  for (i=0;i
Packit 1c1d7e
  {
Packit 1c1d7e
    GroupDef *gd = (GroupDef *)unmarshalObjPointer(s);
Packit 1c1d7e
    result->append(gd);
Packit 1c1d7e
  }
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
MemberList *unmarshalMemberList(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uint i;
Packit 1c1d7e
  uint count = unmarshalUInt(s); 
Packit 1c1d7e
  if (count==NULL_LIST) return 0;
Packit 1c1d7e
  MemberList *result = new MemberList;
Packit 1c1d7e
  assert(count<1000000);
Packit 1c1d7e
  for (i=0;i
Packit 1c1d7e
  {
Packit 1c1d7e
    MemberDef *md = (MemberDef*)unmarshalObjPointer(s);
Packit 1c1d7e
    result->append(md);
Packit 1c1d7e
  }
Packit 1c1d7e
  result->unmarshal(s);
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
ExampleSDict *unmarshalExampleSDict(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uint i;
Packit 1c1d7e
  uint count = unmarshalUInt(s); 
Packit 1c1d7e
  if (count==NULL_LIST) return 0;
Packit 1c1d7e
  ExampleSDict *result = new ExampleSDict;
Packit 1c1d7e
  assert(count<1000000);
Packit 1c1d7e
  for (i=0;i
Packit 1c1d7e
  {
Packit 1c1d7e
    QCString key = unmarshalQCString(s);
Packit 1c1d7e
    Example *e = new Example;
Packit 1c1d7e
    e->anchor = unmarshalQCString(s);
Packit 1c1d7e
    e->name   = unmarshalQCString(s);
Packit 1c1d7e
    e->file   = unmarshalQCString(s);
Packit 1c1d7e
    result->inSort(key,e);
Packit 1c1d7e
  }
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
SDict<MemberList> *unmarshalMemberLists(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  uint i;
Packit 1c1d7e
  uint count = unmarshalUInt(s); 
Packit 1c1d7e
  if (count==NULL_LIST) return 0;
Packit 1c1d7e
  SDict<MemberList> *result = new SDict<MemberList>(7);
Packit 1c1d7e
  assert(count<1000000);
Packit 1c1d7e
  for (i=0;i
Packit 1c1d7e
  {
Packit 1c1d7e
    QCString key = unmarshalQCString(s);
Packit 1c1d7e
    MemberList *ml = (MemberList *)unmarshalObjPointer(s);
Packit 1c1d7e
    result->append(key,ml);
Packit 1c1d7e
  }
Packit 1c1d7e
  return result;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
Entry * unmarshalEntry(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  Entry *e = new Entry;
Packit 1c1d7e
  uint header=unmarshalUInt(s);
Packit 1c1d7e
  ASSERT(header==HEADER);
Packit 1c1d7e
  e->name             = unmarshalQCString(s);
Packit 1c1d7e
  e->type             = unmarshalQCString(s);
Packit 1c1d7e
  e->section          = unmarshalInt(s);
Packit 1c1d7e
  e->protection       = (Protection)unmarshalInt(s);
Packit 1c1d7e
  e->mtype            = (MethodTypes)unmarshalInt(s);
Packit 1c1d7e
  e->spec             = unmarshalUInt64(s);
Packit 1c1d7e
  e->initLines        = unmarshalInt(s);
Packit 1c1d7e
  e->stat             = unmarshalBool(s);
Packit 1c1d7e
  e->explicitExternal = unmarshalBool(s);
Packit 1c1d7e
  e->proto            = unmarshalBool(s);
Packit 1c1d7e
  e->subGrouping      = unmarshalBool(s);
Packit 1c1d7e
  e->callGraph        = unmarshalBool(s);
Packit 1c1d7e
  e->callerGraph      = unmarshalBool(s);
Packit 1c1d7e
  e->virt             = (Specifier)unmarshalInt(s);
Packit 1c1d7e
  e->args             = unmarshalQCString(s);
Packit 1c1d7e
  e->bitfields        = unmarshalQCString(s);
Packit 1c1d7e
  delete e->argList;
Packit 1c1d7e
  e->argList          = unmarshalArgumentList(s);
Packit 1c1d7e
  e->tArgLists        = unmarshalArgumentLists(s);
Packit 1c1d7e
  e->program          = unmarshalQGString(s);
Packit 1c1d7e
  e->initializer      = unmarshalQGString(s);
Packit 1c1d7e
  e->includeFile      = unmarshalQCString(s);
Packit 1c1d7e
  e->includeName      = unmarshalQCString(s);
Packit 1c1d7e
  e->doc              = unmarshalQCString(s);
Packit 1c1d7e
  e->docLine          = unmarshalInt(s);
Packit 1c1d7e
  e->docFile          = unmarshalQCString(s);
Packit 1c1d7e
  e->brief            = unmarshalQCString(s);
Packit 1c1d7e
  e->briefLine        = unmarshalInt(s);
Packit 1c1d7e
  e->briefFile        = unmarshalQCString(s);
Packit 1c1d7e
  e->inbodyDocs       = unmarshalQCString(s);
Packit 1c1d7e
  e->inbodyLine       = unmarshalInt(s);
Packit 1c1d7e
  e->inbodyFile       = unmarshalQCString(s);
Packit 1c1d7e
  e->relates          = unmarshalQCString(s);
Packit 1c1d7e
  e->relatesType      = (RelatesType)unmarshalInt(s);
Packit 1c1d7e
  e->read             = unmarshalQCString(s);
Packit 1c1d7e
  e->write            = unmarshalQCString(s);
Packit 1c1d7e
  e->inside           = unmarshalQCString(s);
Packit 1c1d7e
  e->exception        = unmarshalQCString(s);
Packit 1c1d7e
  e->typeConstr       = unmarshalArgumentList(s);
Packit 1c1d7e
  e->bodyLine         = unmarshalInt(s);
Packit 1c1d7e
  e->endBodyLine      = unmarshalInt(s);
Packit 1c1d7e
  e->mGrpId           = unmarshalInt(s);
Packit 1c1d7e
  delete e->extends;
Packit 1c1d7e
  e->extends          = unmarshalBaseInfoList(s);
Packit 1c1d7e
  delete e->groups;
Packit 1c1d7e
  e->groups           = unmarshalGroupingList(s);
Packit 1c1d7e
  delete e->anchors;
Packit 1c1d7e
  e->anchors          = unmarshalSectionInfoList(s);
Packit 1c1d7e
  e->fileName         = unmarshalQCString(s);
Packit 1c1d7e
  e->startLine        = unmarshalInt(s);
Packit 1c1d7e
  e->sli              = unmarshalItemInfoList(s);
Packit 1c1d7e
  e->lang             = (SrcLangExt)unmarshalInt(s);
Packit 1c1d7e
  e->hidden           = unmarshalBool(s);
Packit 1c1d7e
  e->artificial       = unmarshalBool(s);
Packit 1c1d7e
  e->groupDocType     = (Entry::GroupDocType)unmarshalInt(s);
Packit 1c1d7e
  e->id               = unmarshalQCString(s);
Packit 1c1d7e
  return e;
Packit 1c1d7e
}
Packit 1c1d7e
Packit 1c1d7e
Entry * unmarshalEntryTree(StorageIntf *s)
Packit 1c1d7e
{
Packit 1c1d7e
  Entry *e = unmarshalEntry(s);
Packit 1c1d7e
  uint count = unmarshalUInt(s);
Packit 1c1d7e
  uint i;
Packit 1c1d7e
  for (i=0;i
Packit 1c1d7e
  {
Packit 1c1d7e
    e->addSubEntry(unmarshalEntryTree(s));
Packit 1c1d7e
  }
Packit 1c1d7e
  return e;
Packit 1c1d7e
}