--- a/WriteStream.st Thu Nov 23 02:27:21 1995 +0100
+++ b/WriteStream.st Thu Nov 23 02:32:01 1995 +0100
@@ -11,10 +11,10 @@
"
PositionableStream subclass:#WriteStream
- instanceVariableNames:''
- classVariableNames:''
- poolDictionaries:''
- category:'Streams'
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Streams'
!
!WriteStream class methodsFor:'documentation'!
@@ -33,10 +33,6 @@
"
!
-version
- ^ '$Header: /cvs/stx/stx/libbasic/WriteStream.st,v 1.21 1995-11-11 15:28:41 cg Exp $'
-!
-
documentation
"
Streams for writing into - this implementation currently DOES change the
@@ -45,22 +41,10 @@
Thus it is slightly incompatible to ST-80 since 'aStream contents' does
not always return the original collection. This may change.
"
-! !
-
-!WriteStream methodsFor:'queries'!
-
-isWritable
- ^ true
-! !
+!
-!WriteStream methodsFor:'private accessing'!
-
-on:aCollection from:start to:last
- "create and return a new stream for writing onto aCollection, where
- writing is limited to the elements in the range start to last."
-
- super on:aCollection from:start to:last.
- writeLimit := last.
+version
+ ^ '$Header: /cvs/stx/stx/libbasic/WriteStream.st,v 1.22 1995-11-23 01:32:01 cg Exp $'
! !
!WriteStream methodsFor:'accessing'!
@@ -99,6 +83,82 @@
super reset
! !
+!WriteStream methodsFor:'ignored'!
+
+bold
+ "change font to bold - ignored here.
+ - this allows WriteStreams to be compatible to PrinterStreams"
+!
+
+boldItalic
+ "change font to italic - ignored here.
+ - this allows WriteStreams to be compatible to PrinterStreams"
+!
+
+italic
+ "change font to italic - ignored here.
+ - this allows WriteStreams to be compatible to PrinterStreams"
+!
+
+normal
+ "change font to normal - ignored here.
+ - this allows WriteStreams to be compatible to PrinterStreams"
+! !
+
+!WriteStream methodsFor:'positioning'!
+
+position:index
+ "redefined to allow positioning past the readLimit"
+
+ ((index > (collection size + 1)) or:[index < 0]) ifTrue: [^ self positionError].
+ position := index
+! !
+
+!WriteStream methodsFor:'private'!
+
+growCollection
+ self growCollection:10
+!
+
+growCollection:minNewSize
+ "grow the streamed collection to at least minNewSize"
+
+ |oldSize newSize newColl|
+
+ oldSize := collection size.
+ (oldSize == 0) ifTrue:[
+ newSize := minNewSize
+ ] ifFalse:[
+ newSize := oldSize * 2.
+ [newSize < minNewSize] whileTrue:[
+ newSize := newSize * 2
+ ]
+ ].
+ collection isFixedSize ifTrue:[
+ newColl := collection species new:newSize.
+ newColl replaceFrom:1 to:oldSize with:collection startingAt:1.
+ collection := newColl
+ ] ifFalse:[
+ collection grow:newSize
+ ].
+! !
+
+!WriteStream methodsFor:'private accessing'!
+
+on:aCollection from:start to:last
+ "create and return a new stream for writing onto aCollection, where
+ writing is limited to the elements in the range start to last."
+
+ super on:aCollection from:start to:last.
+ writeLimit := last.
+! !
+
+!WriteStream methodsFor:'queries'!
+
+isWritable
+ ^ true
+! !
+
!WriteStream methodsFor:'reading'!
next
@@ -113,16 +173,31 @@
self shouldNotImplement
! !
-!WriteStream methodsFor:'positioning'!
+!WriteStream methodsFor:'writing'!
-position:index
- "redefined to allow positioning past the readLimit"
+next:count put:anObject
+ "append anObject count times to the receiver.
+ Redefined to avoid count grows of the underlying collection -
+ instead a single grow on the final size is performed."
+
+ |final|
+
+ (collection isNil or:[writeLimit notNil]) ifTrue:[
+ ^ super next:count put:anObject
+ ].
- ((index > (collection size + 1)) or:[index < 0]) ifTrue: [^ self positionError].
- position := index
-! !
+ final := position + count - 1.
+ (final > collection size) ifTrue:[
+ self growCollection:final
+ ].
-!WriteStream methodsFor:'writing'!
+ position to:final do:[:index |
+ collection at:index put:anObject.
+ ].
+ position := position + count.
+ (position > readLimit) ifTrue:[readLimit := position - 1].
+ ^ anObject
+!
nextPut:anObject
"append the argument, anObject to the stream"
@@ -204,30 +279,6 @@
^anObject
!
-next:count put:anObject
- "append anObject count times to the receiver.
- Redefined to avoid count grows of the underlying collection -
- instead a single grow on the final size is performed."
-
- |final|
-
- (collection isNil or:[writeLimit notNil]) ifTrue:[
- ^ super next:count put:anObject
- ].
-
- final := position + count - 1.
- (final > collection size) ifTrue:[
- self growCollection:final
- ].
-
- position to:final do:[:index |
- collection at:index put:anObject.
- ].
- position := position + count.
- (position > readLimit) ifTrue:[readLimit := position - 1].
- ^ anObject
-!
-
nextPutAll:aCollection
"append all elements of the argument, aCollection to the stream.
Redefined to avoid count grows of the underlying collection -
@@ -259,53 +310,3 @@
^ aCollection
! !
-!WriteStream methodsFor:'ignored'!
-
-bold
- "change font to bold - ignored here.
- - this allows WriteStreams to be compatible to PrinterStreams"
-!
-
-italic
- "change font to italic - ignored here.
- - this allows WriteStreams to be compatible to PrinterStreams"
-!
-
-boldItalic
- "change font to italic - ignored here.
- - this allows WriteStreams to be compatible to PrinterStreams"
-!
-
-normal
- "change font to normal - ignored here.
- - this allows WriteStreams to be compatible to PrinterStreams"
-! !
-
-!WriteStream methodsFor:'private'!
-
-growCollection
- self growCollection:10
-!
-
-growCollection:minNewSize
- "grow the streamed collection to at least minNewSize"
-
- |oldSize newSize newColl|
-
- oldSize := collection size.
- (oldSize == 0) ifTrue:[
- newSize := minNewSize
- ] ifFalse:[
- newSize := oldSize * 2.
- [newSize < minNewSize] whileTrue:[
- newSize := newSize * 2
- ]
- ].
- collection isFixedSize ifTrue:[
- newColl := collection species new:newSize.
- newColl replaceFrom:1 to:oldSize with:collection startingAt:1.
- collection := newColl
- ] ifFalse:[
- collection grow:newSize
- ].
-! !