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