blob: 0a40878c1a18d35fd1b3c188530c404472e5128d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
#ifndef DBENTRIES_H
#define DBENTRIES_H
#include <db4/db_cxx.h>
#include <qstring.h>
#include <qbuffer.h>
#include <qmap.h>
#include <qstringlist.h>
#include <qdatetime.h>
class CatalogInfo
{
QString author;
QDateTime datetime;
QString filename;
QString filepath;
};
class ResultInfo
{
public:
//Common info
QString original; //placeholder
//
//Multi reference info
QValueList<CatalogInfo> catalogs;
QString info;
};
class InputInfo
{
public:
unsigned int ref() {return 1;}
};
class DBItem : public Dbt
{
public:
virtual ~DBItem(){}
virtual bool isEmpty(){return empty;}
//void fromDbt(Dbt *dbt);
void set();
void get();
protected:
virtual void read(QDataStream *s) = 0;
virtual void write(QDataStream *s) = 0;
QByteArray mydata;
bool empty;
};
class DBItemMainKey : public DBItem
{
public:
DBItemMainKey();
DBItemMainKey(QString searchstring);
QString getString(){ return sstr;}
private:
virtual void read(QDataStream *s);
virtual void write(QDataStream *s);
QString sstr;
};
class DBItemMainData : public DBItem
{
public:
typedef QMapIterator<QString,QValueList<unsigned int> > TranslationIterator;
typedef QMap<QString,QValueList<unsigned int> > TranslationMap;
DBItemMainData();
QStringList getTranslations();
QValueList<unsigned int> getReferences(QString str);
void clear();
//Add a translation with reference ref, if translation exists append
// ref to the list of references
void addTranslation(QString str,unsigned int ref);
void removeTranslation(QString str,unsigned int ref);
//remove any reference to ref, if ref is the only reference of a translation
// the translation is removed
void removeRef(unsigned int ref);
unsigned int getIndexnumber(){ return indexnumber; }
void setIndexnumber(int i){ indexnumber=i; }
private:
virtual void read(QDataStream *s);
virtual void write(QDataStream *s);
unsigned int indexnumber;
TranslationMap translations;
};
class DBItemMultiIndex : public DBItem
{
public:
typedef QValueList<unsigned int> IndexList;
DBItemMultiIndex();
// DBItemMultiIndex(IndexList l);
void addEntry(unsigned int index);
void removeEntry(unsigned int index);
IndexList getList(){ return list;}
void clear() {list.clear();}
private:
virtual void read(QDataStream *s);
virtual void write(QDataStream *s);
IndexList list;
};
class DBItemNum : public Dbt
{
public:
DBItemNum(){
set_data(&num);
set_size(4);
num=0;
}
DBItemNum(unsigned int i){
set_data(&num);
set_size(4);
num=i;
}
unsigned int getNum(){ num=*(unsigned int *)get_data(); return num;}
private:
unsigned int num;
};
#endif
|