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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
/*
Copyright 1990-2008 Light Infocon Tecnologia S/A
Este arquivo é parte do programa LightBase - Banco de Dados Textual Documental
O LightBase é um software livre; você pode redistribui-lo e/ou modifica-lo dentro
dos termos da Licença Pública Geral GNU como publicada pela Fundação do Software
Livre (FSF); na versão 2 da Licença.
Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO
EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
Você deve ter recebido uma cópia da Licença Pública Geral GNU versao 2, sob o
título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do
Software Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//
// void * ALOpenInputFile::operator new( size_t size )
//
// ARGUMENTS:
//
// size : The size of the object being created.
//
// RETURNS
//
// A pointer to the storage allocated for the object.
//
// DESCRIPTION
//
// When we construct an object when using the DLL, trouble can arise.
// The main bad thing is that when we call the constructor from an
// EXE, we allocate the storage for the new object from inside our EXE.
// When we destroy the same object, the destructor frees up the memory
// inside the DLL. This is bad, because you can mangle the heap inside
// the DLL by trying to free an object that doesn't belong to it.
//
// The fix to this conundrum is to allocate the object inside the DLL,
// and we can make this happen by overloading the new operator. We don't
// bother unless it's a DLL deal.
//
// This lecture will be repeated at times throughout the source in this
// project.
//
// REVISION HISTORY
//
// May 22, 1994 1.0A : First release
//
void AL_DLL_FAR * AL_PROTO ALOpenInputFile::operator new
//
// void * ALOpenOutputFile::operator new( size_t size )
//
// ARGUMENTS:
//
// size : The size of the object being created.
//
// RETURNS
//
// A pointer to the storage allocated for the object.
//
// DESCRIPTION
//
// See the function directly above.
//
// REVISION HISTORY
//
// May 22, 1994 1.0A : First release
//
void AL_DLL_FAR * AL_PROTO ALOpenOutputFile::operator new
//
// void * ALOpenFiles::operator new( size_t size )
//
// ARGUMENTS:
//
// size : The size of the object being created.
//
// RETURNS
//
// A pointer to the storage allocated for the object.
//
// DESCRIPTION
//
// See the function directly above.
//
// REVISION HISTORY
//
// May 22, 1994 1.0A : First release
//
void AL_DLL_FAR * AL_PROTO ALOpenFiles::operator new
//
// ALOpenInputFile::ALOpenInputFile( ALStorage &file )
//
// ARGUMENTS:
//
// file : The storage object that has to opened.
//
// RETURNS
//
// Nothing, this is a constructor.
//
// DESCRIPTION
//
// You can stick this constructor at the start of a function, and it
// opens up an ALStorage object for you. You can then take it for
// granted that it is open. You can also take it for granted that
// the storage object will be closed by the destructor when the
// function exits. All of this saves a lot of repetitive code.
//
// REVISION HISTORY
//
// May 22, 1994 1.0A : First release
//
AL_PROTO
//
// ALOpenInputFile::~ALOpenInputFile()
//
// ARGUMENTS:
//
// None.
//
// RETURNS
//
// None, it is a destructor.
//
// DESCRIPTION
//
// At the end of the function, it is time to close the storage object.
// But only if it wasn't open when the constructor was called.
//
// REVISION HISTORY
//
// May 22, 1994 1.0A : First release
//
AL_PROTO ALOpenInputFile::~
//
// ALOpenOutputFile::ALOpenOutputFile( ALStorage &file )
//
// ARGUMENTS:
//
// file : The ALStorage object that needs to be created.
//
// RETURNS
//
// Nothing, it is a constructor.
//
// DESCRIPTION
//
// This is just like ALOpenInputFile, except instead of calling
// ALStorage::Open(), it calls ALStorage::Create(). Note that if
// the file is already open, we keep track of the fact and leave it
// alone.
//
// REVISION HISTORY
//
// May 22, 1994 1.0A : First release
//
AL_PROTO
//
// ALOpenOutputFile::~ALOpenOutputFile()
//
// ARGUMENTS:
//
// None.
//
// RETURNS
//
// Nothing.
//
// DESCRIPTION
//
// If the file was closed when the constructor was called, we close
// it in the constructor.
//
// REVISION HISTORY
//
// May 22, 1994 1.0A : First release
//
AL_PROTO ALOpenOutputFile::~
//
// ALOpenFiles::ALOpenFiles( ALStorage &input,
// ALStorage &output )
//
// ARGUMENTS:
//
// input : The storage object that needs to be opened, maybe.
//
// output : The storage object that needs to be created, maybe.
//
// RETURNS
//
// Nothing.
//
// DESCRIPTION
//
// This is just a combination of the ALOpenOutputFile() and
// ALOpenInputFile() guys rolled into one. To combine them, we
// just create this object that contains one of both objects.
//
// So this guy takes care of opening an input file and an output
// file right there at the same time. The most exciting part of it
// is that they both get closed up in the destructor.
//
// So all the constructor has to do here is call the other two
// constructors in an initializer list.
//
// REVISION HISTORY
//
// May 22, 1994 1.0A : First release
//
AL_PROTO : mInputFile, mOutputFile
//
// ALOpenFiles::~ALOpenFiles()
//
// ARGUMENTS:
//
// None.
//
// RETURNS
//
// Nothing.
//
// DESCRIPTION
//
// This guy closes the two files, if they were closed when the constructor
// was called. We don't have to do anything explicitly, because the
// two data members of this object do so in their destructors.
//
// REVISION HISTORY
//
// May 22, 1994 1.0A : First release
//
AL_PROTO ALOpenFiles::~