reader

package
v0.26.4 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: GPL-3.0 Imports: 4 Imported by: 14

README

Reader

Auxiliary methods and functions for reading.

Documentation

Index

Constants

View Source
const (
	CR = '\r'
	LF = '\n'
)

ASCII symbols.

View Source
const ErrUnexpectedDataSize = "unexpected data size: %v vs %v"

Variables

This section is empty.

Functions

This section is empty.

Types

type IReader added in v0.9.1

type IReader interface {
	io.Reader
	GetInternalReader() io.Reader
	ReadLineEndingWithCRLF() (line []byte, err error)
	ReadBytes(size int) (bytes []byte, err error)
	ReadByte() (ub byte, err error)
	ReadSByte() (sb int8, err error)
	Read2Bytes() (bytes []byte, err error)
	Read4Bytes() (bytes []byte, err error)
	Read8Bytes() (bytes []byte, err error)
	ReadWord_BE() (w bt.Word, err error)
	ReadWord_LE() (w bt.Word, err error)
	ReadDWord_BE() (dw bt.DWord, err error)
	ReadDWord_LE() (dw bt.DWord, err error)
	ReadUShort_BE() (us uint16, err error)
	ReadUShort_LE() (us uint16, err error)
	ReadULong_BE() (ul uint32, err error)
	ReadULong_LE() (ul uint32, err error)
	ReadSShort_BE() (ss int16, err error)
	ReadSShort_LE() (ss int16, err error)
	ReadSLong_BE() (sl int32, err error)
	ReadSLong_LE() (sl int32, err error)
	ReadFloat_BE() (f float32, err error)
	ReadFloat_LE() (f float32, err error)
	ReadDouble_BE() (d float64, err error)
	ReadDouble_LE() (d float64, err error)
}

type Reader

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

func New added in v0.9.1

func New(stream io.Reader) *Reader

func (*Reader) GetInternalReader added in v0.8.0

func (r *Reader) GetInternalReader() io.Reader

func (*Reader) Read added in v0.8.0

func (r *Reader) Read(dst []byte) (n int, err error)

Read is the standard method of the 'io.Reader' interface.

func (*Reader) Read2Bytes added in v0.8.0

func (r *Reader) Read2Bytes() (bytes []byte, err error)

Read2Bytes reads two bytes.

func (*Reader) Read4Bytes added in v0.8.0

func (r *Reader) Read4Bytes() (bytes []byte, err error)

Read4Bytes reads four bytes.

func (*Reader) Read8Bytes added in v0.8.0

func (r *Reader) Read8Bytes() (bytes []byte, err error)

Read8Bytes reads eight bytes.

func (*Reader) ReadByte added in v0.8.0

func (r *Reader) ReadByte() (ub byte, err error)

ReadByte reads one (unsigned) byte.

func (*Reader) ReadBytes

func (r *Reader) ReadBytes(size int) (bytes []byte, err error)

ReadBytes reads an exact number of bytes. This method is different from the common 'Read' method of an 'io.Reader' interface in that it returns the actual number of bytes read. In other words, if the specified number of bytes is not available, only those bytes which were available are returned. If there is no data available, an empty array (slice) is returned. When there is no error – the full-size array (slice) of bytes should be returned, but it is not going to happen because modern Go language has bugs in several built-in libraries implementing the 'io.Reader' interface:

  1. bytes: return EOF early in Reader.Read #21852 https://github.com/golang/go/issues/21852 destel opened this issue on Sep 13, 2017

  2. bytes: bytes.Reader returns EOF on zero-byte Read, which doesn't conform with io.Reader interface documentation #40385 https://github.com/golang/go/issues/40385 metala opened this issue on Jul 24, 2020

  3. bytes: bytes.Reader violates the io.Reader and io.EOF main principle #59253 https://github.com/golang/go/issues/59253

  4. io: Documentation of the io package at website is contrary to its documentation in comments inside source code. #59254 https://github.com/golang/go/issues/59254

func (*Reader) ReadDWord_BE added in v0.8.0

func (r *Reader) ReadDWord_BE() (dw bt.DWord, err error)

ReadDWord_BE reads a double word using the big endian technique.

func (*Reader) ReadDWord_LE added in v0.8.0

func (r *Reader) ReadDWord_LE() (dw bt.DWord, err error)

ReadDWord_LE reads a double word using the little endian technique.

func (*Reader) ReadDouble_BE added in v0.8.0

func (r *Reader) ReadDouble_BE() (d float64, err error)

ReadDouble_BE reads a Double using the big endian technique.

func (*Reader) ReadDouble_LE added in v0.8.0

func (r *Reader) ReadDouble_LE() (d float64, err error)

ReadDouble_LE reads a Double using the little endian technique.

func (*Reader) ReadFloat_BE added in v0.8.0

func (r *Reader) ReadFloat_BE() (f float32, err error)

ReadFloat_BE reads a Float using the big endian technique.

func (*Reader) ReadFloat_LE added in v0.8.0

func (r *Reader) ReadFloat_LE() (f float32, err error)

ReadFloat_LE reads a Float using the little endian technique.

func (*Reader) ReadLineEndingWithCRLF

func (r *Reader) ReadLineEndingWithCRLF() (line []byte, err error)

ReadLineEndingWithCRLF reads a line ending exactly with the 'CR'+'LF' symbols sequence. The two symbols at the end of the line (CR+LF) are included into the returned result. On error, returns the last read sequence of bytes, even if it does not have a correct ending.

func (*Reader) ReadSByte added in v0.8.0

func (r *Reader) ReadSByte() (sb int8, err error)

ReadSByte reads one signed byte.

func (*Reader) ReadSLong_BE added in v0.8.0

func (r *Reader) ReadSLong_BE() (sl int32, err error)

ReadSLong_BE reads a signed long using the big endian technique.

func (*Reader) ReadSLong_LE added in v0.8.0

func (r *Reader) ReadSLong_LE() (sl int32, err error)

ReadSLong_LE reads a signed long using the little endian technique.

func (*Reader) ReadSShort_BE added in v0.8.0

func (r *Reader) ReadSShort_BE() (ss int16, err error)

ReadSShort_BE reads a signed short using the big endian technique.

func (*Reader) ReadSShort_LE added in v0.8.0

func (r *Reader) ReadSShort_LE() (ss int16, err error)

ReadSShort_LE reads a signed short using the little endian technique.

func (*Reader) ReadULong_BE added in v0.8.0

func (r *Reader) ReadULong_BE() (ul uint32, err error)

ReadULong_BE reads an unsigned long using the big endian technique.

func (*Reader) ReadULong_LE added in v0.8.0

func (r *Reader) ReadULong_LE() (ul uint32, err error)

ReadULong_LE reads an unsigned long using the little endian technique.

func (*Reader) ReadUShort_BE added in v0.8.0

func (r *Reader) ReadUShort_BE() (us uint16, err error)

ReadUShort_BE reads an unsigned short using the big endian technique.

func (*Reader) ReadUShort_LE added in v0.8.0

func (r *Reader) ReadUShort_LE() (us uint16, err error)

ReadUShort_LE reads an unsigned short using the little endian technique.

func (*Reader) ReadWord_BE added in v0.8.0

func (r *Reader) ReadWord_BE() (w bt.Word, err error)

ReadWord_BE reads a word using the big endian technique.

func (*Reader) ReadWord_LE added in v0.8.0

func (r *Reader) ReadWord_LE() (w bt.Word, err error)

ReadWord_LE reads a word using the little endian technique.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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