+
Point of view
All features
deferred class INPUT_STREAM_TOOLS
Summary
Direct parents
Insert list: ANY
Known children
Insert list: INPUT_STREAM
Overview
Features
{ANY}
Skipping separators:
{ANY}
To read one number at a time:
{ANY}
To read one line or one word at a time:
{ANY}
Other features:
{ANY}
{}
read_character
deferred procedure
{ANY}
If read_character fail, end_of_input is set.
Else, use last_character. Read tutorial or io cluster documentation to learn the read_character usage pattern.
require ensure
read_line_in (buffer: STRING)
deferred procedure
{ANY}
Same job as read_line but storage is directly done in buffer.
Read tutorial or io cluster documentation to learn the read_line usage pattern.
require
read_available_in (buffer: STRING, limit: INTEGER_32)
deferred procedure
{ANY}
Same job as read_available but storage is directly done in buffer.
The usage pattern is the same as for read_line.
require
unread_character
deferred procedure
{ANY}
last_character: CHARACTER
deferred function
{ANY}
can_read_character: BOOLEAN
deferred function
{ANY}
Note that this state is usually temporary.
Usually it is called until either it becomes True or the stream is disconnected:
 from
 until
    stream.can_read_character or else not stream.is_connected
 loop
    -- some "still waiting..." code, maybe a sandglass?
 end
 if stream.is_connected then
    stream.read_character
 end
See also: is_connected, end_of_input
require ensure
can_read_line: BOOLEAN
deferred function
{ANY}
require
can_unread_character: BOOLEAN
deferred function
{ANY}
valid_last_character: BOOLEAN
deferred function
{ANY}
require
end_of_input: BOOLEAN
deferred function
{ANY}
end_of_input means the previous attempt in character reading failed because the end has been reached.
So last_character is not valid and you are not allowed to do any read attempt anymore.
Notes:
  • Just after a successful connect, end_of_input is always False because you did not yet read anything).
  • Once the end of input has been reached, this is definitive in that no more characters will ever be provided (but of course you can still come back if can_unread_character; end_of_input will be changed if you unread_character). In that, it is different from can_read_character which is only a temporary state.
Please refer to the Liberty Eiffel FAQ or tutorial/io examples.
is_filtered: BOOLEAN
deferred function
{ANY}
is_connected: BOOLEAN
deferred function
{ANY}
skip_separators
effective procedure
{ANY}
Skip all separators (see is_separator of class CHARACTER) and make the first non-separator available in last_character.
This non-separator character is pushed back into the stream (see unread_character) to be available one more time (the next read_character will consider this non-separator). When end_of_input occurs, this process is automatically stopped.
require
skip_separators_using (separators: STRING)
effective procedure
{ANY}
Same job as skip_separators using the separators set.
require
skip_remainder_of_line
effective procedure
{ANY}
Skip all the remainder of the line including the end of line delimiter itself.
read_integer
effective procedure
{ANY}
Read an integer according to the Eiffel syntax.
 Make result available in last_integer.  Heading
separators are automatically skipped using is_separator of class CHARACTER.  Trailing separators
are not skipped.
require ensure
last_integer: INTEGER_32
writable attribute
{ANY}
Last integer read using read_integer.
valid_last_integer: BOOLEAN
writable attribute
{ANY}
Was the last call to read_integer successful ?
last_real: REAL_64
writable attribute
{ANY}
Last real read with read_real.
valid_last_real: BOOLEAN
writable attribute
{ANY}
Was the last call to read_real successful ?
read_real
effective procedure
{ANY}
Read a REAL and make the result available in last_real.
require ensure
last_string: STRING
once function
{ANY}
Access to the unique common buffer to get for example the result computed by read_line, read_word, newline, etc.
This is a once function (the same common buffer is used for all streams).
read_line
effective procedure
{ANY}
Read a complete line ended by '%N' or end_of_input.%
% Make the result available in last_string common buffer. The end of line character (usually '%N') is not added in the last_string buffer. Read tutorial or io cluster documentation to learn the read_line usage pattern.
See also read_line_in.
require
read_available (limit: INTEGER_32)
effective procedure
{ANY}
Read as many characters as possible, as long as the stream does not block and up to the given limit.
read_word
effective procedure
{ANY}
Read a word using is_separator of class CHARACTER.
The result is available in the last_string common buffer. Heading separators are automatically skipped. Trailing separators are not skipped (last_character is left on the first one). If end_of_input is encountered, Result can be the empty string.
require
newline
effective procedure
{ANY}
Consume input until newline ('%N') is found.
% The corresponding STRING is stored in last_string common buffer.
require
reach_and_skip (keyword: STRING)
effective procedure
{ANY}
Try to skip enough characters in order to reach the keyword which is skipped too.
If the keyword is not in the remainder of this stream, the process is stopped as soon as end_of_input occurs.
require ensure
read_word_using (separators: STRING)
effective procedure
{ANY}
Same job as read_word using separators.
require
read_tail_in (str: STRING)
effective procedure
{ANY}
Read all remaining character of the stream in str.
require ensure
io_getc (stream: POINTER): INTEGER_32
{}
io_ungetc (byte: CHARACTER, stream: POINTER)
{}
io_fread (buf: NATIVE_ARRAY[CHARACTER], size: INTEGER_32, stream: POINTER): INTEGER_32
{}
return size read or 0 if end of input (-1 on error => exception ?)
{}