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
|
/*++
Copyright (c) 1991 Microsoft Corporation
Module Name:
bufstrm.hxx
Abstract:
This module contains the declaration for the BUFFER_STREAM class.
The BUFFER_STREAM is an abstract class derived from STREAM, that
provides a buffer for read operations in STREAM.
Buffer for read operations is needed in order to read
STRINGs from streams.
Buffer for write operation is not currently implemented. It should
be implemented if we notice that write operations are slow.
Author:
Jaime Sasson (jaimes) 12-Apr-1991
Environment:
ULIB, User Mode
--*/
#if !defined( _BUFFER_STREAM_ )
#define _BUFFER_STREAM_
#include "stream.hxx"
#include "wstring.hxx"
DECLARE_CLASS( STREAM );
class BUFFER_STREAM : public STREAM {
public:
VIRTUAL
~BUFFER_STREAM(
);
VIRTUAL
BOOLEAN
IsAtEnd(
) CONST;
VIRTUAL
STREAMACCESS
QueryAccess(
) CONST PURE;
VIRTUAL
VOID
SetStreamTypeANSI(
);
VIRTUAL
VOID
DetermineStreamType(
IN OUT PBYTE *Buffer,
IN ULONG BufferSize
);
VIRTUAL
BOOLEAN
Read(
OUT PBYTE Buffer,
IN ULONG BytesToRead,
OUT PULONG BytesRead
);
VIRTUAL
BOOLEAN
ReadChar(
OUT PWCHAR Char,
IN BOOLEAN Unicode DEFAULT FALSE
);
VIRTUAL
BOOLEAN
ReadMbString(
IN PSTR String,
IN DWORD BufferSize,
INOUT PDWORD StringSize,
IN PSTR Delimiters,
IN BOOLEAN ExpandTabs DEFAULT FALSE,
IN DWORD TabExp DEFAULT 8
);
VIRTUAL
BOOLEAN
ReadWString(
IN PWSTR String,
IN DWORD BufferSize,
INOUT PDWORD StringSize,
IN PWSTR Delimiters,
IN BOOLEAN ExpandTabs DEFAULT FALSE,
IN DWORD TabExp DEFAULT 8
);
VIRTUAL
BOOLEAN
ReadString(
OUT PWSTRING String,
IN PWSTRING Delimiters,
IN BOOLEAN Unicode DEFAULT FALSE
);
protected:
DECLARE_CONSTRUCTOR( BUFFER_STREAM );
NONVIRTUAL
BOOLEAN
Initialize(
IN ULONG BufferSize
);
NONVIRTUAL
VOID
Construct(
);
VIRTUAL
BOOLEAN
AdvanceBufferPointer(
IN ULONG NumberOfBytes
);
VIRTUAL
BOOLEAN
EndOfFile(
) CONST PURE;
VIRTUAL
BOOLEAN
FillBuffer(
IN PBYTE Buffer,
IN ULONG BufferSize,
OUT PULONG BytesRead
) PURE;
NONVIRTUAL
ULONG
FlushBuffer(
);
VIRTUAL
PCBYTE
GetBuffer(
PULONG BytesInBuffer
);
NONVIRTUAL
ULONG
QueryBytesInBuffer(
) CONST;
VIRTUAL
HANDLE
QueryHandle(
) CONST PURE;
private:
PBYTE _Buffer;
ULONG _BufferSize;
PBYTE _CurrentByte;
ULONG _BytesInBuffer;
INT _BufferStreamType;
};
INLINE
ULONG
BUFFER_STREAM::QueryBytesInBuffer(
) CONST
/*++
Routine Description:
Returns the number of bytes in the buffer.
Arguments:
None.
Return Value:
ULONG - Number of bytes in the buffer.
--*/
{
return( _BytesInBuffer );
}
#endif // _BUFFER_STREAM_
|