author | Claus Gittinger <cg@exept.de> |
Sat, 11 Nov 1995 16:28:41 +0100 | |
changeset 530 | 07d0bce293c9 |
parent 384 | cc3d110ea879 |
child 611 | 80bb0f1a7bab |
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 |
|
14 |
instanceVariableNames:'' |
|
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Streams' |
|
18 |
! |
|
19 |
||
88 | 20 |
!ReadWriteStream class methodsFor: 'documentation'! |
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 |
version |
|
530
07d0bce293c9
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
384
diff
changeset
|
37 |
^ '$Header: /cvs/stx/stx/libbasic/Attic/RWStream.st,v 1.12 1995-11-11 15:26:14 cg Exp $' |
88 | 38 |
! |
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
ReadWriteStreams allow both read- and write-access to some collection. |
|
43 |
To allow this, they reenable some methods blocked in WriteStream. |
|
44 |
(being one of the seldom places, where multiple inheritance could be |
|
45 |
of good use in smalltalk). |
|
329 | 46 |
|
47 |
Claus: |
|
48 |
I personally find the ReadStream - WriteStream - ReadWriteStream |
|
49 |
organization brain-damaged. It would be better to have an attribute |
|
50 |
(such as readOnly / writeOnly / readWrite) in an InternalStream subclass |
|
51 |
of Stream ... |
|
88 | 52 |
" |
53 |
! ! |
|
1 | 54 |
|
345 | 55 |
!ReadWriteStream methodsFor:'queries'! |
56 |
||
57 |
isReadable |
|
58 |
^ true |
|
59 |
! ! |
|
60 |
||
61 |
!ReadWriteStream methodsFor:'positioning'! |
|
329 | 62 |
|
63 |
reset |
|
64 |
"re-redefine to not clobber the collection" |
|
65 |
||
66 |
position := "0" 1 |
|
67 |
! ! |
|
68 |
||
345 | 69 |
!ReadWriteStream methodsFor:'access-reading'! |
1 | 70 |
|
71 |
peek |
|
41 | 72 |
"return the element to be read next without advancing read position. |
73 |
If there are no more elements, nil is returned." |
|
74 |
||
75 |
(position > readLimit) ifTrue:[^ nil]. |
|
1 | 76 |
^ collection at:position |
77 |
! |
|
78 |
||
79 |
next |
|
41 | 80 |
"return the next element; advance read position. |
81 |
If there are no more elements, nil is returned." |
|
82 |
||
83 |
|element| |
|
84 |
||
85 |
(position > readLimit) ifTrue:[^ nil]. |
|
86 |
element := collection at:position. |
|
1 | 87 |
position := position + 1. |
41 | 88 |
^ element |
1 | 89 |
! ! |