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
|
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Streams'
|
|
18 |
!
|
|
19 |
|
|
20 |
ReadWriteStream comment:'
|
5
|
21 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
329
|
22 |
All Rights Reserved
|
93
|
23 |
|
379
|
24 |
$Header: /cvs/stx/stx/libbasic/Attic/RWStream.st,v 1.10 1995-08-10 12:30:39 claus Exp $
|
88
|
25 |
'!
|
1
|
26 |
|
88
|
27 |
!ReadWriteStream class methodsFor: 'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
329
|
32 |
All Rights Reserved
|
88
|
33 |
|
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
|
42 |
|
|
43 |
version
|
|
44 |
"
|
379
|
45 |
$Header: /cvs/stx/stx/libbasic/Attic/RWStream.st,v 1.10 1995-08-10 12:30:39 claus Exp $
|
|
46 |
$Revision: 1.10 $
|
88
|
47 |
"
|
|
48 |
!
|
|
49 |
|
|
50 |
documentation
|
|
51 |
"
|
|
52 |
ReadWriteStreams allow both read- and write-access to some collection.
|
|
53 |
To allow this, they reenable some methods blocked in WriteStream.
|
|
54 |
(being one of the seldom places, where multiple inheritance could be
|
|
55 |
of good use in smalltalk).
|
329
|
56 |
|
|
57 |
Claus:
|
|
58 |
I personally find the ReadStream - WriteStream - ReadWriteStream
|
|
59 |
organization brain-damaged. It would be better to have an attribute
|
|
60 |
(such as readOnly / writeOnly / readWrite) in an InternalStream subclass
|
|
61 |
of Stream ...
|
88
|
62 |
"
|
|
63 |
! !
|
1
|
64 |
|
345
|
65 |
!ReadWriteStream methodsFor:'queries'!
|
|
66 |
|
|
67 |
isReadable
|
|
68 |
^ true
|
|
69 |
! !
|
|
70 |
|
|
71 |
!ReadWriteStream methodsFor:'positioning'!
|
329
|
72 |
|
|
73 |
reset
|
|
74 |
"re-redefine to not clobber the collection"
|
|
75 |
|
|
76 |
position := "0" 1
|
|
77 |
! !
|
|
78 |
|
345
|
79 |
!ReadWriteStream methodsFor:'access-reading'!
|
1
|
80 |
|
|
81 |
peek
|
41
|
82 |
"return the element to be read next without advancing read position.
|
|
83 |
If there are no more elements, nil is returned."
|
|
84 |
|
|
85 |
(position > readLimit) ifTrue:[^ nil].
|
1
|
86 |
^ collection at:position
|
|
87 |
!
|
|
88 |
|
|
89 |
next
|
41
|
90 |
"return the next element; advance read position.
|
|
91 |
If there are no more elements, nil is returned."
|
|
92 |
|
|
93 |
|element|
|
|
94 |
|
|
95 |
(position > readLimit) ifTrue:[^ nil].
|
|
96 |
element := collection at:position.
|
1
|
97 |
position := position + 1.
|
41
|
98 |
^ element
|
1
|
99 |
! !
|