/src/lib/io/core/binary_input_stream.e
Specman e | 129 lines | 73 code | 12 blank | 44 comment | 0 complexity | 1d63971790036d9545df124696e88d3b MD5 | raw file
1-- This file is part of a Liberty Eiffel library. 2-- See the full copyright at the end. 3-- 4deferred class BINARY_INPUT_STREAM 5 -- 6 -- A binary input stream is an input stream that is binary safe (meaning that, except for failure modes, 7 -- you can read back the very same sequence of bytes you wrote to that stream) 8 -- 9 10inherit 11 INPUT_STREAM 12 13feature {ANY} 14 read_byte 15 -- Read a byte and assign it to `last_byte'. 16 require 17 is_connected 18 not is_filtered 19 can_read_character 20 deferred 21 end 22 23 last_byte: INTEGER 24 -- Last byte read with `read_byte'. 25 require 26 is_connected 27 not end_of_input 28 not is_filtered 29 deferred 30 end 31 32 read_integer_16_native_endian 33 -- Read in the same order as the machine running this code. If a 34 -- 16-bits value is available, it's assigned to `last_integer_16'. 35 -- The result is machine dependant. 36 require 37 is_connected 38 not is_filtered 39 can_read_character 40 deferred 41 end 42 43 read_integer_16_big_endian 44 -- Read a big endian value is the file. If a 16-bits value 45 -- is available, it's assigned to `last_integer_16'. 46 require 47 is_connected 48 not is_filtered 49 can_read_character 50 deferred 51 end 52 53 read_integer_16_little_endian 54 -- Read a little endian value is the file. If a 16-bits value 55 -- is available, it's assigned to `last_integer_16'. 56 require 57 is_connected 58 not is_filtered 59 can_read_character 60 deferred 61 end 62 63 last_integer_16: INTEGER 64 -- Last byte read with `read_integer_16_*'. 65 require 66 is_connected 67 not end_of_input 68 not is_filtered 69 deferred 70 end 71 72 read_integer_32_native_endian 73 -- Read in the same order as the machine running this code. If a 74 -- 32-bits value is available, it's assigned to `last_integer_32'. 75 -- The result is machine dependant. 76 require 77 is_connected 78 deferred 79 end 80 81 read_integer_32_big_endian 82 -- Read a big endian value is the file. If 32-bits value 83 -- is available, it's assigned to `last_integer_32'. 84 require 85 is_connected 86 not is_filtered 87 can_read_character 88 deferred 89 end 90 91 read_integer_32_little_endian 92 -- Read a little endian value is the file. If a 32-bits value 93 -- is available, it's assigned to `last_integer_32'. 94 require 95 is_connected 96 not is_filtered 97 can_read_character 98 deferred 99 end 100 101 last_integer_32: INTEGER 102 require 103 is_connected 104 not end_of_input 105 not is_filtered 106 deferred 107 end 108 109end -- class BINARY_INPUT_STREAM 110-- 111-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file. 112-- 113-- Permission is hereby granted, free of charge, to any person obtaining a copy 114-- of this software and associated documentation files (the "Software"), to deal 115-- in the Software without restriction, including without limitation the rights 116-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 117-- copies of the Software, and to permit persons to whom the Software is 118-- furnished to do so, subject to the following conditions: 119-- 120-- The above copyright notice and this permission notice shall be included in 121-- all copies or substantial portions of the Software. 122-- 123-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 124-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 125-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 126-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 127-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 128-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 129-- THE SOFTWARE.