marshal.h

Go to the documentation of this file.
00001 #ifndef MARSHAL_H
00002 #define MARSHAL_H
00003 
00004 #include <qlist.h>
00005 #include <qfile.h>
00006 #include "sortdict.h"
00007 #include "store.h"
00008 
00009 class ArgumentList;
00010 struct BaseInfo;
00011 struct Grouping;
00012 struct SectionInfo;
00013 struct ListItemInfo;
00014 class QCString;
00015 class QGString;
00016 class SectionDict;
00017 class MemberSDict;
00018 class GroupList;
00019 struct BodyInfo;
00020 struct DocInfo;
00021 struct BriefInfo;
00022 class MemberList;
00023 class ExampleSDict;
00024 class Entry;
00025 
00026 #define NULL_LIST 0xffffffff
00027 
00028 class FileStorage : public QFile, public StorageIntf
00029 {
00030   public:
00031     FileStorage() : QFile() {}
00032     FileStorage( const QString &name) : QFile(name) {}
00033     int read(char *buf,uint size)        { return QFile::readBlock(buf,size); }
00034     int write(const char *buf,uint size) { return QFile::writeBlock(buf,size); }
00035 };
00036 
00037 class StreamStorage : public StorageIntf
00038 {
00039   public:
00040     StreamStorage()
00041     {
00042       m_data=0;
00043       m_offset=0;
00044       m_len=0;
00045     }
00046    ~StreamStorage()
00047     {
00048       delete m_data;
00049     }
00050     StreamStorage(char *data,uint len)
00051     {
00052       m_data=data;
00053       m_offset=0;
00054       m_len=len;
00055     }
00056     int read(char *buf,uint size)
00057     {
00058       int bytesLeft = QMIN((int)size,m_len-m_offset);
00059       if (bytesLeft>0) memcpy(buf,m_data,bytesLeft);
00060       m_offset+=bytesLeft;
00061       return bytesLeft;
00062     }
00063     int write(const char *buf,uint size)
00064     {
00065       m_data=(char *)realloc(m_data,m_offset+size);
00066       memcpy(m_data+m_offset,buf,size);
00067       m_offset+=size;
00068       m_len+=size;
00069       return size;
00070     }
00071     void rewind() { m_offset=0; }
00072     char *data() const { return m_data; }
00073     int size() { return m_len; }
00074   private:
00075     char *m_data;
00076     int m_offset;
00077     int m_len;
00078 };
00079 
00080 //----- marshaling function: datatype -> byte stream --------------------
00081 
00082 void marshalInt(StorageIntf *s,int v);
00083 void marshalUInt(StorageIntf *s,uint v);
00084 void marshalBool(StorageIntf *s,bool b);
00085 void marshalQCString(StorageIntf *s,const QCString &str);
00086 void marshalQGString(StorageIntf *s,const QGString &str);
00087 void marshalArgumentList(StorageIntf *s,ArgumentList *argList);
00088 void marshalArgumentLists(StorageIntf *s,QList<ArgumentList> *argLists);
00089 void marshalBaseInfoList(StorageIntf *s, QList<BaseInfo> *baseList);
00090 void marshalGroupingList(StorageIntf *s, QList<Grouping> *groups);
00091 void marshalSectionInfoList(StorageIntf *s, QList<SectionInfo> *anchors);
00092 void marshalItemInfoList(StorageIntf *s, QList<ListItemInfo> *sli);
00093 void marshalObjPointer(StorageIntf *s,void *obj);
00094 void marshalSectionDict(StorageIntf *s,SectionDict *sections);
00095 void marshalMemberSDict(StorageIntf *s,MemberSDict *memberSDict);
00096 void marshalDocInfo(StorageIntf *s,DocInfo *docInfo);
00097 void marshalBriefInfo(StorageIntf *s,BriefInfo *briefInfo);
00098 void marshalBodyInfo(StorageIntf *s,BodyInfo *bodyInfo);
00099 void marshalGroupList(StorageIntf *s,GroupList *groupList);
00100 void marshalMemberList(StorageIntf *s,MemberList *ml);
00101 void marshalExampleSDict(StorageIntf *s,ExampleSDict *ed);
00102 void marshalMemberLists(StorageIntf *s,SDict<MemberList> *mls);
00103 void marshalEntry(StorageIntf *s,Entry *e);
00104 void marshalEntryTree(StorageIntf *s,Entry *e);
00105 
00106 //----- unmarshaling function: byte stream -> datatype ------------------
00107 
00108 int                  unmarshalInt(StorageIntf *s);
00109 uint                 unmarshalUInt(StorageIntf *s);
00110 bool                 unmarshalBool(StorageIntf *s);
00111 QCString             unmarshalQCString(StorageIntf *s);
00112 QGString             unmarshalQGString(StorageIntf *s);
00113 ArgumentList *       unmarshalArgumentList(StorageIntf *s);
00114 QList<ArgumentList> *unmarshalArgumentLists(StorageIntf *s);
00115 QList<BaseInfo> *    unmarshalBaseInfoList(StorageIntf *s);
00116 QList<Grouping> *    unmarshalGroupingList(StorageIntf *s);
00117 QList<SectionInfo> * unmarshalSectionInfoList(StorageIntf *s);
00118 QList<ListItemInfo> *unmarshalItemInfoList(StorageIntf *s);
00119 void *               unmarshalObjPointer(StorageIntf *s);
00120 SectionDict *        unmarshalSectionDict(StorageIntf *s);
00121 MemberSDict *        unmarshalMemberSDict(StorageIntf *s);
00122 DocInfo *            unmarshalDocInfo(StorageIntf *s);
00123 BriefInfo *          unmarshalBriefInfo(StorageIntf *s);
00124 BodyInfo *           unmarshalBodyInfo(StorageIntf *s);
00125 GroupList *          unmarshalGroupList(StorageIntf *s);
00126 MemberList *         unmarshalMemberList(StorageIntf *s);
00127 ExampleSDict *       unmarshalExampleSDict(StorageIntf *s);
00128 SDict<MemberList> *  unmarshalMemberLists(StorageIntf *s);
00129 Entry *              unmarshalEntry(StorageIntf *s);
00130 Entry *              unmarshalEntryTree(StorageIntf *s);
00131 
00132 #endif



Generated on Mon Mar 31 10:58:40 2008 by  doxygen 1.5.1