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 virtual xbInt16 CreateMemoFile () = 0;
66
67 virtual xbInt16 DumpMemoHeader () = 0;
68
69
70 virtual xbInt16 GetMemoField ( xbInt16 iFieldNo, xbString &sMemoData ) = 0;
71 virtual xbInt16 GetMemoFieldLen ( xbInt16 iFieldNo, xbUInt32 &ulMemoFieldLen ) = 0;
72 virtual xbInt16 OpenMemoFile () = 0;
73 virtual xbInt16 GetMemoFileType ();
74 virtual xbInt16 PackMemo ( void (*memoStatusFunc)(xbUInt32 ulItemNum, xbUInt32 ulNumItems)) = 0;
75 virtual xbInt16 UpdateMemoField ( xbInt16 iFieldNo, const xbString &sMemoData ) = 0;
76
77 #ifdef XB_DEBUG_SUPPORT
78 virtual xbInt16 DumpMemoFreeChain() = 0;
79 #endif
80
81 #ifdef XB_LOCKING_SUPPORT
82 virtual xbInt16 LockMemo ( xbInt16 iLockFunction );
83 virtual xbBool GetMemoLocked () const;
84 #endif
85
86
87
88 // *********** FIXME *************
89 // next two methods should be protected but are called in the xb_test_xxxx programs testing routines
90 // so for now, they are kept as public
91 virtual xbInt16 CalcLastDataBlock ( xbUInt32 &lLastDataBlock );
92 virtual xbInt16 GetHdrNextBlock ( xbUInt32 &ulBlockNo );
93
94 protected:
95 friend class xbDbf;
96
97 virtual xbInt16 ReadDbtHeader ( xbInt16 iOption ) = 0;
98 virtual xbInt16 UpdateHeaderName () = 0;
99 virtual xbInt16 UpdateHeadNextNode();
100 virtual xbInt16 Zap () = 0;
101
102 xbDbf *dbf; /* pointer to related dbf instance */
103 char cVersion; /* byte 16 off the header block, 0x03 for V3, version IV - ? */
104 xbInt16 iMemoFileType; /* 3 = version III, 4 = version IV */
105 xbUInt32 ulHdrNextBlock; /* next available block , bytes 0-3 of the memo header */
106 void * mbb; /* memo block buffer */
107
108
109 private:
110
111 #ifdef XB_LOCKING_SUPPORT
112 xbBool bFileLocked; /* memo file locked */
113 #endif
114
115};
116
117
118
119#ifdef XB_DBF3_SUPPORT
121
133class XBDLLEXPORT xbMemoDbt3 : public xbMemo {
134 public:
135 xbMemoDbt3( xbDbf *dbf, xbString const &sFileName );
136 ~xbMemoDbt3();
137 virtual xbInt16 Abort ();
138 virtual xbInt16 Commit ();
139 virtual xbInt16 CreateMemoFile ();
140 virtual xbInt16 DumpMemoHeader ();
141 virtual xbInt16 GetMemoField ( xbInt16 iFieldNo, xbString &sMemoData );
142 virtual xbInt16 GetMemoFieldLen( xbInt16 iFieldNo, xbUInt32 &ulMemoFieldLen );
143 virtual xbInt16 OpenMemoFile ();
144 virtual xbInt16 PackMemo ( void (*memoStatusFunc) (xbUInt32 ulItemNum, xbUInt32 ulNumItems));
145 virtual xbInt16 UpdateMemoField( xbInt16 iFieldNo, const xbString &sMemoData );
146
147 #ifdef XB_DEBUG_SUPPORT
148 virtual xbInt16 DumpMemoFreeChain();
149 #endif
150
151 protected:
152 virtual xbInt16 ReadDbtHeader( xbInt16 iOption );
153 virtual xbInt16 UpdateHeaderName();
154 virtual xbInt16 Zap();
155
156 private:
157};
158#endif
159
160
161#ifdef XB_DBF4_SUPPORT
162
164
174class XBDLLEXPORT xbMemoDbt4 : public xbMemo {
175 public:
176 xbMemoDbt4( xbDbf *dbf, xbString const &sFileName );
177 ~xbMemoDbt4();
178 virtual xbInt16 Abort ();
179 virtual xbInt16 Commit ();
180 virtual xbInt16 CreateMemoFile ();
181 virtual xbInt16 DumpMemoHeader ();
182 virtual xbInt16 GetMemoField ( xbInt16 iFieldNo, xbString &sMemoData );
183 virtual xbInt16 GetMemoFieldLen ( xbInt16 iFieldNo, xbUInt32 &ulMemoFieldLen );
184 virtual xbInt16 GetMemoFieldLen ( xbInt16 iFieldNo, xbUInt32 &ulMemoFieldLen, xbUInt32 &lBlockNo );
185 virtual xbInt16 OpenMemoFile ();
186 virtual xbInt16 PackMemo ( void (*memoStatusFunc) (xbUInt32 ulItemNum, xbUInt32 ulNumItems));
187 virtual xbInt16 UpdateMemoField ( xbInt16 iFieldNo, const xbString &sMemoData );
188
189 #ifdef XB_DEBUG_SUPPORT
190 virtual xbInt16 DumpMemoFreeChain ();
191 virtual xbInt16 DumpMemoInternals ();
192 virtual xbInt16 ReadFreeBlockHeader( xbUInt32 ulBlockNo, xbUInt32 &ulNextBlock, xbUInt32 &ulFreeBlockCnt );
193 #endif
194
195 protected:
196 virtual xbInt16 FindBlockSetInChain( xbUInt32 ulBlocksNeeded, xbUInt32 &ulLastDataBlock, xbUInt32 &ulLocation, xbUInt32 &ulPrevNode, xbBool &bFound );
197 virtual xbInt16 FreeMemoBlockChain( xbUInt32 ulBlockNo );
198 virtual xbInt16 FreeMemoBlockChain( xbUInt32 ulBlockNo, xbUInt32 &ulLastDataBlock );
199 virtual xbInt16 GetBlockSetFromChain( xbUInt32 ulBlocksNeeded, xbUInt32 ulLocation, xbUInt32 ulPrevNode );
200 virtual xbInt16 ReadDbtHeader( xbInt16 iOption );
201 virtual xbInt16 ReadBlockHeader( xbUInt32 ulBlockNo, xbInt16 iOption );
202 virtual xbInt16 UpdateHeaderName ();
203 virtual xbInt16 WriteBlockHeader( xbUInt32 ulBlockNo, xbInt16 iOption );
204 virtual xbInt16 Zap();
205
206 private:
207 xbString sDbfFileNameWoExt;
208 xbUInt32 ulNextFreeBlock;
209 xbUInt32 ulFreeBlockCnt;
210 xbInt16 iField1;
211 xbInt16 iStartPos;
212 xbUInt32 ulFieldLen;
213
214 xbLinkList<xbUInt32> llOldBlocks; // list of previously used memo blocks for field, used by Commit() / Abort()
215 xbLinkList<xbUInt32> llNewBlocks; // list of newly updated memo blocks for field, used by Commit() / Abort()
216
217};
218#endif
219
220
221} /* namespace xb */
222#endif /* XB_MEMO_SUPPORT */
223#endif /* __XB_MEMO_H__ */
224
Definition: xbdate.cpp:19
short int xbBool
Definition: xbtypes.h:24
class XBDLLEXPORT xbDbf
Definition: xbtblmgr.h:28