/src/lib/io/core/output_stream.e
Specman e | 109 lines | 66 code | 14 blank | 29 comment | 3 complexity | ca5a53323009030287b32e987815b420 MD5 | raw file
1-- This file is part of a Liberty Eiffel library. 2-- See the full copyright at the end. 3-- 4deferred class OUTPUT_STREAM 5 -- 6 -- An output stream is a flow of characters that can be written to some destination (be it an Eiffel object or 7 -- an external object) 8 -- 9 10inherit 11 STREAM 12 13insert 14 OUTPUT_STREAM_TOOLS 15 FILTERABLE 16 redefine filter 17 end 18 19feature {ANY} 20 put_character (c: CHARACTER) 21 do 22 filtered_put_character(c) 23 end 24 25 flush 26 -- Flushes the pipe. If `is_filtered', calls the filter's 27 -- `flush' instead. 28 do 29 if filter /= Void then 30 filter.flush 31 else 32 filtered_flush 33 end 34 end 35 36 can_put_character (c: CHARACTER): BOOLEAN 37 deferred 38 end 39 40 detach 41 do 42 if filter /= Void then 43 filter.do_detach 44 filter := Void 45 end 46 filtered_flush 47 end 48 49feature {FILTER_OUTPUT_STREAM} 50 filtered_put_character (c: CHARACTER) 51 require 52 is_connected 53 can_put_character(c) 54 deferred 55 end 56 57 filtered_flush 58 require 59 is_connected 60 deferred 61 end 62 63feature {FILTER} 64 filter: FILTER_OUTPUT_STREAM 65 66feature {ANY} 67 event_can_write: EVENT_DESCRIPTOR 68 do 69 Result := can_write 70 if Result = Void then 71 create can_write.make(Current) 72 Result := can_write 73 end 74 end 75 76feature {} 77 can_write: CAN_WRITE_DATA_TO_STREAM 78 79 new_url: URL 80 do 81 create Result.from_stream(Current, False, True) 82 end 83 84 as_output_stream: OUTPUT_STREAM 85 do 86 Result := Current 87 end 88 89end -- class OUTPUT_STREAM 90-- 91-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file. 92-- 93-- Permission is hereby granted, free of charge, to any person obtaining a copy 94-- of this software and associated documentation files (the "Software"), to deal 95-- in the Software without restriction, including without limitation the rights 96-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 97-- copies of the Software, and to permit persons to whom the Software is 98-- furnished to do so, subject to the following conditions: 99-- 100-- The above copyright notice and this permission notice shall be included in 101-- all copies or substantial portions of the Software. 102-- 103-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 104-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 105-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 106-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 107-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 108-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 109-- THE SOFTWARE.