PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/src/lib/io/basic/std_input_output.e

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