hashcode-utils-kt / org.hildan.hashcode.utils.reader

Package org.hildan.hashcode.utils.reader

Types

HCReader

Provides convenience methods to parse the input data, with clear error handling and line numbering.

class HCReader : Closeable

Exceptions

FileParsingException

Thrown if an exception occurs while parsing a file, in order to provide the file's path in the message.

class FileParsingException : RuntimeException

IncompleteInputReadException

Thrown if the parsing ends while there is still input to read.

class IncompleteInputReadException : InputParsingException

IncompleteLineReadException

Thrown if the next line is accessed while the current line has not been fully consumed.

class IncompleteLineReadException : InputParsingException

InputParsingException

Thrown if the parsing of the input fails.

open class InputParsingException : RuntimeException

NoMoreLinesToReadException

Thrown if the input is accessed for more lines when there is no more to read.

class NoMoreLinesToReadException : InputParsingException

Properties

DEFAULT_HASHCODE_INPUT_DELIMITER

The most likely delimiter to use in HashCode input files.

val DEFAULT_HASHCODE_INPUT_DELIMITER: Regex

Functions

withHCReader

Executes the given readProblem function on a new HCReader, reading the given input text. The reader is closed whether an exception is thrown or not.

fun <P> withHCReader(input: String, tokenDelimiter: Regex = DEFAULT_HASHCODE_INPUT_DELIMITER, readProblem: HCReader.() -> P): P

Executes the given readProblem function on a new HCReader, reading the file at the given path. The reader is closed whether an exception is thrown or not.

fun <P> withHCReader(path: Path, tokenDelimiter: Regex = DEFAULT_HASHCODE_INPUT_DELIMITER, readProblem: HCReader.() -> P): P