byteframe

package module
v0.0.0-...-8979c5c Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: MIT Imports: 5 Imported by: 6

README

Byteframe

GoDoc pipeline status coverage report

Byteframe is a small helper library for reading and writing binary data in Go.

byteframe assumes all of you binary data can easily fit into memory at once. This library should not be used for anything that would benefit from data streaming (file format parsing, audio/video encoding, etc).

This library is HEAVILY based on the code from sgemu

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteFrame

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

ByteFrame is a struct for reading and writing raw byte data.

func NewByteFrame

func NewByteFrame() *ByteFrame

NewByteFrame creates a new ByteFrame with valid default values. byteOrder defaults to big endian.

func NewByteFrameFromBytes

func NewByteFrameFromBytes(buf []byte) *ByteFrame

NewByteFrameFromBytes creates a new ByteFrame with valid default values. makes a copy of the given buf and initalizes with it. byteOrder defaults to big endian.

func (*ByteFrame) Data

func (b *ByteFrame) Data() []byte

Data returns the data from the buffer start up to the max index.

func (*ByteFrame) DataFromCurrent

func (b *ByteFrame) DataFromCurrent() []byte

DataFromCurrent returns the data from the current index up to the max index.

func (*ByteFrame) ReadBool

func (b *ByteFrame) ReadBool() (x bool)

ReadBool reads a bool at the current index (1 byte. b > 0 -> true, b == 0 -> false)

func (*ByteFrame) ReadBytes

func (b *ByteFrame) ReadBytes(size uint) (x []byte)

ReadBytes reads `size` many bytes at the current index.

func (*ByteFrame) ReadFloat32

func (b *ByteFrame) ReadFloat32() (x float32)

ReadFloat32 reads a float32 at the current index.

func (*ByteFrame) ReadFloat64

func (b *ByteFrame) ReadFloat64() (x float64)

ReadFloat64 reads a float64 at the current index.

func (*ByteFrame) ReadInt16

func (b *ByteFrame) ReadInt16() (x int16)

ReadInt16 reads a int16 at the current index.

func (*ByteFrame) ReadInt32

func (b *ByteFrame) ReadInt32() (x int32)

ReadInt32 reads a int32 at the current index.

func (*ByteFrame) ReadInt64

func (b *ByteFrame) ReadInt64() (x int64)

ReadInt64 reads a int64 at the current index.

func (*ByteFrame) ReadInt8

func (b *ByteFrame) ReadInt8() (x int8)

ReadInt8 reads a int8 at the current index.

func (*ByteFrame) ReadNullTerminatedBytes

func (b *ByteFrame) ReadNullTerminatedBytes() []byte

ReadNullTerminatedBytes reads bytes up to a NULL terminator.

func (*ByteFrame) ReadUint16

func (b *ByteFrame) ReadUint16() (x uint16)

ReadUint16 reads a uint16 at the current index.

func (*ByteFrame) ReadUint32

func (b *ByteFrame) ReadUint32() (x uint32)

ReadUint32 reads a uint32 at the current index.

func (*ByteFrame) ReadUint64

func (b *ByteFrame) ReadUint64() (x uint64)

ReadUint64 reads a uint64 at the current index.

func (*ByteFrame) ReadUint8

func (b *ByteFrame) ReadUint8() (x uint8)

ReadUint8 reads a uint8 at the current index.

func (*ByteFrame) Seek

func (b *ByteFrame) Seek(offset int64, whence int) (int64, error)

Seek (implements the io.Seeker interface)

func (*ByteFrame) SetBE

func (b *ByteFrame) SetBE()

SetBE sets the byte order to big endian.

func (*ByteFrame) SetLE

func (b *ByteFrame) SetLE()

SetLE sets the byte order to litte endian.

func (*ByteFrame) WriteBool

func (b *ByteFrame) WriteBool(x bool)

WriteBool writes a bool at the current index (1 byte. true -> 1, false -> 0)

func (*ByteFrame) WriteBytes

func (b *ByteFrame) WriteBytes(x []byte)

WriteBytes writes a slice of bytes at the current index.

func (*ByteFrame) WriteFloat32

func (b *ByteFrame) WriteFloat32(x float32)

WriteFloat32 writes a float32 at the current index.

func (*ByteFrame) WriteFloat64

func (b *ByteFrame) WriteFloat64(x float64)

WriteFloat64 writes a float64 at the current index

func (*ByteFrame) WriteInt16

func (b *ByteFrame) WriteInt16(x int16)

WriteInt16 writes a int16 at the current index.

func (*ByteFrame) WriteInt32

func (b *ByteFrame) WriteInt32(x int32)

WriteInt32 writes a int32 at the current index.

func (*ByteFrame) WriteInt64

func (b *ByteFrame) WriteInt64(x int64)

WriteInt64 writes a int64 at the current index.

func (*ByteFrame) WriteInt8

func (b *ByteFrame) WriteInt8(x int8)

WriteInt8 writes a int8 at the current index.

func (*ByteFrame) WriteNullTerminatedBytes

func (b *ByteFrame) WriteNullTerminatedBytes(x []byte)

WriteNullTerminatedBytes write a slice bytes with an additional NULL terminator.

func (*ByteFrame) WriteUint16

func (b *ByteFrame) WriteUint16(x uint16)

WriteUint16 writes a uint16 at the current index.

func (*ByteFrame) WriteUint32

func (b *ByteFrame) WriteUint32(x uint32)

WriteUint32 writes a uint32 at the current index.

func (*ByteFrame) WriteUint64

func (b *ByteFrame) WriteUint64(x uint64)

WriteUint64 writes a uint64 at the current index.

func (*ByteFrame) WriteUint8

func (b *ByteFrame) WriteUint8(x uint8)

WriteUint8 writes a uint8 at the current index.

Jump to

Keyboard shortcuts

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