Xbase64 4.0.1
C++ Library for handling Xbase (DBF) format type files
xbmemo.h
Go to the documentation of this file.
1/* xbmemo.h
2
3XBase64 Software Library
4
5Copyright (c) 1997,2003,2014,2022 Gary A Kunkel
6
7The xb64 software library is covered under the terms of the GPL Version 3, 2007 license.
8
9Email Contact:
10
11 XDB-devel@lists.sourceforge.net
12 XDB-users@lists.sourceforge.net
13
14*/
15
16
17#ifndef __XB_XBMEMO_H__
18#define __XB_XBMEMO_H__
19
20
21// dont use "#pragma interface" with abstract classes
22// #ifdef CMAKE_COMPILER_IS_GNUCC
23// #pragma interface
24// #endif
25
26#ifdef XB_MEMO_SUPPORT
27
28
29
30
31namespace xb{
32
34
55class XBDLLEXPORT xbMemo : public xbFile {
56 public:
57
58 xbMemo( xbDbf *dbf, xbString const &sFileName );
59
60 /* virtual methods */
61 virtual ~xbMemo();
62 virtual xbInt16 Abort () = 0;
63 virtual xbInt16 CloseMemoFile ();
64 virtual xbInt16 Commit () = 0;
65
66 #ifdef XB_LOCKING_SUPPORT
67 virtual xbInt16 LockMemo ( xbInt16 iLockFunction );
68 virtual xbBool GetMemoLocked () const;
69 #endif
70
71 /* pure virtual methods */
72 virtual xbInt16 CreateMemoFile () = 0;
73
74 virtual xbInt16 GetMemoField ( xbInt16 iFieldNo, xbString &sMemoData ) = 0;
75 virtual xbInt16 GetMemoFieldLen( xbInt16 iFieldNo, xbUInt32 &ulMemoFieldLen ) = 0;
76 virtual xbInt16 OpenMemoFile () = 0;
77 virtual xbInt16 GetMemoFileType();
78 virtual xbInt16 PackMemo ( void (*memoStatusFunc)(xbUInt32 ulItemNum, xbUInt32 ulNumItems)) = 0;
79 virtual xbInt16 UpdateMemoField( xbInt16 iFieldNo, const xbString &sMemoData ) = 0;
80
81 #ifdef XB_DEBUG_SUPPORT
82 virtual xbInt16 DumpMemoFreeChain() = 0;
83 virtual xbInt16 DumpMemoHeader () = 0;
84 #endif
85
86 // *********** FIXME *************
87 // next two methods should be protected but are called in the xb_test_xxxx programs testing routines
88 // so for now, they are kept as public
89 virtual xbInt16 CalcLastDataBlock ( xbUInt32 &lLastDataBlock );
90 virtual xbInt16 GetHdrNextBlock ( xbUInt32 &ulBlockNo );
91
92 protected:
93 friend class xbDbf;
94
95 virtual xbInt16 ReadDbtHeader ( xbInt16 iOption ) = 0;
96 virtual xbInt16 UpdateHeaderName () = 0;
97 virtual xbInt16 UpdateHeadNextNode();
98 virtual xbInt16 Zap () = 0;
99
100 xbDbf *dbf; /* pointer to related dbf instance */
101 char cVersion; /* byte 16 off the header block, 0x03 for V3, version IV - ? */
102 xbInt16 iMemoFileType; /* 3 = version III, 4 = version IV */
103 xbUInt32 ulHdrNextBlock; /* next available block , bytes 0-3 of the memo header */
104 void * mbb; /* memo block buffer */
105
106
107 private:
108
109 #ifdef XB_LOCKING_SUPPORT
110 xbBool bFileLocked; /* memo file locked */
111 #endif
112
113};
114
115
116
117#ifdef XB_DBF3_SUPPORT
119
131class XBDLLEXPORT xbMemoDbt3 : public xbMemo {
132 public:
133 xbMemoDbt3( xbDbf *dbf, xbString const &sFileName );
134 ~xbMemoDbt3();
135 virtual xbInt16 Abort ();
136 virtual xbInt16 Commit ();
137 virtual xbInt16 CreateMemoFile ();
138 virtual xbInt16 GetMemoField ( xbInt16 iFieldNo, xbString &sMemoData );
139 virtual xbInt16 GetMemoFieldLen( xbInt16 iFieldNo, xbUInt32 &ulMemoFieldLen );
140 virtual xbInt16 OpenMemoFile ();
141 virtual xbInt16 PackMemo ( void (*memoStatusFunc) (xbUInt32 ulItemNum, xbUInt32 ulNumItems));
142 virtual xbInt16 UpdateMemoField( xbInt16 iFieldNo, const xbString &sMemoData );
143
144 #ifdef XB_DEBUG_SUPPORT
145 virtual xbInt16 DumpMemoFreeChain();
146 virtual xbInt16 DumpMemoHeader ();
147 #endif
148
149 protected:
150 virtual xbInt16 ReadDbtHeader( xbInt16 iOption );
151 virtual xbInt16 UpdateHeaderName();
152 virtual xbInt16 Zap();
153
154 private:
155};
156#endif
157
158
159#ifdef XB_DBF4_SUPPORT
160
162
172class XBDLLEXPORT xbMemoDbt4 : public xbMemo {
173 public:
174 xbMemoDbt4( xbDbf *dbf, xbString const &sFileName );
175 ~xbMemoDbt4();
176 virtual xbInt16 Abort ();
177 virtual xbInt16 Commit ();
178 virtual xbInt16 CreateMemoFile ();
179
180 virtual xbInt16 GetMemoField ( xbInt16 iFieldNo, xbString &sMemoData );
181 virtual xbInt16 GetMemoFieldLen ( xbInt16 iFieldNo, xbUInt32 &ulMemoFieldLen );
182 virtual xbInt16 GetMemoFieldLen ( xbInt16 iFieldNo, xbUInt32 &ulMemoFieldLen, xbUInt32 &lBlockNo );
183 virtual xbInt16 OpenMemoFile ();
184 virtual xbInt16 PackMemo ( void (*memoStatusFunc) (xbUInt32 ulItemNum, xbUInt32 ulNumItems));
185 virtual xbInt16 UpdateMemoField ( xbInt16 iFieldNo, const xbString &sMemoData );
186
187 #ifdef XB_DEBUG_SUPPORT
188 virtual xbInt16 DumpMemoFreeChain ();
189 virtual xbInt16 DumpMemoHeader ();
190 virtual xbInt16 DumpMemoInternals ();
191 virtual xbInt16 ReadFreeBlockHeader( xbUInt32 ulBlockNo, xbUInt32 &ulNextBlock, xbUInt32 &ulFreeBlockCnt );
192 #endif
193
194 protected:
195 virtual xbInt16 FindBlockSetInChain( xbUInt32 ulBlocksNeeded, xbUInt32 &ulLastDataBlock, xbUInt32 &ulLocation, xbUInt32 &ulPrevNode, xbBool &bFound );
196 virtual xbInt16 FreeMemoBlockChain( xbUInt32 ulBlockNo );
197 virtual xbInt16 FreeMemoBlockChain( xbUInt32 ulBlockNo, xbUInt32 &ulLastDataBlock );
198 virtual xbInt16 GetBlockSetFromChain( xbUInt32 ulBlocksNeeded, xbUInt32 ulLocation, xbUInt32 ulPrevNode );
199 virtual xbInt16 ReadDbtHeader( xbInt16 iOption );
200 virtual xbInt16 ReadBlockHeader( xbUInt32 ulBlockNo, xbInt16 iOption );
201 virtual xbInt16 UpdateHeaderName ();
202 virtual xbInt16 WriteBlockHeader( xbUInt32 ulBlockNo, xbInt16 iOption );
203 virtual xbInt16 Zap();
204
205 private:
206 xbString sDbfFileNameWoExt;
207 xbUInt32 ulNextFreeBlock;
208 xbUInt32 ulFreeBlockCnt;
209 xbInt16 iField1;
210 xbInt16 iStartPos;
211 xbUInt32 ulFieldLen;
212
213 xbLinkList<xbUInt32> llOldBlocks; // list of previously used memo blocks for field, used by Commit() / Abort()
214 xbLinkList<xbUInt32> llNewBlocks; // list of newly updated memo blocks for field, used by Commit() / Abort()
215
216};
217#endif
218
219
220} /* namespace xb */
221#endif /* XB_MEMO_SUPPORT */
222#endif /* __XB_MEMO_H__ */
223
Definition: xbdate.cpp:19
short int xbBool
Definition: xbtypes.h:24
class XBDLLEXPORT xbDbf
Definition: xbtblmgr.h:28