FilteringLineStream.st
author Claus Gittinger <cg@exept.de>
Thu, 02 Mar 2000 15:15:13 +0100
changeset 885 c31412b26306
parent 474 61cb199537b5
child 988 e7e70b439226
permissions -rw-r--r--
package-definitions fixed/updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
     1
"{ Package: 'stx:goodies' }"
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
     2
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
     3
"
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
     4
 COPYRIGHT (c) 1996 by Claus Gittinger
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
     5
	      All Rights Reserved
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
     6
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
     7
 This software is furnished under a license and may be used
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
     8
 only in accordance with the terms of that license and with the
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    10
 be provided or otherwise made available to, or used by, any
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    11
 other person.  No title to or ownership of the software is
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    12
 hereby transferred.
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    13
"
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    14
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    15
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
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:
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
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
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    78
								[exEnd]
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
    79
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
    80
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    81
  filter all comments (starting with '#') from a Makefile:
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    82
								[exBegin]
400
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
    83
    |in filter|
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
    84
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
    85
    in := 'Makefile' asFilename readStream.
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
    86
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
    87
    filter := FilteringLineStream readingFrom:in.
400
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
    88
    filter filter:[:line | (line startsWith:'#') ifTrue:[line] ifFalse:[nil]].
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
    89
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
    90
    filter outputStream:Transcript.
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
    91
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
    92
    filter filterUpToEnd
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    93
								[exEnd]
400
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
    94
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
    95
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    96
  the inverse - remove all comments from the Makefile:
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    97
								[exBegin]
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    98
    |in filter|
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
    99
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   100
    in := 'Makefile' asFilename readStream.
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   101
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   102
    filter := FilteringLineStream readingFrom:in.
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   103
    filter filter:[:line | (line startsWith:'#') ifTrue:[nil] ifFalse:[line]].
400
f61c18fd77be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 399
diff changeset
   104
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   105
    filter outputStream:Transcript.
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   106
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   107
    filter filterUpToEnd
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   108
								[exEnd]
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   109
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   110
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   111
  feed a second filter from the first filters output;
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   112
  (the remains are all lines starting with '#' and ending with '-'):
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   113
								[exBegin]
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    |in filter1 filter2|
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    in := 'Makefile' asFilename readStream.
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   118
    filter1 := FilteringLineStream readingFrom:in.
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    filter1 filter:[:line | (line startsWith:'#') ifTrue:[line] ifFalse:[nil]].
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   121
    filter2 := FilteringLineStream readingFrom:filter1.
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   122
    filter2 filter:[:line | (line endsWith:'-') ifTrue:[line] ifFalse:[nil]].
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    filter2 outputStream:Transcript.
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   126
    filter2 filterUpToEnd
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   127
								[exEnd]
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
"
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
! !
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   132
!FilteringLineStream methodsFor:'access - pull-reading'!
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   133
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   134
filterUpToEnd
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   135
    "pull input from inputStream up to the end,
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   136
     push it filtered into the outputStream."
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   137
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   138
    [inputStream atEnd] whileFalse:[
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   139
	self nextPutLine:(inputStream nextLine)
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   140
    ].
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   141
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   142
    "Created: 11.1.1997 / 16:09:05 / cg"
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   143
! !
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   144
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
!FilteringLineStream methodsFor:'access - push-writing'!
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
cr
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
    "finish a line, push it filtered into the outputStream"
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
    |output|
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   152
    lineFilter isNil ifTrue:[
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   153
	lineBuffer notNil ifTrue:[
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   154
	    outputStream nextPutAll:lineBuffer
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   155
	].
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   156
	outputStream cr
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   157
    ] ifFalse:[
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   158
	lineBuffer isNil ifTrue:[lineBuffer := ''].
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   160
	output := lineFilter value:lineBuffer.
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   161
	output notNil ifTrue:[
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   162
	    outputStream nextPutAll:output.
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   163
	    outputStream cr.
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   164
	]
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
    ].
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
    lineBuffer := ''.
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   168
    "Modified: 11.1.1997 / 16:32:40 / cg"
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
!
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
nextPut:something
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
    "collect a line and push it when a cr arrives"
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
    something == Character cr ifTrue:[
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   175
	self cr
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    ] ifFalse:[
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   177
	lineBuffer isNil ifTrue:[lineBuffer := ''].
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   178
	lineBuffer := lineBuffer copyWith:something.
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
    "Created: 2.7.1996 / 20:54:38 / cg"
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
    "Modified: 2.7.1996 / 21:03:26 / cg"
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
!
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
nextPutAll:something
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    "collect a line and push it when a cr arrives"
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   188
    lineBuffer isNil ifTrue:[
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   189
	lineBuffer := something
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   190
    ] ifFalse:[
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   191
	lineBuffer := lineBuffer , something.
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   192
    ]
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   193
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   194
    "Modified: 11.1.1997 / 16:31:28 / cg"
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   195
! !
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   196
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   197
!FilteringLineStream methodsFor:'accessing'!
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   199
filter
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   200
    "return the filter"
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   201
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   202
    ^ lineFilter
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
    "Created: 11.1.1997 / 16:13:15 / 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
filter:aBlock
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   208
    "set the filter"
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   209
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   210
    lineFilter := aBlock
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
    "Created: 11.1.1997 / 16:13:25 / cg"
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
! !
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
473
cb46b0ba9934 comment
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
   215
!FilteringLineStream class methodsFor:'documentation'!
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
version
885
c31412b26306 package-definitions fixed/updated
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   218
    ^ '$Header: /cvs/stx/stx/libbasic2/FilteringLineStream.st,v 1.5 2000-03-02 14:15:07 cg Exp $'
399
7007796f7a34 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
! !