1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2006 Floréal Morandat <morandat@lirmm.fr>
4 # Copyright 2009 Jean-Sebastien Gelinas <calestar@gmail.com>
6 # This file is free software, which comes along with NIT. This software is
7 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8 # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
9 # PARTICULAR PURPOSE. You can modify it is you want, provided this header
10 # is kept unaltered, and a notification of the changes is added.
11 # You are allowed to redistribute it and sell it, alone or is a part of
16 # Filter readed elements
17 readable var _stream
: nullable IStream = null
25 private fun stream
=(i
: nullable IStream)
33 # Filter outputed elements
34 readable var _stream
: nullable OStream = null
36 # Can the stream be used to write
37 redef fun is_writable
: Bool
40 return stream
.is_writable
43 private fun stream
=(i
: OStream)
51 var _streams
: Iterator[IStream]
55 if stream
== null then
57 else if stream
.eof
then
66 redef fun stream
: nullable IStream
68 if _stream
== null and _streams
.is_ok
then
69 stream
= _streams
.item
70 assert _stream
!= null
76 redef fun read_char
: Int
79 return stream
.read_char
84 while stream
!= null do
90 init with_streams
(streams
: Array[IStream])
92 _streams
= streams
.iterator
94 init(streams
: IStream ...)
96 _streams
= streams
.iterator
102 var _streams
: Array[OStream]
104 redef fun is_writable
: Bool
106 if stream
.is_writable
then
111 if i
.is_writable
then
119 redef fun write
(s
: String)
124 if stream
.is_writable
then
139 init with_streams
(streams
: Array[OStream])
144 init(streams
: OStream ...)