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