FilteringLineStream.st
author md
Thu, 08 Nov 2001 16:34:27 +0100
changeset 988 e7e70b439226
parent 885 c31412b26306
child 2377 2c8db8ee1b58
permissions -rw-r--r--
example added
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
     1
"
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
     2
 COPYRIGHT (c) 1996 by Claus Gittinger
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
     3
	      All Rights Reserved
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
     4
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
     5
 This software is furnished under a license and may be used
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
     6
 only in accordance with the terms of that license and with the
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
     8
 be provided or otherwise made available to, or used by, any
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
     9
 other person.  No title to or ownership of the software is
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    10
 hereby transferred.
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    11
"
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    12
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    13
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    14
988
e7e70b439226 example added
md
parents: 885
diff changeset
    15
"{ Package: 'stx:goodies' }"
e7e70b439226 example added
md
parents: 885
diff changeset
    16
400
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
    17
FilteringStream subclass:#FilteringLineStream
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
    18
	instanceVariableNames:'lineBuffer lineFilter'
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	classVariableNames:''
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	poolDictionaries:''
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
    21
	category:'Streams-Misc'
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    24
!FilteringLineStream class methodsFor:'documentation'!
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    25
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    26
copyright
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    27
"
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    28
 COPYRIGHT (c) 1996 by Claus Gittinger
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    29
	      All Rights Reserved
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    30
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    31
 This software is furnished under a license and may be used
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    32
 only in accordance with the terms of that license and with the
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    33
 inclusion of the above copyright notice.   This software may not
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    34
 be provided or otherwise made available to, or used by, any
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    35
 other person.  No title to or ownership of the software is
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    36
 hereby transferred.
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    37
"
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    38
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    39
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    40
!
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    41
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    42
documentation
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    43
"
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    44
    A FilteringLineStream is much like a FilteringStream, but
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    45
    processes its input line-wise.
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    46
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    47
    A FilteringLineStream can be connected to some input
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    48
    (from which characters are read via the ReadStream protocol),
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    49
    and/or to some output (to which characters are written via
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    50
    the WriteStream protocol.
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    51
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    52
    The FilteringLineStream itself performs some filtering/processing
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    53
    on the elements as they arrive, optionally suppressing filtering
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    54
    (i.e. removing) some elements.
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    55
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    56
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    57
    [author:]
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    58
	Claus Gittinger
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    59
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    60
    [See also:]
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    61
	FilteringStream ReadStream WriteStream
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    62
"
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    63
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    64
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    65
!
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
examples
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
"
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
    69
  pushing the contents of a stream onto another stream
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
    70
  (here, the Transcript) without a need to read everyting into a
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
    71
  buffer or to reinvent the read-loop:
988
e7e70b439226 example added
md
parents: 885
diff changeset
    72
                                                                [exBegin]
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
    73
    |in pusher|
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
    74
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
    75
    in := 'Makefile' asFilename readStream.
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
    76
    pusher := FilteringLineStream readingFrom:in writingTo:Transcript.
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
    77
    pusher filterUpToEnd
988
e7e70b439226 example added
md
parents: 885
diff changeset
    78
                                                                [exEnd]
e7e70b439226 example added
md
parents: 885
diff changeset
    79
e7e70b439226 example added
md
parents: 885
diff changeset
    80
e7e70b439226 example added
md
parents: 885
diff changeset
    81
  filter through an ActorStream:
e7e70b439226 example added
md
parents: 885
diff changeset
    82
                                                                [exBegin]
e7e70b439226 example added
md
parents: 885
diff changeset
    83
    |lineNr in pusher actorPerLine|
e7e70b439226 example added
md
parents: 885
diff changeset
    84
e7e70b439226 example added
md
parents: 885
diff changeset
    85
    lineNr := 0.
e7e70b439226 example added
md
parents: 885
diff changeset
    86
e7e70b439226 example added
md
parents: 885
diff changeset
    87
    actorPerLine := ActorStream new.
e7e70b439226 example added
md
parents: 885
diff changeset
    88
    actorPerLine nextPutLineBlock:[:line | lineNr := lineNr + 1. Transcript show:lineNr; showCR:line].
e7e70b439226 example added
md
parents: 885
diff changeset
    89
e7e70b439226 example added
md
parents: 885
diff changeset
    90
    in := 'Makefile' asFilename readStream.
e7e70b439226 example added
md
parents: 885
diff changeset
    91
    pusher := FilteringLineStream readingFrom:in writingTo:actorPerLine.
e7e70b439226 example added
md
parents: 885
diff changeset
    92
    pusher filterUpToEnd
e7e70b439226 example added
md
parents: 885
diff changeset
    93
                                                                [exEnd]
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
    94
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
    95
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    96
  filter all comments (starting with '#') from a Makefile:
988
e7e70b439226 example added
md
parents: 885
diff changeset
    97
                                                                [exBegin]
400
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
    98
    |in filter|
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
    99
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   100
    in := 'Makefile' asFilename readStream.
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   101
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   102
    filter := FilteringLineStream readingFrom:in.
400
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   103
    filter filter:[:line | (line startsWith:'#') ifTrue:[line] ifFalse:[nil]].
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   104
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   105
    filter outputStream:Transcript.
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   106
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   107
    filter filterUpToEnd
988
e7e70b439226 example added
md
parents: 885
diff changeset
   108
                                                                [exEnd]
400
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   109
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   110
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   111
  the inverse - remove all comments from the Makefile:
988
e7e70b439226 example added
md
parents: 885
diff changeset
   112
                                                                [exBegin]
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   113
    |in filter|
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   114
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   115
    in := 'Makefile' asFilename readStream.
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   116
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   117
    filter := FilteringLineStream readingFrom:in.
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   118
    filter filter:[:line | (line startsWith:'#') ifTrue:[nil] ifFalse:[line]].
400
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   119
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   120
    filter outputStream:Transcript.
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   121
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   122
    filter filterUpToEnd
988
e7e70b439226 example added
md
parents: 885
diff changeset
   123
                                                                [exEnd]
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   124
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   125
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   126
  feed a second filter from the first filters output;
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   127
  (the remains are all lines starting with '#' and ending with '-'):
988
e7e70b439226 example added
md
parents: 885
diff changeset
   128
                                                                [exBegin]
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    |in filter1 filter2|
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    in := 'Makefile' asFilename readStream.
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   133
    filter1 := FilteringLineStream readingFrom:in.
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    filter1 filter:[:line | (line startsWith:'#') ifTrue:[line] ifFalse:[nil]].
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   136
    filter2 := FilteringLineStream readingFrom:filter1.
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   137
    filter2 filter:[:line | (line endsWith:'-') ifTrue:[line] ifFalse:[nil]].
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    filter2 outputStream:Transcript.
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   141
    filter2 filterUpToEnd
988
e7e70b439226 example added
md
parents: 885
diff changeset
   142
                                                                [exEnd]
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
"
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
! !
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   146
!FilteringLineStream methodsFor:'access - pull-reading'!
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   147
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   148
filterUpToEnd
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   149
    "pull input from inputStream up to the end,
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   150
     push it filtered into the outputStream."
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   151
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   152
    [inputStream atEnd] whileFalse:[
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   153
	self nextPutLine:(inputStream nextLine)
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   154
    ].
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   155
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   156
    "Created: 11.1.1997 / 16:09:05 / cg"
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   157
! !
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   158
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
!FilteringLineStream methodsFor:'access - push-writing'!
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
cr
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
    "finish a line, push it filtered into the outputStream"
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
    |output|
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   166
    lineFilter isNil ifTrue:[
988
e7e70b439226 example added
md
parents: 885
diff changeset
   167
        outputStream nextPutLine:(lineBuffer ? '')
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   168
    ] ifFalse:[
988
e7e70b439226 example added
md
parents: 885
diff changeset
   169
        lineBuffer isNil ifTrue:[lineBuffer := ''].
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
988
e7e70b439226 example added
md
parents: 885
diff changeset
   171
        output := lineFilter value:lineBuffer.
e7e70b439226 example added
md
parents: 885
diff changeset
   172
        output notNil ifTrue:[
e7e70b439226 example added
md
parents: 885
diff changeset
   173
            outputStream nextPutLine:output.
e7e70b439226 example added
md
parents: 885
diff changeset
   174
        ]
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
    ].
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    lineBuffer := ''.
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   178
    "Modified: 11.1.1997 / 16:32:40 / cg"
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
!
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
nextPut:something
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
    "collect a line and push it when a cr arrives"
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
    something == Character cr ifTrue:[
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   185
	self cr
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    ] ifFalse:[
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   187
	lineBuffer isNil ifTrue:[lineBuffer := ''].
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   188
	lineBuffer := lineBuffer copyWith:something.
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
    ]
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
    "Created: 2.7.1996 / 20:54:38 / cg"
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
    "Modified: 2.7.1996 / 21:03:26 / cg"
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
!
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
nextPutAll:something
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
    "collect a line and push it when a cr arrives"
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   198
    lineBuffer isNil ifTrue:[
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   199
	lineBuffer := something
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   200
    ] ifFalse:[
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   201
	lineBuffer := lineBuffer , something.
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   202
    ]
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   203
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   204
    "Modified: 11.1.1997 / 16:31:28 / cg"
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   205
! !
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   206
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   207
!FilteringLineStream methodsFor:'accessing'!
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   209
filter
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   210
    "return the filter"
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   211
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   212
    ^ lineFilter
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   213
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   214
    "Created: 11.1.1997 / 16:13:15 / cg"
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   215
!
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   216
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   217
filter:aBlock
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   218
    "set the filter"
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   219
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   220
    lineFilter := aBlock
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   221
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   222
    "Created: 11.1.1997 / 16:13:25 / cg"
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
! !
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   225
!FilteringLineStream class methodsFor:'documentation'!
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
version
988
e7e70b439226 example added
md
parents: 885
diff changeset
   228
    ^ '$Header: /cvs/stx/stx/libbasic2/FilteringLineStream.st,v 1.6 2001-11-08 15:34:27 md Exp $'
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
! !