initial commit
[rofl0r-KOL.git] / main_tstream.htm
blobe5e4d374c2a757479780b63037e436022b72b61f
1 <html>
2 <head>
3 <title>KOL Help: TStream object (main frame)</title>
4 <base target="_top">
5 </head>
7 <body bgcolor="#FFFFEF" text="#000000" link="#008080" vlink="#008000" alink="#808000">
8 <p><font face="Courier" color="#800080"><b>TStream( unit <a href=kol_pas.htm>KOL.pas</a> )
9 <font face="Wingdings">ï</font> <a href=tobj.htm>TObj</a>
10 <font face="Wingdings">ï</font> <a href=_tobj.htm>_TObj</a>
11 </b></font></p>
12 <p><b>
13 TStream = object( <a href=tobj.htm target="_top">TObj</a> )
14 </b></p>
15 Simple stream object. Can be opened for file, or as memory stream (see
16 <a href=kol_pas.htm#newreadfilestream target="_top">NewReadFileStream</a>, <a href=kol_pas.htm#newwritefilestream target="_top">NewWriteFileStream</a>, <a href=kol_pas.htm#newmemorystream target="_top">NewMemoryStream</a>, etc.). And, another
17 type of streaming object can be derived (without inheriting new object
18 type, just by writing another New...Stream method, which calls
19 <a href=kol_pas.htm#_newstream target="_top">_NewStream</a> and pass methods record to it).
20 <h3 align="center"><font color="#FF8080">TStream properties</font></h3>
21 <a name="size"></a>
22 <p>
23 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Size</b></font>: <b>DWord</b>;</font>
24 <br>
25 Returns stream size. For some custom streams, can be slow
26 operation, or even always return undefined value (-1 recommended).
27 </p>
28 <a name="position"></a>
29 <p>
30 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Position</b></font>: <b>DWord</b>;</font>
31 <br>
32 Current position.
33 </p>
34 <a name="memory"></a>
35 <p>
36 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Memory</b></font>: <b>Pointer</b>;</font>
37 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
38 <br>
39 Only for memory stream.
40 </p>
41 <a name="handle"></a>
42 <p>
43 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Handle</b></font>: THandle;</font>
44 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
45 <br>
46 Only for file stream. It is possible to check that Handle &lt;&gt;
47 INVALID_HANDLE_VALUE to ensure that file stream is created OK.
48 </p>
49 <a name="methods"></a>
50 <p>
51 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Methods</b></font>: PStreamMethods;</font>
52 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
53 <br>
54 Pointer to TStreamMethods record. Useful to implement custom-defined
55 streams, which can access its fCustom field, or even to change
56 methods when necessary.
57 </p>
58 <a name="data"></a>
59 <p>
60 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Data</b></font>: TStreamData;</font>
61 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
62 <br>
63 Pointer to TStreamData record. Useful to implement custom-defined
64 streams, which can access Data fields directly when implemented.
65 </p>
66 <a name="capacity"></a>
67 <p>
68 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Capacity</b></font>: <b>DWORD</b>;</font>
69 <br>
70 Amound of memory allocated for data (MemoryStream).
71 </p>
72 <h4 align="center"><font color="black">Properties, inherited from <a href="tobj.htm" target="_top">TObj</a></font></h4>
73 <h3 align="center"><font color="#FF8080">TStream methods</font></h3>
74 <a name="read"></a>
75 <p>
76 <font face="Courier" color="#800080"><b>function</b> <b>Read</b>( <b>var</b> Buffer; Count: <b>DWord</b> ): <b>DWord</b>;</font>
77 <br>
78 Reads Count bytes from a stream. Returns number of bytes read.
79 </p>
80 <a name="seek"></a>
81 <p>
82 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>Seek</b></font>( MoveTo: <b>Integer</b>; MoveMethod: TMoveMethod ): <b>DWord</b>;</font>
83 <br>
84 Allows to change current position or to obtain it. Property
85 <a href=#position target="main">Position</a> uses this method both for get and set position.
86 </p>
87 <a name="write"></a>
88 <p>
89 <font face="Courier" color="#800080"><b>function</b> <b>Write</b>( <b>var</b> Buffer; Count: <b>DWord</b> ): <b>DWord</b>;</font>
90 <br>
91 Writes Count bytes from Buffer, starting from current position
92 in a stream. Returns how much bytes are written.
93 </p>
94 <a name="writestr"></a>
95 <p>
96 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>WriteStr</b></font>( S: <b>String</b> ): <b>DWORD</b>;</font>
97 <br>
98 Writes string to the stream, not including ending #0. Exactly
99 Length( S ) characters are written.
100 </p>
101 <a name="writestrz"></a>
103 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>WriteStrZ</b></font>( S: <b>String</b> ): <b>DWORD</b>;</font>
104 <br>
105 Writes string, adding #0. Number of bytes written is returned.
106 </p>
107 <a name="readstrz"></a>
109 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>ReadStrZ</b></font>: <b>String</b>;</font>
110 <br>
111 Reads string, finished by #0. After reading, current position in
112 the stream is set to the byte, follows #0.
113 </p>
114 <a name="readstr"></a>
116 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>ReadStr</b></font>: <b>String</b>;</font>
117 <br>
118 Reads string, finished by #13, #10 or #13#10 symbols. Terminating symbols
119 #13 and/or #10 are not added to the end of returned string though
120 stream positioned follow it.
121 </p>
122 <a name="writestrex"></a>
124 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>WriteStrEx</b></font>( S: <b>String</b> ): <b>DWord</b>;</font>
125 <br>
126 Writes string S to stream, also saving its size for future use by
127 ReadStrEx* functions. Returns number of actually written characters.
128 </p>
129 <a name="readstrexvar"></a>
131 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>ReadStrExVar</b></font>( <b>var</b> S: <b>String</b> ): <b>DWord</b>;</font>
132 <br>
133 Reads string from stream and assigns it to S.
134 Returns number of actually read characters.
135 Note:
136 String must be written by using <a href=#writestrex target="main">WriteStrEx</a> function.
137 Return value is count of characters READ, not the length of string.
138 </p>
139 <a name="readstrex"></a>
141 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>ReadStrEx</b></font>: <b>String</b>;</font>
142 <br>
143 Reads string from stream and returns it.
144 </p>
145 <a name="writestrpas"></a>
147 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>WriteStrPas</b></font>( S: <b>String</b> ): <b>DWORD</b>;</font>
148 <br>
149 Writes a string in Pascal short string format - 1 byte length, then string
150 itself without trailing #0 char. S parameter length should not exceed 255
151 chars, rest chars are truncated while writing. Total amount of bytes
152 written is returned.
153 </p>
154 <a name="readstrpas"></a>
156 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>ReadStrPas</b></font>: <b>String</b>;</font>
157 <br>
158 Reads 1 byte from a stream, then treat it as a length of following string
159 which is read and returned. A purpose of this function is reading strings
160 written using <a href=#writestrpas target="main">WriteStrPas</a>.
161 </p>
162 <a name="seekasync"></a>
164 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>SeekAsync</b></font>( MoveTo: <b>Integer</b>; MoveMethod: TMoveMethod );</font>
165 <br>
166 Changes current position asynchronously. To wait for finishing the
167 operation, use method <a href=#wait target="main">Wait</a>.
168 </p>
169 <a name="readasync"></a>
171 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>ReadAsync</b></font>( <b>var</b> Buffer; Count: <b>DWord</b> );</font>
172 <br>
173 Reads Count bytes from a stream asynchronously. To wait finishing the
174 operation, use method <a href=#wait target="main">Wait</a>.
175 </p>
176 <a name="writeasync"></a>
178 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>WriteAsync</b></font>( <b>var</b> Buffer; Count: <b>DWord</b> );</font>
179 <br>
180 Writes Count bytes from Buffer, starting from current position
181 in a stream - asynchronously. To wait finishing the operation,
182 use method <a href=#wait target="main">Wait</a>.
183 </p>
184 <a name="busy"></a>
186 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>Busy</b></font>: <b>Boolean</b>;</font>
187 <br>
188 Returns TRUE until finishing the last asynchronous operation
189 started by calling <a href=#seekasync target="main">SeekAsync</a>, <a href=#readasync target="main">ReadAsync</a>, <a href=#writeasync target="main">WriteAsync</a> methods.
190 </p>
191 <a name="wait"></a>
193 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>Wait</b></font>;</font>
194 <br>
195 Waits for finishing the last asynchronous operation.
196 </p>
197 <h4 align="center"><font color="black">Methods, inherited from <a href="tobj.htm" target="_top">TObj</a></font></h4>
198 <h3 align="center"><font color="#FF8080">TStream events</font></h3>
199 <h4 align="center"><font color="black">Events, inherited from <a href="tobj.htm" target="_top">TObj</a></font></h4>
200 <h3 align="center"><font color="#FF8080">TStream fields</font></h3>
201 <h4 align="center"><font color="black">Fields, inherited from <a href="tobj.htm" target="_top">TObj</a></font></h4>
202 <hr>
203 <p align="center">[&nbsp;<a href=index.htm>Index</a>&nbsp;]</p>
204 <p align="center"><font face="Comic Sans MS"><small>This help is generated 22-Sep-2005 by KOL Help generator, (C) 2000-2001 by Vladimir Kladov<br>Modified (C) 2003 by Alexander Bartov</small></font></p>
205 </body>
206 </html>