/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. --
  4. class 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. inherit
  11. TERMINAL_INPUT_OUTPUT_STREAM
  12. create {ANY}
  13. make
  14. feature {}
  15. make (a_in: like in_stream; a_out: like out_stream)
  16. do
  17. in_stream := a_in
  18. out_stream := a_out
  19. end
  20. in_stream: INPUT_STREAM
  21. out_stream: OUTPUT_STREAM
  22. feature {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 := in_stream /= Void and then in_stream.is_connected
  28. and then (out_stream /= Void and then out_stream.is_connected)
  29. end
  30. disconnect
  31. do
  32. in_stream.disconnect
  33. out_stream.disconnect
  34. end
  35. feature {ANY}
  36. end_of_input: BOOLEAN
  37. do
  38. Result := in_stream.end_of_input
  39. end
  40. can_unread_character: BOOLEAN
  41. do
  42. Result := in_stream.can_unread_character
  43. end
  44. feature {FILTER_INPUT_STREAM} -- input features:
  45. filtered_read_character
  46. do
  47. in_stream.read_character
  48. end
  49. filtered_unread_character
  50. do
  51. in_stream.unread_character
  52. end
  53. filtered_last_character: CHARACTER
  54. do
  55. Result := in_stream.last_character
  56. end
  57. feature {FILTER_OUTPUT_STREAM} -- output features:
  58. filtered_put_character (c: CHARACTER)
  59. do
  60. out_stream.put_character(c)
  61. end
  62. filtered_flush
  63. do
  64. out_stream.flush
  65. end
  66. feature {FILTER} -- meaningless features:
  67. filtered_descriptor: INTEGER
  68. do
  69. std_error.put_string("INPUT_OUTPUT_STREAM_CONNECTOR.filtered_descriptor has been called!%N")
  70. crash
  71. end
  72. filtered_has_descriptor: BOOLEAN False
  73. filtered_stream_pointer: POINTER
  74. do
  75. std_error.put_string("INPUT_OUTPUT_STREAM_CONNECTOR.filtered_stream_pointer has been called!%N")
  76. crash
  77. end
  78. filtered_has_stream_pointer: BOOLEAN False
  79. invariant
  80. not_filtered: not input_is_filtered and not output_is_filtered
  81. end -- class SIMPLE_INPUT_OUTPUT_STREAM
  82. --
  83. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  84. --
  85. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  86. -- of this software and associated documentation files (the "Software"), to deal
  87. -- in the Software without restriction, including without limitation the rights
  88. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  89. -- copies of the Software, and to permit persons to whom the Software is
  90. -- furnished to do so, subject to the following conditions:
  91. --
  92. -- The above copyright notice and this permission notice shall be included in
  93. -- all copies or substantial portions of the Software.
  94. --
  95. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  96. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  97. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  98. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  99. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  100. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  101. -- THE SOFTWARE.