package ru.ifmo.testlib;

import java.math.BigInteger;

/**
 * InStream
 *
 * @author Andrew Stankevich
 * @author Dmitry Paraschenko
 */
public interface InStream {
    /**
     * A special value denoting end of file.
     */
    public final static int EOF_CHAR = -1;

    /**
     * Returns the next character from the stream, of {@link #EOF_CHAR} if end of file is reached.
     * Moves the current position in the stream to the next character.
     *
     * @return next character from the stream
     *
     * @throws CheckerException if an error occurred
     */
    public int nextChar();

    /**
     * Returns the next character for the input stream.
     * If end of file is reached, returns {@link #EOF_CHAR}.
     * Doesn't move the current position -
     * the following {#nextChar()} or {#currChar()} call returns the same character.
     *
     * @return current character for the stream
     */
    public int currChar();

    /**
     * Returns whether the end of file was reached.
     *
     * @return whether the end of file was reached.
     */
    public boolean isEoF();

    /**
     * Returns whether the end of line was reached.
     *
     * @return whether the end of line was reached.
     */
    public boolean isEoLn();

    /**
     * Skips spaces and tab-characters and returns whether the end of file was reached.
     *
     * @return whether the end of file was reached after skipping all spaces and tab-characters.
     *
     * @throws CheckerException if an error occurred
     */
    public boolean seekEoF() ;

    /**
     * Skips spaces and tab-characters and returns whether the end of line was reached.
     *
     * @return whether the end of line was reached after skipping all spaces and tab-characters.
     *
     * @throws CheckerException if an error occurred
     */
    public boolean seekEoLn() ;

    /**
     * Skips current line.
     *
     * @throws CheckerException if an error occurred
     */
    public void skipLine() ;

    /**
     * Skips all characters from specified string.
     *
     * @param skip the {@link String} containing characters to be skipped.
     *
     * @throws CheckerException if an error occurred
     */
    public void skip(String skip) ;

    /**
     * Resets the stream.

     * @throws CheckerException if an error occurred
     */
    public void reset() ;

    /**
     * Closes the stream.
     *
     * @throws CheckerException if an error occurred
     */
    public void close() ;

    /**
     * Returns next {@link String} token with specified delimiters.
     *
     * @param before the {@link String} containing characters to be used as delimiters before the token.
     * @param after the {@link String} containing characters to be used as delimiters after the token.
     *  
     * @return next {@link String} token;
     *
     * @throws CheckerException if an error occurred
     */
    public String nextToken(String before, String after) ;

    /**
     * Returns next {@link String} token with specified delimiters.
     *
     * @param skip the {@link String} containing characters to be used as delimiters before and after the token.
     *
     * @return next {@link String} token;
     *
     * @throws CheckerException if an error occurred
     */
    public String nextToken(String skip) ;

    /**
     * Returns next {@link String} token. Whitespace characters are used as delimiters.
     * 
     * @return next {@link String} token.
     *
     * @throws CheckerException if an error occurred
     */
    public String nextToken() ;

    /**
     * Returns next {@link Integer} number. Whitespace characters are used as delimiters.
     *
     * @return next {@link Integer} number.
     *
     * @throws CheckerException if an error occurred
     */
    public int nextInt() ;

    /**
     * Returns next {@link Long} number. Whitespace characters are used as delimiters.
     *
     * @return next {@link Long} number.
     *
     * @throws CheckerException if an error occurred
     */
    public long nextLong() ;

    /**
     * Returns next {@link BigInteger} number. Whitespace characters are used as delimiters.
     *
     * @return next {@link BigInteger} number.
     *
     * @throws CheckerException if an error occurred
     */
    public BigInteger nextBigInteger() ;

    /**
     * Returns next {@link Float} number. Whitespace characters are used as delimiters.
     *
     * @return next {@link Float} number.
     *
     * @throws CheckerException if an error occurred
     */
    public float nextFloat() ;

    /**
     * Returns next {@link Double} number. Whitespace characters are used as delimiters.
     *
     * @return next {@link Double} number.
     *
     * @throws CheckerException if an error occurred
     */
    public double nextDouble() ;

    /**
     * Returns unread part of current line.
     *
     * @return unread part of current line.
     *
     * @throws CheckerException if an error occurred
     */
    public String nextLine() ;
}

