--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/terminals/Xtreams__CollectionWriteStream.st Mon Aug 22 16:04:00 2011 +0000
@@ -0,0 +1,53 @@
+"{ Package: 'stx:goodies/xtreams/terminals' }"
+
+"{ NameSpace: Xtreams }"
+
+WriteStream subclass:#CollectionWriteStream
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'My Classes'
+!
+
+CollectionWriteStream comment:'Write stream on a sequenceable collection. The collection is grown automatically to accommodate any elements written. Closing a collection write stream will truncate the collection to the current stream position. This behavior is useful as a replacement for the traditional #contents message. The contents can be accessed with the #terminal message after the stream is closed.
+{{{
+ String new writing write: ''Hello World''; -- 6; close; terminal
+}}}
+
+Instance Variables
+ position <Integer> current position of the stream
+ length <Integer> number of valid elements in the destination
+
+'
+!
+
+
+!CollectionWriteStream methodsFor:'accessing'!
+
+put: anObject
+ destination add: anObject
+!
+
+write: anInteger from: aSequenceableCollection at: startIndex
+ startIndex to: startIndex + anInteger - 1 do: [:index |
+ destination add: (aSequenceableCollection at: index)].
+ ^anInteger
+! !
+
+!CollectionWriteStream methodsFor:'initialize-release'!
+
+close
+!
+
+contentsSpecies
+ ^destination species
+!
+
+flush
+! !
+
+!CollectionWriteStream class methodsFor:'documentation'!
+
+version_SVN
+ ^ '$Id$'
+! !