/src/lib/io/core/binary_input_stream.e

http://github.com/tybor/Liberty · 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. --
  4. deferred 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. inherit
  10. INPUT_STREAM
  11. feature {ANY}
  12. read_byte
  13. -- Read a byte and assign it to `last_byte'.
  14. require
  15. is_connected
  16. not is_filtered
  17. can_read_character
  18. deferred
  19. end
  20. last_byte: INTEGER
  21. -- Last byte read with `read_byte'.
  22. require
  23. is_connected
  24. not end_of_input
  25. not is_filtered
  26. deferred
  27. end
  28. read_integer_16_native_endian
  29. -- Read in the same order as the machine running this code. If a
  30. -- 16-bits value is available, it's assigned to `last_integer_16'.
  31. -- The result is machine dependant.
  32. require
  33. is_connected
  34. not is_filtered
  35. can_read_character
  36. deferred
  37. end
  38. read_integer_16_big_endian
  39. -- Read a big endian value is the file. If a 16-bits value
  40. -- is available, it's assigned to `last_integer_16'.
  41. require
  42. is_connected
  43. not is_filtered
  44. can_read_character
  45. deferred
  46. end
  47. read_integer_16_little_endian
  48. -- Read a little endian value is the file. If a 16-bits value
  49. -- is available, it's assigned to `last_integer_16'.
  50. require
  51. is_connected
  52. not is_filtered
  53. can_read_character
  54. deferred
  55. end
  56. last_integer_16: INTEGER
  57. -- Last byte read with `read_integer_16_*'.
  58. require
  59. is_connected
  60. not end_of_input
  61. not is_filtered
  62. deferred
  63. end
  64. read_integer_32_native_endian
  65. -- Read in the same order as the machine running this code. If a
  66. -- 32-bits value is available, it's assigned to `last_integer_32'.
  67. -- The result is machine dependant.
  68. require
  69. is_connected
  70. deferred
  71. end
  72. read_integer_32_big_endian
  73. -- Read a big endian value is the file. If 32-bits value
  74. -- is available, it's assigned to `last_integer_32'.
  75. require
  76. is_connected
  77. not is_filtered
  78. can_read_character
  79. deferred
  80. end
  81. read_integer_32_little_endian
  82. -- Read a little endian value is the file. If a 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. last_integer_32: INTEGER
  91. require
  92. is_connected
  93. not end_of_input
  94. not is_filtered
  95. deferred
  96. end
  97. end -- class BINARY_INPUT_STREAM
  98. --
  99. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  100. --
  101. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  102. -- of this software and associated documentation files (the "Software"), to deal
  103. -- in the Software without restriction, including without limitation the rights
  104. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  105. -- copies of the Software, and to permit persons to whom the Software is
  106. -- furnished to do so, subject to the following conditions:
  107. --
  108. -- The above copyright notice and this permission notice shall be included in
  109. -- all copies or substantial portions of the Software.
  110. --
  111. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  112. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  113. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  114. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  115. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  116. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  117. -- THE SOFTWARE.