--- a/FilteringLineStream.st Fri Dec 11 10:23:53 2009 +0100
+++ b/FilteringLineStream.st Fri Dec 11 10:23:55 2009 +0100
@@ -9,10 +9,7 @@
other person. No title to or ownership of the software is
hereby transferred.
"
-
-
-
-"{ Package: 'stx:goodies' }"
+"{ Package: 'stx:libbasic2' }"
FilteringStream subclass:#FilteringLineStream
instanceVariableNames:'lineBuffer lineFilter'
@@ -69,17 +66,17 @@
pushing the contents of a stream onto another stream
(here, the Transcript) without a need to read everyting into a
buffer or to reinvent the read-loop:
- [exBegin]
+ [exBegin]
|in pusher|
in := 'Makefile' asFilename readStream.
pusher := FilteringLineStream readingFrom:in writingTo:Transcript.
pusher filterUpToEnd
- [exEnd]
+ [exEnd]
filter through an ActorStream:
- [exBegin]
+ [exBegin]
|lineNr in pusher actorPerLine|
lineNr := 0.
@@ -90,11 +87,11 @@
in := 'Makefile' asFilename readStream.
pusher := FilteringLineStream readingFrom:in writingTo:actorPerLine.
pusher filterUpToEnd
- [exEnd]
+ [exEnd]
filter all comments (starting with '#') from a Makefile:
- [exBegin]
+ [exBegin]
|in filter|
in := 'Makefile' asFilename readStream.
@@ -105,11 +102,11 @@
filter outputStream:Transcript.
filter filterUpToEnd
- [exEnd]
+ [exEnd]
the inverse - remove all comments from the Makefile:
- [exBegin]
+ [exBegin]
|in filter|
in := 'Makefile' asFilename readStream.
@@ -120,12 +117,12 @@
filter outputStream:Transcript.
filter filterUpToEnd
- [exEnd]
+ [exEnd]
feed a second filter from the first filters output;
(the remains are all lines starting with '#' and ending with '-'):
- [exBegin]
+ [exBegin]
|in filter1 filter2|
in := 'Makefile' asFilename readStream.
@@ -139,7 +136,7 @@
filter2 outputStream:Transcript.
filter2 filterUpToEnd
- [exEnd]
+ [exEnd]
"
! !
@@ -164,14 +161,14 @@
|output|
lineFilter isNil ifTrue:[
- outputStream nextPutLine:(lineBuffer ? '')
+ outputStream nextPutLine:(lineBuffer ? '')
] ifFalse:[
- lineBuffer isNil ifTrue:[lineBuffer := ''].
+ lineBuffer isNil ifTrue:[lineBuffer := ''].
- output := lineFilter value:lineBuffer.
- output notNil ifTrue:[
- outputStream nextPutLine:output.
- ]
+ output := lineFilter value:lineBuffer.
+ output notNil ifTrue:[
+ outputStream nextPutLine:output.
+ ]
].
lineBuffer := ''.
@@ -225,5 +222,9 @@
!FilteringLineStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/FilteringLineStream.st,v 1.6 2001-11-08 15:34:27 md Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/FilteringLineStream.st,v 1.7 2009-12-11 09:23:55 cg Exp $'
+!
+
+version_CVS
+ ^ '$Header: /cvs/stx/stx/libbasic2/FilteringLineStream.st,v 1.7 2009-12-11 09:23:55 cg Exp $'
! !