/src/lib/io/tools/standard_streams.e

http://github.com/tybor/Liberty · Specman e · 95 lines · 53 code · 13 blank · 29 comment · 0 complexity · 9b4062ad64ab33fc1c7cc55ad782dc4d MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. class STANDARD_STREAMS
  5. --
  6. -- Thanks to this `standard_streams' singleton object, you can redirect `std_input_stream',
  7. -- `std_output_stream' as well as `std_error_stream'.
  8. --
  9. -- See also the examples from our tutorial/io directory.
  10. --
  11. insert
  12. SINGLETON
  13. rename io as any_io,
  14. std_input as any_std_input,
  15. std_output as any_std_output,
  16. std_error as any_std_error
  17. end
  18. create {ANY}
  19. make
  20. feature {ANY}
  21. std_input: INPUT_STREAM
  22. std_output: OUTPUT_STREAM
  23. std_error: OUTPUT_STREAM
  24. feature {ANY}
  25. set_std_input (a_std_input: like std_input)
  26. require
  27. a_std_input.is_connected
  28. do
  29. std_input := a_std_input
  30. end
  31. restore_std_input
  32. do
  33. set_std_input(any_std_input)
  34. end
  35. set_std_output (a_std_output: like std_output)
  36. require
  37. a_std_output.is_connected
  38. do
  39. std_output := a_std_output
  40. end
  41. restore_std_output
  42. do
  43. set_std_output(any_std_output)
  44. end
  45. set_std_error (a_std_error: like std_error)
  46. require
  47. a_std_error.is_connected
  48. do
  49. std_error := a_std_error
  50. end
  51. restore_std_error
  52. do
  53. set_std_error(any_std_error)
  54. end
  55. feature {}
  56. make
  57. do
  58. restore_std_input
  59. restore_std_output
  60. restore_std_error
  61. end
  62. end -- class STANDARD_STREAMS
  63. --
  64. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  65. --
  66. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  67. -- of this software and associated documentation files (the "Software"), to deal
  68. -- in the Software without restriction, including without limitation the rights
  69. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  70. -- copies of the Software, and to permit persons to whom the Software is
  71. -- furnished to do so, subject to the following conditions:
  72. --
  73. -- The above copyright notice and this permission notice shall be included in
  74. -- all copies or substantial portions of the Software.
  75. --
  76. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  77. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  78. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  79. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  80. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  81. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  82. -- THE SOFTWARE.