-
Notifications
You must be signed in to change notification settings - Fork 10
/
_streams.pas
253 lines (212 loc) · 5.67 KB
/
_streams.pas
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
unit _Streams;
(******
DN/2 Plugin Interface - object model
Copyright (C) 2002 Aleksej Kozlov (Cat)
2:5030/1326.13
******)
{&Delphi+}
{&Use32+}
interface
uses
_Defines, _Objects
;
type
PStream = ^TStream;
TStream = object(TObject)
Status: Integer;
ErrorInfo: Integer;
StreamSize: LongInt;
Position: LongInt;
constructor Init;
procedure CopyFrom(var S: TStream; Count: LongInt);
procedure Error(Code, Info: Integer); virtual;
procedure Flush; virtual;
function Get: PObject;
function GetPos: LongInt; virtual;
function GetSize: LongInt; virtual;
procedure Put(P: PObject);
procedure Read(var Buf; Count: LongInt); virtual;
function ReadStr: PString;
function ReadLongStr: PLongString;
procedure ReadStrV(var S: String);
procedure ReadLongStrV(var S: LongString);
procedure Reset;
procedure Seek(Pos: LongInt); virtual;
function StrRead: PChar;
procedure StrWrite(P: PChar);
procedure Truncate; virtual;
procedure Write(const Buf; Count: LongInt); virtual;
procedure WriteStr(P: PString);
procedure WriteLongStr(P: PLongString);
function Eof: Boolean;
procedure DoOpen(OpenMode: Word); virtual;
procedure Close; virtual;
end;
PDosStream = ^TDosStream;
TDOSStream = object(TStream)
Handle: Integer;
FName: AsciiZ;
FMode: Word;
constructor Init(FileName: String; Mode: Word);
procedure Open(FileName: String; Mode: Word);
{destructor Done; virtual;}
{procedure Read(var Buf; Count: LongInt); virtual;}
procedure ReadBlock(var Buf; Count: LongInt; var BytesRead: Word);
virtual;
{procedure Seek(Pos: LongInt); virtual;}
{procedure Truncate; virtual;}
{procedure Write(const Buf; Count: LongInt); virtual;}
{procedure DoOpen(OpenMode: Word); virtual;}
{procedure Close; virtual;}
end;
PBufStream = ^TBufStream;
TBufStream = object(TDOSStream)
Buffer: PByteArray;
BufSize: LongInt;
BufPtr: LongInt;
BufEnd: LongInt;
ModBufStart, ModBufEnd: LongInt;
constructor Init(FileName: String; Mode: Word; Size: LongInt);
{destructor Done; virtual;}
{procedure Flush; virtual;}
{procedure Read(var Buf; Count: LongInt); virtual;}
{procedure Seek(Pos: LongInt); virtual;}
{procedure Truncate; virtual;}
{procedure Write(const Buf; Count: LongInt); virtual;}
{procedure DoOpen(OpenMode: Word); virtual;}
{procedure Close; virtual;}
end;
PMemoryStream = ^TMemoryStream;
TMemoryStream = object(TStream)
BlkCount: LongInt;
BlkSize: Word;
MemSize: LongInt;
BlkList: PPointerArray;
constructor Init(ALimit: LongInt; ABlockSize: Word);
{destructor Done; virtual;}
{procedure Read(var Buf; Count: LongInt); virtual;}
{procedure Truncate; virtual;}
{procedure Write(const Buf; Count: LongInt); virtual;}
end;
implementation
uses
_DNFuncs
;
constructor TStream.Init;
begin
_TObject^.Init(nil, @Self);
end;
procedure TStream.CopyFrom(var S: TStream; Count: LongInt);
begin
_TStream^.CopyFrom(_Model1.TStream(S), Count, @Self);
end;
procedure TStream.Error(Code, Info: Integer);
assembler; {&Frame-}
asm
end;
procedure TStream.Flush;
assembler; {&Frame-}
asm
end;
function TStream.Get: PObject;
begin
Result := PObject(_TStream^.Get(@Self));
end;
function TStream.GetPos: LongInt;
assembler; {&Frame-}
asm
end;
function TStream.GetSize: LongInt;
assembler; {&Frame-}
asm
end;
procedure TStream.Put(P: PObject);
begin
_TStream^.Put(_Model1.PObject(P), @Self);
end;
procedure TStream.Read(var Buf; Count: LongInt);
assembler; {&Frame-}
asm
end;
function TStream.ReadStr: PString;
begin
Result := _TStream^.ReadStr(@Self);
end;
function TStream.ReadLongStr: PLongString;
begin
Result := _TStream^.ReadLongStr(@Self);
end;
procedure TStream.ReadStrV(var S: String);
begin
_TStream^.ReadStrV(S, @Self);
end;
procedure TStream.ReadLongStrV(var S: LongString);
begin
_TStream^.ReadLongStrV(S, @Self);
end;
procedure TStream.Reset;
begin
_TStream^.Reset(@Self);
end;
procedure TStream.Seek(Pos: LongInt);
assembler; {&Frame-}
asm
end;
function TStream.StrRead: PChar;
begin
Result := _TStream^.StrRead(@Self);
end;
procedure TStream.StrWrite(P: PChar);
begin
_TStream^.StrWrite(P, @Self);
end;
procedure TStream.Truncate;
assembler; {&Frame-}
asm
end;
procedure TStream.Write(const Buf; Count: LongInt);
assembler; {&Frame-}
asm
end;
procedure TStream.WriteStr(P: PString);
begin
_TStream^.WriteStr(P, @Self);
end;
procedure TStream.WriteLongStr(P: PLongString);
begin
_TStream^.WriteLongStr(P, @Self);
end;
function TStream.Eof: Boolean;
begin
Result := _TStream^.Eof(@Self);
end;
procedure TStream.DoOpen(OpenMode: Word);
assembler; {&Frame-}
asm
end;
procedure TStream.Close;
assembler; {&Frame-}
asm
end;
constructor TDOSStream.Init(FileName: String; Mode: Word);
begin
_TDosStream^.Init(FileName, Mode, nil, @Self);
end;
procedure TDOSStream.Open(FileName: String; Mode: Word);
begin
_TDosStream^.Open(FileName, Mode, @Self);
end;
procedure TDOSStream.ReadBlock(var Buf; Count: LongInt;
var BytesRead: Word);
assembler; {&Frame-}
asm
end;
constructor TBufStream.Init(FileName: String; Mode: Word; Size: LongInt);
begin
_TBufStream^.Init(FileName, Mode, Size, nil, @Self);
end;
constructor TMemoryStream.Init(ALimit: LongInt; ABlockSize: Word);
begin
_TMemoryStream^.Init(ALimit, ABlockSize, nil, @Self);
end;
end.