author | Claus Gittinger <cg@exept.de> |
Sat, 04 Oct 1997 19:01:30 +0200 | |
changeset 2998 | 930360fb3f12 |
parent 2927 | 1434c3d7f78a |
child 3081 | 4cd54c54ed78 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
329 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
WriteStream subclass:#ReadWriteStream |
|
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
701
diff
changeset
|
14 |
instanceVariableNames:'' |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
701
diff
changeset
|
15 |
classVariableNames:'' |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
701
diff
changeset
|
16 |
poolDictionaries:'' |
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
701
diff
changeset
|
17 |
category:'Streams' |
1 | 18 |
! |
19 |
||
611 | 20 |
!ReadWriteStream class methodsFor:'documentation'! |
88 | 21 |
|
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
329 | 25 |
All Rights Reserved |
88 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
38 |
ReadWriteStreams allow both read- and write-access to some collection. |
|
39 |
To allow this, they reenable some methods blocked in WriteStream. |
|
40 |
(being one of the seldom places, where multiple inheritance could be |
|
41 |
of good use in smalltalk). |
|
329 | 42 |
|
43 |
Claus: |
|
1295 | 44 |
I personally find the ReadStream - WriteStream - ReadWriteStream |
45 |
organization brain-damaged. It would be better to have an attribute |
|
46 |
(such as readOnly / writeOnly / readWrite) in an InternalStream subclass |
|
47 |
of Stream ... |
|
48 |
||
49 |
[author:] |
|
50 |
Claus Gittinger |
|
88 | 51 |
" |
329 | 52 |
! ! |
53 |
||
345 | 54 |
!ReadWriteStream methodsFor:'access-reading'! |
1 | 55 |
|
56 |
next |
|
41 | 57 |
"return the next element; advance read position. |
58 |
If there are no more elements, nil is returned." |
|
59 |
||
60 |
|element| |
|
61 |
||
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
701
diff
changeset
|
62 |
(position > readLimit) ifTrue:[^ self pastEnd]. |
41 | 63 |
element := collection at:position. |
1 | 64 |
position := position + 1. |
41 | 65 |
^ element |
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
701
diff
changeset
|
66 |
|
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
701
diff
changeset
|
67 |
"Modified: 5.2.1996 / 21:57:40 / stefan" |
611 | 68 |
! |
69 |
||
70 |
peek |
|
71 |
"return the element to be read next without advancing read position. |
|
72 |
If there are no more elements, nil is returned." |
|
73 |
||
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
701
diff
changeset
|
74 |
(position > readLimit) ifTrue:[^ self pastEnd]. |
611 | 75 |
^ collection at:position |
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
701
diff
changeset
|
76 |
|
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
701
diff
changeset
|
77 |
"Modified: 5.2.1996 / 21:57:47 / stefan" |
1 | 78 |
! ! |
611 | 79 |
|
677 | 80 |
!ReadWriteStream methodsFor:'converting'! |
81 |
||
82 |
readStream |
|
2927 | 83 |
"return the receiver as a readStream - thats myself" |
84 |
||
677 | 85 |
^ self |
86 |
||
87 |
"Created: 29.11.1995 / 22:04:23 / stefan" |
|
88 |
! ! |
|
89 |
||
611 | 90 |
!ReadWriteStream methodsFor:'queries'! |
91 |
||
92 |
isReadable |
|
2927 | 93 |
"return true if the receiver supports reading - thats true" |
94 |
||
611 | 95 |
^ true |
96 |
! ! |
|
97 |
||
677 | 98 |
!ReadWriteStream class methodsFor:'documentation'! |
99 |
||
100 |
version |
|
2927 | 101 |
^ '$Header: /cvs/stx/stx/libbasic/ReadWriteStream.st,v 1.18 1997-09-15 20:50:34 cg Exp $' |
677 | 102 |
! ! |