/src/lib/io/core/output_stream.e

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