FilteringStream.st
author Claus Gittinger <cg@exept.de>
Sat, 11 Jan 1997 19:49:15 +0100
changeset 477 6124ae485dbd
parent 474 61cb199537b5
child 479 9653144c97b4
permissions -rw-r--r--
need readAhead
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
472
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
     1
"
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
     2
 COPYRIGHT (c) 1996 by Claus Gittinger
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
     3
              All Rights Reserved
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
     4
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
     5
 This software is furnished under a license and may be used
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
     6
 only in accordance with the terms of that license and with the
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
     8
 be provided or otherwise made available to, or used by, any
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
     9
 other person.  No title to or ownership of the software is
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    10
 hereby transferred.
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    11
"
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    12
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    13
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
Stream subclass:#FilteringStream
477
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    15
	instanceVariableNames:'inputStream outputStream filter readAhead'
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
    18
	category:'Streams-Misc'
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
472
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    21
!FilteringStream class methodsFor:'documentation'!
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    22
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    23
copyright
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    24
"
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    25
 COPYRIGHT (c) 1996 by Claus Gittinger
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    26
              All Rights Reserved
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    27
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    28
 This software is furnished under a license and may be used
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    29
 only in accordance with the terms of that license and with the
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    31
 be provided or otherwise made available to, or used by, any
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    32
 other person.  No title to or ownership of the software is
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    33
 hereby transferred.
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    34
"
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    35
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    36
!
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    37
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    38
documentation
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    39
"
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    40
    A FilteringStream can be connected to some input
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    41
    (from which elements are read via the ReadStream protocol),
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    42
    and/or to some output (to which elements are written via
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    43
    the WriteStream protocol.
477
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    44
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    45
    The FilteringStream itself performs filtering/processing
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    46
    on the elements as they arrive, optionally suppressing
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    47
    elements.
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    48
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    49
    A FilteringStream can be operated in pull-mode, by asking
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    50
    it for the next element; it will then ask its inputStream for
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    51
    and element, process it and return it.
472
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    52
477
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    53
    Or, in pushMode, by having someone else writing elements via
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    54
    nextPut:; it will then process the element, and send it to its 
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    55
    output stream.
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    56
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    57
    Mixing modes does not make sense, since if pulled, data will not
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    58
    be written to the outputStream (unless the puller does it).
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    59
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    60
    The connected streams need not be real streams; anything which
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    61
    responds to the basic Stream protocol can be connected
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
    62
    (a Transcript, a RandomNumber generator or even a Plug will do as well).
472
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    63
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    64
    [instance variables:]
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    65
        inputStream     <Stream>  the stream from which elements are read
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    66
        outputStream    <Stream>  the stream to which elements are written
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    67
        filter          <Block>   the filter block;
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    68
        unbound         <Boolean> if true, the stream is unbound.
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    69
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    70
    [author:]
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    71
        Claus Gittinger
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    72
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    73
    [See also:]
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    74
        ReadStream WriteStream
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    75
"
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    76
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    77
!
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
examples
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
"
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
    81
  pushing the contents of a stream onto another stream
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
    82
  (here, the Transcript) without a need to read everyting into a
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
    83
  buffer or to reinvent the read-loop:
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
    84
  (notice, a FilteringLineStream does this with less overhead)
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
    85
                                                                [exBegin]
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
    86
    |in pusher|
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
    87
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
    88
    in := 'Makefile' asFilename readStream.
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
    89
    pusher := FilteringStream readingFrom:in writingTo:Transcript.
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
    90
    pusher filterUpToEnd
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
    91
                                                                [exEnd]
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
    92
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
    93
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
  filter random numbers:
472
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
    95
                                                                [exBegin]
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    |in filter|
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    in := Random new.
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   100
    filter := FilteringLineStream readingFrom:in.
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    filter filter:[:num | ((num >= 0.5) and:[num <= 0.6]) ifTrue:[num] ifFalse:[nil]].
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    20 timesRepeat:[
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
        Transcript showCR:(filter next printString).
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    ]
472
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
   106
                                                                [exEnd]
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
  filtering prime numbers:
472
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
   109
                                                                [exBegin]
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    |num generator primeFilter addFilter|
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    num := 1.
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    generator := Plug new.
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    generator respondTo:#next
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
                   with:[num := num + 1. num].
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    generator respondTo:#atEnd
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
                   with:[false].
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    addFilter := [:prime | |newFilter|
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
        newFilter := FilteringLineStream basicNew.
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
        newFilter filter:[:num | (num \\ prime) == 0 ifTrue:[
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
                                    nil
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
                                 ] ifFalse:[
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
                                    num
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
                                 ]
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
                         ].
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
        newFilter inputStream:primeFilter.
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
        primeFilter := newFilter
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    ].
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    addFilter value:2.
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    primeFilter inputStream:generator.
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
472
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
   134
    10000 timesRepeat:[
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
        |nextPrime|
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
        nextPrime := primeFilter next.
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
        addFilter value:nextPrime.
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
        Transcript showCR:nextPrime.
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    ]
472
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
   141
                                                                [exEnd]
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
! !
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   148
!FilteringStream class methodsFor:'instance creation'!
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   149
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   150
new
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   151
    "create and return a new filteringStream.
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   152
     The resulting stream must be connected to some other stream,
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   153
     before being used"
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   154
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   155
    ^ self basicNew initialize.
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   156
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   157
    "Created: 11.1.1997 / 15:31:30 / cg"
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   158
    "Modified: 11.1.1997 / 15:33:13 / cg"
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   159
!
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   160
477
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   161
on:something
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   162
    "create and return a new filteringStream, which reads from
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   163
     something (which must be convertable to a stream)"
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   164
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   165
    ^ self readingFrom:something readStream
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   166
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   167
    "Created: 11.1.1997 / 19:19:34 / cg"
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   168
!
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   169
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   170
readingFrom:aReadStream
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   171
    "create and return a new filteringStream, which reads from
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   172
     another stream"
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   173
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   174
    ^ self basicNew initialize inputStream:aReadStream.
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   175
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   176
    "Created: 11.1.1997 / 15:32:15 / cg"
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   177
!
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   178
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   179
readingFrom:aReadStream writingTo:aWriteStream
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   180
    "create and return a new filteringStream, which reads from
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   181
     aReadStream and writes to aWriteStream."
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   182
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   183
    |newStream|
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   184
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   185
    newStream := self basicNew initialize.
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   186
    newStream inputStream:aReadStream.
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   187
    newStream outputStream:aWriteStream.
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   188
    ^ newStream
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   189
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   190
    "Created: 11.1.1997 / 15:32:28 / cg"
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   191
!
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   192
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   193
writingTo:aWriteStream
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   194
    "create and return a new filteringStream, which writes to
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   195
     another stream"
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   196
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   197
    ^ self basicNew initialize outputStream:aWriteStream.
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   198
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   199
    "Created: 11.1.1997 / 15:32:36 / cg"
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   200
! !
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   201
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
!FilteringStream methodsFor:'access - pull-reading'!
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
filterUpToEnd
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
    "pull input from inputStream up to the end,
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   206
     push it filtered into the outputStream."
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
    [inputStream atEnd] whileFalse:[
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
        self nextPut:(inputStream next)
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    ].
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    "Created: 2.7.1996 / 21:06:42 / cg"
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   213
    "Modified: 11.1.1997 / 16:08:35 / cg"
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
!
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
next
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
    "pull input from inputStream and
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
     push it filtered into the outputStream"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
    |input output|
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
477
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   222
    "/ readAhead input has already been filtered
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   223
    "/ (see #atEnd)
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   224
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   225
    readAhead notNil ifTrue:[
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   226
        input := readAhead.
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   227
        readAhead := nil.
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   228
        ^ input
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   229
    ].
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   230
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    [inputStream atEnd] whileFalse:[
472
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
   232
        "/ get an element
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
        input := inputStream next.
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   234
        filter isNil ifTrue:[
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   235
            ^ input
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   236
        ].
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   237
472
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
   238
        "/ filter it - this may return nil, to eat it
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
        output := filter value:input.
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
        output notNil ifTrue:[
472
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
   241
            "/ good - output it
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
            ^ output.
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
        ].
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    ].
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
    ^ nil
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
    "Created: 2.7.1996 / 21:09:58 / cg"
477
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   248
    "Modified: 11.1.1997 / 17:17:27 / cg"
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
! !
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
!FilteringStream methodsFor:'access - push-writing'!
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
nextPut:something
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
    "push something through the filter"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
    |output|
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
472
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
   258
    "/ filter it
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   259
    filter isNil ifTrue:[
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   260
        outputStream nextPut:something
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   261
    ] ifFalse:[
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   262
        output := filter value:something.
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   263
        output notNil ifTrue:[
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   264
            outputStream nextPut:output
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   265
        ]
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
    ]
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   268
    "Modified: 11.1.1997 / 16:12:52 / cg"
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
! !
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
!FilteringStream methodsFor:'accessing'!
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
filter
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
    "return the filter"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
    ^ filter
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
    "Modified: 2.7.1996 / 21:03:36 / cg"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
    "Created: 2.7.1996 / 21:06:42 / cg"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
!
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
filter:something
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
    "set the filter"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
    filter := something.
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
    "Modified: 2.7.1996 / 21:03:40 / cg"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
    "Created: 2.7.1996 / 21:06:42 / cg"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
!
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
inputStream
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
    "return the inputStream"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
    ^ inputStream
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
    "Modified: 2.7.1996 / 21:03:43 / cg"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
    "Created: 2.7.1996 / 21:06:42 / cg"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
!
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
inputStream:something
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
    "set the inputStream"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
    inputStream := something.
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
    "Modified: 2.7.1996 / 21:03:46 / cg"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
    "Created: 2.7.1996 / 21:06:42 / cg"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
!
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
outputStream
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
    "return the outputStream"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
    ^ outputStream
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
    "Modified: 2.7.1996 / 21:03:49 / cg"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
    "Created: 2.7.1996 / 21:06:42 / cg"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
!
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
outputStream:something
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
    "set the outputStream"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
    outputStream := something.
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
    "Modified: 2.7.1996 / 21:03:52 / cg"
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
    "Created: 2.7.1996 / 21:06:42 / cg"
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   325
! !
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   327
!FilteringStream methodsFor:'misc'!
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   329
close
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   330
    "when I am closed, close my input - if any"
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   332
    inputStream notNil ifTrue:[
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   333
        inputStream close
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   334
    ]
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   336
    "Created: 11.1.1997 / 15:27:17 / cg"
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
! !
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
!FilteringStream methodsFor:'queries'!
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
atEnd
472
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
   342
    "return true, if the receiver stream is at the end"
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
   343
477
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   344
    |nextElement|
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   345
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   346
    readAhead notNil ifTrue:[^ false].
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   347
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   348
    filter isNil ifTrue:[
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   349
        "/ then, its easy
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   350
        ^ inputStream atEnd
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   351
    ].
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
477
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   353
    "/ with a filter, things are more complicated, 
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   354
    "/ since we cannot tell, without asking the filter ...
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   355
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   356
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   357
    [inputStream atEnd] whileFalse:[
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   358
        nextElement := inputStream next.
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   359
        readAhead := filter value:nextElement.
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   360
        readAhead notNil ifTrue:[^ false].
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   361
    ].
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   362
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   363
    ^ true
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   364
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   365
    "Modified: 11.1.1997 / 17:16:45 / cg"
474
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   366
!
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   367
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   368
contentsSpecies
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   369
    "return the kind of collection I should return when asked
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   370
     for multiple elements."
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   371
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   372
    ^ inputStream contentsSpecies
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   373
61cb199537b5 comments & fixes
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   374
    "Created: 11.1.1997 / 16:23:22 / cg"
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
! !
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
472
33f423823933 commentary & doc
Claus Gittinger <cg@exept.de>
parents: 401
diff changeset
   377
!FilteringStream class methodsFor:'documentation'!
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
version
477
6124ae485dbd need readAhead
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   380
    ^ '$Header: /cvs/stx/stx/libbasic2/FilteringStream.st,v 1.4 1997-01-11 18:49:15 cg Exp $'
401
f97488701314 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
! !