--- a/FilteringLineStream.st Tue Jul 02 21:04:45 1996 +0200
+++ b/FilteringLineStream.st Tue Jul 02 21:27:59 1996 +0200
@@ -1,5 +1,5 @@
-Stream subclass:#FilteringLineStream
- instanceVariableNames:'lineBuffer inputStream outputStream filter'
+FilteringStream subclass:#FilteringLineStream
+ instanceVariableNames:'lineBuffer'
classVariableNames:''
poolDictionaries:''
category:'Streams'
@@ -9,6 +9,23 @@
examples
"
+ filter all comments from a file:
+
+ |in filter|
+
+ in := 'Makefile' asFilename readStream.
+
+ filter := FilteringLineStream basicNew.
+ filter inputStream:in.
+ filter filter:[:line | (line startsWith:'#') ifTrue:[line] ifFalse:[nil]].
+
+ filter outputStream:Transcript.
+
+ filter filterUpToEnd
+
+
+ feed a second filter from the first filters output:
+
|in filter1 filter2|
in := 'Makefile' asFilename readStream.
@@ -28,20 +45,6 @@
! !
-!FilteringLineStream methodsFor:'access - pull-reading'!
-
-filterUpToEnd
- "pull input from inputStream up to the end,
- push it filtered into the outputStream"
-
- [inputStream atEnd] whileFalse:[
- self nextPut:(inputStream next)
- ].
-
- "Created: 2.7.1996 / 20:58:24 / cg"
- "Modified: 2.7.1996 / 21:02:49 / cg"
-! !
-
!FilteringLineStream methodsFor:'access - push-writing'!
cr
@@ -86,64 +89,8 @@
"Modified: 2.7.1996 / 21:03:30 / cg"
! !
-!FilteringLineStream methodsFor:'accessing'!
-
-filter
- "return the filter"
-
- ^ filter
-
- "Created: 2.7.1996 / 20:56:55 / cg"
- "Modified: 2.7.1996 / 21:03:36 / cg"
-!
-
-filter:something
- "set the filter"
-
- filter := something.
-
- "Created: 2.7.1996 / 20:56:55 / cg"
- "Modified: 2.7.1996 / 21:03:40 / cg"
-!
-
-inputStream
- "return the inputStream"
-
- ^ inputStream
-
- "Created: 2.7.1996 / 20:56:50 / cg"
- "Modified: 2.7.1996 / 21:03:43 / cg"
-!
-
-inputStream:something
- "set the inputStream"
-
- inputStream := something.
-
- "Created: 2.7.1996 / 20:56:50 / cg"
- "Modified: 2.7.1996 / 21:03:46 / cg"
-!
-
-outputStream
- "return the outputStream"
-
- ^ outputStream
-
- "Created: 2.7.1996 / 20:56:53 / cg"
- "Modified: 2.7.1996 / 21:03:49 / cg"
-!
-
-outputStream:something
- "set the outputStream"
-
- outputStream := something.
-
- "Created: 2.7.1996 / 20:56:53 / cg"
- "Modified: 2.7.1996 / 21:03:52 / cg"
-! !
-
!FilteringLineStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/FilteringLineStream.st,v 1.1 1996-07-02 19:04:45 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/FilteringLineStream.st,v 1.2 1996-07-02 19:27:59 cg Exp $'
! !