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
|
#include <qpro/common.h>
#include <iostream>
#include <qpro/record_factory.h>
#define NEWFUNC(x) static QpRec* NEW_##x (TQP_INT16 pLen, QpIStream& pIn) { return new x (pLen, pIn); }
NEWFUNC(QpRecBof)
NEWFUNC(QpRecBop)
NEWFUNC(QpRecEof)
NEWFUNC(QpRecEmptyCell)
NEWFUNC(QpRecFloatingPointCell)
NEWFUNC(QpRecFormulaCell)
NEWFUNC(QpRecIntegerCell)
NEWFUNC(QpRecLabelCell)
NEWFUNC(QpRecPageName)
NEWFUNC(QpRecPassword)
NEWFUNC(QpRecRecalcMode)
NEWFUNC(QpRecRecalcOrder)
struct Record
{
TQP_INT16 Type;
TQP_INT16 Len;
QpRec* (*Func)(TQP_INT16, QpIStream&);
};
// The functions in the Record table below (NEW_QpRecBof etc.)
// come from the NEWFUNC #define above
static Record gRecord[] =
{
{QpBof, 2, NEW_QpRecBof},
{QpEof, 0, NEW_QpRecEof},
{QpRecalcMode, 1, NEW_QpRecRecalcMode},
{QpRecalcOrder, 1, NEW_QpRecRecalcOrder},
{QpEmptyCell, 6, NEW_QpRecEmptyCell},
{QpIntegerCell, 8, NEW_QpRecIntegerCell},
{QpFloatingPointCell, 14, NEW_QpRecFloatingPointCell},
{QpLabelCell, 0, NEW_QpRecLabelCell},
{QpFormulaCell, 0, NEW_QpRecFormulaCell},
{QpBop, 0, NEW_QpRecBop},
{QpPageName, 0, NEW_QpRecPageName},
{QpPassword, 0, NEW_QpRecPassword},
{0, 0, 0}
};
QpRecFactory::QpRecFactory(QpIStream& pIn)
: cIn(pIn)
{
}
QpRecFactory::~QpRecFactory()
{
}
QpRec*
QpRecFactory::nextRecord()
{
TQP_INT16 lType;
TQP_INT16 lLen;
QpRec* lResult=0;
cIn >> lType >> lLen;
for( Record* lRecord=gRecord; lResult == 0 ; ++lRecord )
{
if( lRecord->Func == 0 )
{
lResult = new QpRecUnknown( lType, lLen, cIn );
}
else
if( lRecord->Type == lType )
{
// ??? check length
lResult = lRecord->Func(lLen, cIn);
}
}
return lResult;
}
|