module Chem::FormatReader::Indexable(T)

Overview

Declares a common interface for indexed reading of a finite number of objects encoded in a file format.

Including types must implement methods to track and set the current object in the IO.

Included Modules

Direct including types

Defined in:

chem/format_reader.cr

Instance Method Summary

Instance methods inherited from module Chem::FormatReader::MultiEntry(T)

each(indexes : Enumerable(Int), & : T -> )
each(& : T -> ) : Nil
each
, next_entry : T | Nil next_entry, read_entry : T read_entry, skip_entry : Nil skip_entry

Instance Method Detail

def entry_index : Int32 #

Returns the index of the current entry.


[View source]
abstract def n_entries : Int32 #

Returns the number of entries in the IO.


[View source]
def next_entry : T | Nil #

Returns the next entry in the IO, or nil if there are no more entries.


[View source]
def read_entry(index : Int) : T #

Returns the entry at the given index. Raises IndexError if the index is invalid.


[View source]
def skip_entry : Nil #
Description copied from module Chem::FormatReader::MultiEntry(T)

Discards the next entry in the IO without fully parsing it.


[View source]
abstract def skip_to_entry(index : Int) : Nil #

Discards the entries (without parsing) up until the given index. Raises IndexError if the index is invalid.


[View source]