PageRenderTime 14ms CodeModel.GetById 11ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/lib/io/basic/simple_input_output_stream.e

http://github.com/tybor/Liberty
Specman e | 121 lines | 71 code | 20 blank | 30 comment | 0 complexity | 9c1254994f2dd1143f9d90c8cbb383f8 MD5 | raw file
  1-- This file is part of a Liberty Eiffel library.
  2-- See the full copyright at the end.
  3--
  4class SIMPLE_INPUT_OUTPUT_STREAM
  5   --
  6   -- Just a centralized access to and input stream and an output stream.
  7   --
  8   -- Note that it cannot be filtered itself (see invariant).
  9   --
 10
 11inherit
 12   TERMINAL_INPUT_OUTPUT_STREAM
 13
 14create {ANY}
 15   make
 16
 17feature {}
 18   make (a_in: like in_stream; a_out: like out_stream)
 19      do
 20         in_stream := a_in
 21         out_stream := a_out
 22      end
 23
 24   in_stream: INPUT_STREAM
 25
 26   out_stream: OUTPUT_STREAM
 27
 28feature {ANY}
 29   is_connected: BOOLEAN
 30      do
 31         -- Yes, it is an "and" and not an "or": it must be strong enough,
 32         -- otherwise the system won't work
 33         Result := in_stream /= Void and then in_stream.is_connected
 34            and then (out_stream /= Void and then out_stream.is_connected)
 35      end
 36
 37   disconnect
 38      do
 39         in_stream.disconnect
 40         out_stream.disconnect
 41      end
 42
 43feature {ANY}
 44   end_of_input: BOOLEAN
 45      do
 46         Result := in_stream.end_of_input
 47      end
 48
 49   can_unread_character: BOOLEAN
 50      do
 51         Result := in_stream.can_unread_character
 52      end
 53
 54feature {FILTER_INPUT_STREAM} -- input features:
 55   filtered_read_character
 56      do
 57         in_stream.read_character
 58      end
 59
 60   filtered_unread_character
 61      do
 62         in_stream.unread_character
 63      end
 64
 65   filtered_last_character: CHARACTER
 66      do
 67         Result := in_stream.last_character
 68      end
 69
 70feature {FILTER_OUTPUT_STREAM} -- output features:
 71   filtered_put_character (c: CHARACTER)
 72      do
 73         out_stream.put_character(c)
 74      end
 75
 76   filtered_flush
 77      do
 78         out_stream.flush
 79      end
 80
 81feature {FILTER} -- meaningless features:
 82   filtered_descriptor: INTEGER
 83      do
 84         std_error.put_string("INPUT_OUTPUT_STREAM_CONNECTOR.filtered_descriptor has been called!%N")
 85         crash
 86      end
 87
 88   filtered_has_descriptor: BOOLEAN False
 89
 90   filtered_stream_pointer: POINTER
 91      do
 92         std_error.put_string("INPUT_OUTPUT_STREAM_CONNECTOR.filtered_stream_pointer has been called!%N")
 93         crash
 94      end
 95
 96   filtered_has_stream_pointer: BOOLEAN False
 97
 98invariant
 99   not_filtered: not input_is_filtered and not output_is_filtered
100
101end -- class SIMPLE_INPUT_OUTPUT_STREAM
102--
103-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
104--
105-- Permission is hereby granted, free of charge, to any person obtaining a copy
106-- of this software and associated documentation files (the "Software"), to deal
107-- in the Software without restriction, including without limitation the rights
108-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
109-- copies of the Software, and to permit persons to whom the Software is
110-- furnished to do so, subject to the following conditions:
111--
112-- The above copyright notice and this permission notice shall be included in
113-- all copies or substantial portions of the Software.
114--
115-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
116-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
117-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
118-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
119-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
120-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
121-- THE SOFTWARE.