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
|
611
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
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:
|
|
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 ...
|
88
|
48 |
"
|
329
|
49 |
! !
|
|
50 |
|
345
|
51 |
!ReadWriteStream methodsFor:'access-reading'!
|
1
|
52 |
|
|
53 |
next
|
41
|
54 |
"return the next element; advance read position.
|
|
55 |
If there are no more elements, nil is returned."
|
|
56 |
|
|
57 |
|element|
|
|
58 |
|
|
59 |
(position > readLimit) ifTrue:[^ nil].
|
|
60 |
element := collection at:position.
|
1
|
61 |
position := position + 1.
|
41
|
62 |
^ element
|
611
|
63 |
!
|
|
64 |
|
|
65 |
peek
|
|
66 |
"return the element to be read next without advancing read position.
|
|
67 |
If there are no more elements, nil is returned."
|
|
68 |
|
|
69 |
(position > readLimit) ifTrue:[^ nil].
|
|
70 |
^ collection at:position
|
1
|
71 |
! !
|
611
|
72 |
|
677
|
73 |
!ReadWriteStream methodsFor:'converting'!
|
|
74 |
|
|
75 |
readStream
|
|
76 |
^ self
|
|
77 |
|
|
78 |
"Created: 29.11.1995 / 22:04:23 / stefan"
|
|
79 |
! !
|
|
80 |
|
611
|
81 |
!ReadWriteStream methodsFor:'positioning'!
|
|
82 |
|
|
83 |
reset
|
|
84 |
"re-redefine to not clobber the collection"
|
|
85 |
|
|
86 |
position := "0" 1
|
|
87 |
! !
|
|
88 |
|
|
89 |
!ReadWriteStream methodsFor:'queries'!
|
|
90 |
|
|
91 |
isReadable
|
|
92 |
^ true
|
|
93 |
! !
|
|
94 |
|
677
|
95 |
!ReadWriteStream class methodsFor:'documentation'!
|
|
96 |
|
|
97 |
version
|
701
|
98 |
^ '$Header: /cvs/stx/stx/libbasic/ReadWriteStream.st,v 1.15 1995-12-07 21:38:18 cg Exp $'
|
677
|
99 |
! !
|