author | Claus Gittinger <cg@exept.de> |
Tue, 07 Jan 1997 12:02:05 +0100 | |
changeset 2072 | e84dbf5e5424 |
parent 1295 | 83f594f05c52 |
child 2927 | 1434c3d7f78a |
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 |
|
51 |
||
88 | 52 |
" |
329 | 53 |
! ! |
54 |
||
345 | 55 |
!ReadWriteStream methodsFor:'access-reading'! |
1 | 56 |
|
57 |
next |
|
41 | 58 |
"return the next element; advance read position. |
59 |
If there are no more elements, nil is returned." |
|
60 |
||
61 |
|element| |
|
62 |
||
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
701
diff
changeset
|
63 |
(position > readLimit) ifTrue:[^ self pastEnd]. |
41 | 64 |
element := collection at:position. |
1 | 65 |
position := position + 1. |
41 | 66 |
^ element |
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
701
diff
changeset
|
67 |
|
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
701
diff
changeset
|
68 |
"Modified: 5.2.1996 / 21:57:40 / stefan" |
611 | 69 |
! |
70 |
||
71 |
peek |
|
72 |
"return the element to be read next without advancing read position. |
|
73 |
If there are no more elements, nil is returned." |
|
74 |
||
970
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
701
diff
changeset
|
75 |
(position > readLimit) ifTrue:[^ self pastEnd]. |
611 | 76 |
^ 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
|
77 |
|
3b59c9b38dbb
ST80 compatibility: generate signal at end of stream when instance variable
Stefan Vogel <sv@exept.de>
parents:
701
diff
changeset
|
78 |
"Modified: 5.2.1996 / 21:57:47 / stefan" |
1 | 79 |
! ! |
611 | 80 |
|
677 | 81 |
!ReadWriteStream methodsFor:'converting'! |
82 |
||
83 |
readStream |
|
84 |
^ self |
|
85 |
||
86 |
"Created: 29.11.1995 / 22:04:23 / stefan" |
|
87 |
! ! |
|
88 |
||
611 | 89 |
!ReadWriteStream methodsFor:'positioning'! |
90 |
||
91 |
reset |
|
92 |
"re-redefine to not clobber the collection" |
|
93 |
||
94 |
position := "0" 1 |
|
95 |
! ! |
|
96 |
||
97 |
!ReadWriteStream methodsFor:'queries'! |
|
98 |
||
99 |
isReadable |
|
100 |
^ true |
|
101 |
! ! |
|
102 |
||
677 | 103 |
!ReadWriteStream class methodsFor:'documentation'! |
104 |
||
105 |
version |
|
1295 | 106 |
^ '$Header: /cvs/stx/stx/libbasic/Attic/RWStream.st,v 1.17 1996-04-25 17:00:25 cg Exp $' |
677 | 107 |
! ! |