# This file is part of NIT ( http://www.nitlanguage.org ).
#
# Copyright 2006 Floréal Morandat <morandat@lirmm.fr>
+# Copyright 2009 Jean-Sebastien Gelinas <calestar@gmail.com>
#
# This file is free software, which comes along with NIT. This software is
# distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
class FilterIStream
special IStream
# Filter readed elements
- readable var _stream: IStream
+ readable var _stream: nullable IStream
redef fun eof: Bool
do
return stream.eof
end
- private fun stream=(i: IStream)
+ private fun stream=(i: nullable IStream)
do
_stream = i
end
class FilterOStream
special OStream
# Filter outputed elements
- readable var _stream: OStream
+ readable var _stream: nullable OStream
# Can the stream be used to write
redef fun is_writable: Bool
end
end
- redef fun stream: IStream
+ redef fun stream: nullable IStream
do
if _stream == null and _streams.is_ok then
stream = _streams.item
end
end
+ redef fun close
+ do
+ for i in _streams
+ do
+ stream = i
+ stream.close
+ end
+ end
+
init with_streams(streams: Array[OStream])
do
_streams = streams