52076c9ee496658d12f8ab31b9b9094d11bec7df
1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2006 Floréal Morandat <morandat@lirmm.fr>
5 # This file is free software, which comes along with NIT. This software is
6 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
7 # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
8 # PARTICULAR PURPOSE. You can modify it is you want, provided this header
9 # is kept unaltered, and a notification of the changes is added.
10 # You are allowed to redistribute it and sell it, alone or is a part of
15 # Filter readed elements
16 readable attr _stream
: IStream
24 private meth stream
=(i
: IStream)
32 # Filter outputed elements
33 readable attr _stream
: OStream
35 # Can the stream be used to write
36 redef meth is_writable
: Bool
39 return stream
.is_writable
42 private meth stream
=(i
: OStream)
50 attr _streams
: Iterator[IStream]
54 if stream
== null then
56 else if stream
.eof
then
65 redef meth stream
: IStream
67 if _stream
== null and _streams
.is_ok
then
68 stream
= _streams
.item
69 assert _stream
!= null
75 redef meth read_char
: Int
78 return stream
.read_char
83 while stream
!= null do
89 init with_streams
(streams
: Array[IStream])
91 _streams
= streams
.iterator
93 init(streams
: IStream ...)
95 _streams
= streams
.iterator
100 special FilterOStream
101 attr _streams
: Array[OStream]
103 redef meth is_writable
: Bool
105 if stream
.is_writable
then
110 if i
.is_writable
then
118 redef meth write
(s
: String)
123 if stream
.is_writable
then
129 init with_streams
(streams
: Array[OStream])
134 init(streams
: OStream ...)