Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/util/doxygen/src/marshal.h

Source at commit 1322 created 9 years 5 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
9class ArgumentList;
10struct BaseInfo;
11struct Grouping;
12struct SectionInfo;
13struct ListItemInfo;
14class QCString;
15class QGString;
16class SectionDict;
17class MemberSDict;
18class GroupList;
19struct BodyInfo;
20struct DocInfo;
21struct BriefInfo;
22class MemberList;
23class ExampleSDict;
24class Entry;
25
26#define NULL_LIST 0xffffffff
27
28class 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
37class 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
82void marshalInt(StorageIntf *s,int v);
83void marshalUInt(StorageIntf *s,uint v);
84void marshalBool(StorageIntf *s,bool b);
85void marshalQCString(StorageIntf *s,const QCString &str);
86void marshalQGString(StorageIntf *s,const QGString &str);
87void marshalArgumentList(StorageIntf *s,ArgumentList *argList);
88void marshalArgumentLists(StorageIntf *s,QList<ArgumentList> *argLists);
89void marshalBaseInfoList(StorageIntf *s, QList<BaseInfo> *baseList);
90void marshalGroupingList(StorageIntf *s, QList<Grouping> *groups);
91void marshalSectionInfoList(StorageIntf *s, QList<SectionInfo> *anchors);
92void marshalItemInfoList(StorageIntf *s, QList<ListItemInfo> *sli);
93void marshalObjPointer(StorageIntf *s,void *obj);
94void marshalSectionDict(StorageIntf *s,SectionDict *sections);
95void marshalMemberSDict(StorageIntf *s,MemberSDict *memberSDict);
96void marshalDocInfo(StorageIntf *s,DocInfo *docInfo);
97void marshalBriefInfo(StorageIntf *s,BriefInfo *briefInfo);
98void marshalBodyInfo(StorageIntf *s,BodyInfo *bodyInfo);
99void marshalGroupList(StorageIntf *s,GroupList *groupList);
100void marshalMemberList(StorageIntf *s,MemberList *ml);
101void marshalExampleSDict(StorageIntf *s,ExampleSDict *ed);
102void marshalMemberLists(StorageIntf *s,SDict<MemberList> *mls);
103void marshalEntry(StorageIntf *s,Entry *e);
104void marshalEntryTree(StorageIntf *s,Entry *e);
105
106//----- unmarshaling function: byte stream -> datatype ------------------
107
108int unmarshalInt(StorageIntf *s);
109uint unmarshalUInt(StorageIntf *s);
110bool unmarshalBool(StorageIntf *s);
111QCString unmarshalQCString(StorageIntf *s);
112QGString unmarshalQGString(StorageIntf *s);
113ArgumentList * unmarshalArgumentList(StorageIntf *s);
114QList<ArgumentList> *unmarshalArgumentLists(StorageIntf *s);
115QList<BaseInfo> * unmarshalBaseInfoList(StorageIntf *s);
116QList<Grouping> * unmarshalGroupingList(StorageIntf *s);
117QList<SectionInfo> * unmarshalSectionInfoList(StorageIntf *s);
118QList<ListItemInfo> *unmarshalItemInfoList(StorageIntf *s);
119void * unmarshalObjPointer(StorageIntf *s);
120SectionDict * unmarshalSectionDict(StorageIntf *s);
121MemberSDict * unmarshalMemberSDict(StorageIntf *s);
122DocInfo * unmarshalDocInfo(StorageIntf *s);
123BriefInfo * unmarshalBriefInfo(StorageIntf *s);
124BodyInfo * unmarshalBodyInfo(StorageIntf *s);
125GroupList * unmarshalGroupList(StorageIntf *s);
126MemberList * unmarshalMemberList(StorageIntf *s);
127ExampleSDict * unmarshalExampleSDict(StorageIntf *s);
128SDict<MemberList> * unmarshalMemberLists(StorageIntf *s);
129Entry * unmarshalEntry(StorageIntf *s);
130Entry * unmarshalEntryTree(StorageIntf *s);
131
132#endif
133

Archive Download this file

Revision: 1322