readers

package
v0.0.0-...-6541b2f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2014 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package readers contains implementations of useful decorators and adapters for readers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewReverseReader

func NewReverseReader(readSeeker io.ReadSeeker) io.Reader

NewReverseReader() returns an implementation of the io.Reader interface that reads the passed io.ReadSeeker backwards.

Types

type ByteScannerReader

type ByteScannerReader interface {
	io.ByteScanner
	io.Reader
}

ByteScannerReader is a combination of io.ByteScanner and io.Reader. The UnreadByte() method is useful in lexical analyzers and so is io.Reader. None of the interfaces supplied with Go appear to have both of these methods.

type HistoryReader

type HistoryReader struct {
	// contains filtered or unexported fields
}

HistoryReader is a decorator for a ByteScannerReader interface that saves the history of the previous "n" reads in a circular buffer. It is useful, for example, with lexical scanners so that when an error occurs, the HistoryReader can provide the last "n" bytes leading up to the error.

func NewHistoryReader

func NewHistoryReader(reader ByteScannerReader, capacity uint) *HistoryReader

NewHistoryReader() creates a new HistoryReader from a ByteScannerReader with a circular buffer of the requested capacity.

func (*HistoryReader) GetHistory

func (d *HistoryReader) GetHistory() []byte

GetHistory() returns the contents of the circular history buffer. It is the only method added to HistoryReader that distinguishes it from ByteScannerReader.

func (*HistoryReader) Read

func (d *HistoryReader) Read(b []byte) (n int, err error)

func (*HistoryReader) ReadByte

func (d *HistoryReader) ReadByte() (b byte, err error)

func (*HistoryReader) UnreadByte

func (d *HistoryReader) UnreadByte() (err error)

type ReverseReader

type ReverseReader struct {
	// contains filtered or unexported fields
}

ReverseReader implements an io.Reader interface on an underlying io.ReadSeeker to read it backwards.

func (*ReverseReader) Read

func (d *ReverseReader) Read(b []byte) (n int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL