Root/
Source at commit 1322 created 12 years 8 months ago. By meklort, Add doxygen to utils folder | |
---|---|
1 | #ifndef MARSHAL_H␊ |
2 | #define MARSHAL_H␊ |
3 | ␊ |
4 | #include <qlist.h>␊ |
5 | #include <qfile.h>␊ |
6 | #include "sortdict.h"␊ |
7 | #include "store.h"␊ |
8 | ␊ |
9 | class ArgumentList;␊ |
10 | struct BaseInfo;␊ |
11 | struct Grouping;␊ |
12 | struct SectionInfo;␊ |
13 | struct ListItemInfo;␊ |
14 | class QCString;␊ |
15 | class QGString;␊ |
16 | class SectionDict;␊ |
17 | class MemberSDict;␊ |
18 | class GroupList;␊ |
19 | struct BodyInfo;␊ |
20 | struct DocInfo;␊ |
21 | struct BriefInfo;␊ |
22 | class MemberList;␊ |
23 | class ExampleSDict;␊ |
24 | class Entry;␊ |
25 | ␊ |
26 | #define NULL_LIST 0xffffffff␊ |
27 | ␊ |
28 | class FileStorage : public QFile, public StorageIntf␊ |
29 | {␊ |
30 | public:␊ |
31 | FileStorage() : QFile() {}␊ |
32 | FileStorage( const QString &name) : QFile(name) {}␊ |
33 | int read(char *buf,uint size) { return QFile::readBlock(buf,size); }␊ |
34 | int write(const char *buf,uint size) { return QFile::writeBlock(buf,size); }␊ |
35 | };␊ |
36 | ␊ |
37 | class StreamStorage : public StorageIntf␊ |
38 | {␊ |
39 | public:␊ |
40 | StreamStorage()␊ |
41 | {␊ |
42 | m_data=0;␊ |
43 | m_offset=0;␊ |
44 | m_len=0;␊ |
45 | }␊ |
46 | ~StreamStorage()␊ |
47 | {␊ |
48 | delete m_data;␊ |
49 | }␊ |
50 | StreamStorage(char *data,uint len)␊ |
51 | {␊ |
52 | m_data=data;␊ |
53 | m_offset=0;␊ |
54 | m_len=len;␊ |
55 | }␊ |
56 | int read(char *buf,uint size)␊ |
57 | {␊ |
58 | int bytesLeft = QMIN((int)size,m_len-m_offset);␊ |
59 | if (bytesLeft>0) memcpy(buf,m_data,bytesLeft);␊ |
60 | m_offset+=bytesLeft;␊ |
61 | return bytesLeft;␊ |
62 | }␊ |
63 | int write(const char *buf,uint size)␊ |
64 | {␊ |
65 | m_data=(char *)realloc(m_data,m_offset+size);␊ |
66 | memcpy(m_data+m_offset,buf,size);␊ |
67 | m_offset+=size;␊ |
68 | m_len+=size;␊ |
69 | return size;␊ |
70 | }␊ |
71 | void rewind() { m_offset=0; }␊ |
72 | char *data() const { return m_data; }␊ |
73 | int size() { return m_len; }␊ |
74 | private:␊ |
75 | char *m_data;␊ |
76 | int m_offset;␊ |
77 | int m_len;␊ |
78 | };␊ |
79 | ␊ |
80 | //----- marshaling function: datatype -> byte stream --------------------␊ |
81 | ␊ |
82 | void marshalInt(StorageIntf *s,int v);␊ |
83 | void marshalUInt(StorageIntf *s,uint v);␊ |
84 | void marshalBool(StorageIntf *s,bool b);␊ |
85 | void marshalQCString(StorageIntf *s,const QCString &str);␊ |
86 | void marshalQGString(StorageIntf *s,const QGString &str);␊ |
87 | void marshalArgumentList(StorageIntf *s,ArgumentList *argList);␊ |
88 | void marshalArgumentLists(StorageIntf *s,QList<ArgumentList> *argLists);␊ |
89 | void marshalBaseInfoList(StorageIntf *s, QList<BaseInfo> *baseList);␊ |
90 | void marshalGroupingList(StorageIntf *s, QList<Grouping> *groups);␊ |
91 | void marshalSectionInfoList(StorageIntf *s, QList<SectionInfo> *anchors);␊ |
92 | void marshalItemInfoList(StorageIntf *s, QList<ListItemInfo> *sli);␊ |
93 | void marshalObjPointer(StorageIntf *s,void *obj);␊ |
94 | void marshalSectionDict(StorageIntf *s,SectionDict *sections);␊ |
95 | void marshalMemberSDict(StorageIntf *s,MemberSDict *memberSDict);␊ |
96 | void marshalDocInfo(StorageIntf *s,DocInfo *docInfo);␊ |
97 | void marshalBriefInfo(StorageIntf *s,BriefInfo *briefInfo);␊ |
98 | void marshalBodyInfo(StorageIntf *s,BodyInfo *bodyInfo);␊ |
99 | void marshalGroupList(StorageIntf *s,GroupList *groupList);␊ |
100 | void marshalMemberList(StorageIntf *s,MemberList *ml);␊ |
101 | void marshalExampleSDict(StorageIntf *s,ExampleSDict *ed);␊ |
102 | void marshalMemberLists(StorageIntf *s,SDict<MemberList> *mls);␊ |
103 | void marshalEntry(StorageIntf *s,Entry *e);␊ |
104 | void marshalEntryTree(StorageIntf *s,Entry *e);␊ |
105 | ␊ |
106 | //----- unmarshaling function: byte stream -> datatype ------------------␊ |
107 | ␊ |
108 | int unmarshalInt(StorageIntf *s);␊ |
109 | uint unmarshalUInt(StorageIntf *s);␊ |
110 | bool unmarshalBool(StorageIntf *s);␊ |
111 | QCString unmarshalQCString(StorageIntf *s);␊ |
112 | QGString unmarshalQGString(StorageIntf *s);␊ |
113 | ArgumentList * unmarshalArgumentList(StorageIntf *s);␊ |
114 | QList<ArgumentList> *unmarshalArgumentLists(StorageIntf *s);␊ |
115 | QList<BaseInfo> * unmarshalBaseInfoList(StorageIntf *s);␊ |
116 | QList<Grouping> * unmarshalGroupingList(StorageIntf *s);␊ |
117 | QList<SectionInfo> * unmarshalSectionInfoList(StorageIntf *s);␊ |
118 | QList<ListItemInfo> *unmarshalItemInfoList(StorageIntf *s);␊ |
119 | void * unmarshalObjPointer(StorageIntf *s);␊ |
120 | SectionDict * unmarshalSectionDict(StorageIntf *s);␊ |
121 | MemberSDict * unmarshalMemberSDict(StorageIntf *s);␊ |
122 | DocInfo * unmarshalDocInfo(StorageIntf *s);␊ |
123 | BriefInfo * unmarshalBriefInfo(StorageIntf *s);␊ |
124 | BodyInfo * unmarshalBodyInfo(StorageIntf *s);␊ |
125 | GroupList * unmarshalGroupList(StorageIntf *s);␊ |
126 | MemberList * unmarshalMemberList(StorageIntf *s);␊ |
127 | ExampleSDict * unmarshalExampleSDict(StorageIntf *s);␊ |
128 | SDict<MemberList> * unmarshalMemberLists(StorageIntf *s);␊ |
129 | Entry * unmarshalEntry(StorageIntf *s);␊ |
130 | Entry * unmarshalEntryTree(StorageIntf *s);␊ |
131 | ␊ |
132 | #endif␊ |
133 |