PageRenderTime 31ms CodeModel.GetById 26ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/lib/io/basic/string_input_stream.e

http://github.com/tybor/Liberty
Specman e | 117 lines | 69 code | 20 blank | 28 comment | 0 complexity | a8888502c15a40be9e37f748a3f20961 MD5 | raw file
  1-- This file is part of a Liberty Eiffel library.
  2-- See the full copyright at the end.
  3--
  4class STRING_INPUT_STREAM
  5   --
  6   -- An input stream where the data is read from a string.
  7   --
  8
  9inherit
 10   TERMINAL_INPUT_STREAM
 11      redefine
 12         valid_last_character, dispose
 13      end
 14
 15create {ANY}
 16   from_string
 17
 18feature {ANY}
 19   end_of_input: BOOLEAN
 20      do
 21         Result := offset > string.upper
 22      end
 23
 24   is_connected: BOOLEAN
 25
 26   must_disconnect: BOOLEAN False
 27
 28   can_unread_character: BOOLEAN
 29      do
 30         Result := offset >= string.lower
 31      end
 32
 33   disconnect
 34      do
 35         filter := Void
 36         is_connected := False
 37      end
 38
 39   valid_last_character: BOOLEAN
 40      do
 41         Result := string.valid_index(offset)
 42      end
 43
 44feature {FILTER_INPUT_STREAM}
 45   filtered_read_character
 46      do
 47         offset := offset + 1
 48      end
 49
 50   filtered_unread_character
 51      do
 52         offset := offset - 1
 53      end
 54
 55   filtered_last_character: CHARACTER
 56      do
 57         Result := string.item(offset)
 58      end
 59
 60feature {FILTER}
 61   filtered_descriptor: INTEGER
 62      do
 63         std_error.put_string("STRING_INPUT_STREAM.filtered_descriptor has been called!%N")
 64         crash
 65      end
 66
 67   filtered_has_descriptor: BOOLEAN False
 68
 69   filtered_stream_pointer: POINTER
 70      do
 71         std_error.put_string("STRING_INPUT_STREAM.filtered_stream_pointer has been called!%N")
 72         crash
 73      end
 74
 75   filtered_has_stream_pointer: BOOLEAN False
 76
 77feature {}
 78   dispose
 79      do
 80         -- No need to force people to disconnect such a STREAM.
 81      end
 82
 83   from_string (a_string: ABSTRACT_STRING)
 84      require
 85         a_string /= Void
 86      do
 87         string := a_string.out
 88         offset := string.lower - 1
 89         is_connected := True
 90      end
 91
 92   string: STRING
 93         -- where the data comes from
 94
 95   offset: INTEGER
 96
 97end -- class STRING_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.