binutils

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2019 License: Apache-2.0 Imports: 1 Imported by: 20

README

GoBinaryUtils

A Go package for easy binary reading and writing

Documentation

Overview

Package binutils implements easy and simple reading and writing of byte arrays. It writes and reads directly to and from byte arrays, rather than readers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Read

func Read(buffer *[]byte, offset *int, length int) []byte

Read reads from buffer at the given offset with the given length.

func ReadBigTriad

func ReadBigTriad(buffer *[]byte, offset *int) uint32

func ReadBool

func ReadBool(buffer *[]byte, offset *int) bool

func ReadByte

func ReadByte(buffer *[]byte, offset *int) byte

func ReadDouble

func ReadDouble(buffer *[]byte, offset *int) float64

func ReadFloat

func ReadFloat(buffer *[]byte, offset *int) float32

func ReadInt

func ReadInt(buffer *[]byte, offset *int) int32

func ReadLittleDouble

func ReadLittleDouble(buffer *[]byte, offset *int) float64

func ReadLittleFloat

func ReadLittleFloat(buffer *[]byte, offset *int) float32

func ReadLittleInt

func ReadLittleInt(buffer *[]byte, offset *int) int32

func ReadLittleLong

func ReadLittleLong(buffer *[]byte, offset *int) int64

func ReadLittleShort

func ReadLittleShort(buffer *[]byte, offset *int) int16

func ReadLittleTriad

func ReadLittleTriad(buffer *[]byte, offset *int) uint32

func ReadLittleUnsignedInt

func ReadLittleUnsignedInt(buffer *[]byte, offset *int) uint32

func ReadLittleUnsignedLong

func ReadLittleUnsignedLong(buffer *[]byte, offset *int) uint64

func ReadLittleUnsignedShort

func ReadLittleUnsignedShort(buffer *[]byte, offset *int) uint16

func ReadLong

func ReadLong(buffer *[]byte, offset *int) int64

func ReadShort

func ReadShort(buffer *[]byte, offset *int) int16

func ReadString

func ReadString(buffer *[]byte, offset *int) string

func ReadUnsignedByte

func ReadUnsignedByte(buffer *[]byte, offset *int) byte

func ReadUnsignedInt

func ReadUnsignedInt(buffer *[]byte, offset *int) uint32

func ReadUnsignedLong

func ReadUnsignedLong(buffer *[]byte, offset *int) uint64

func ReadUnsignedShort

func ReadUnsignedShort(buffer *[]byte, offset *int) uint16

func ReadUnsignedVarInt

func ReadUnsignedVarInt(buffer *[]byte, offset *int) uint32

func ReadUnsignedVarLong

func ReadUnsignedVarLong(buffer *[]byte, offset *int) uint64

func ReadVarInt

func ReadVarInt(buffer *[]byte, offset *int) int32

func ReadVarLong

func ReadVarLong(buffer *[]byte, offset *int) int64

func Write

func Write(buffer *[]byte, v byte)

Write writes a byte to the buffer.

func WriteBigTriad

func WriteBigTriad(buffer *[]byte, uint uint32)

func WriteBool

func WriteBool(buffer *[]byte, bool bool)

func WriteByte

func WriteByte(buffer *[]byte, byte byte)

func WriteDouble

func WriteDouble(buffer *[]byte, double float64)

func WriteFloat

func WriteFloat(buffer *[]byte, float float32)

func WriteInt

func WriteInt(buffer *[]byte, int int32)

func WriteLittleDouble

func WriteLittleDouble(buffer *[]byte, double float64)

func WriteLittleFloat

func WriteLittleFloat(buffer *[]byte, float float32)

func WriteLittleInt

func WriteLittleInt(buffer *[]byte, int int32)

func WriteLittleLong

func WriteLittleLong(buffer *[]byte, long int64)

func WriteLittleShort

func WriteLittleShort(buffer *[]byte, signed int16)

func WriteLittleTriad

func WriteLittleTriad(buffer *[]byte, uint uint32)

func WriteLittleUnsignedInt

func WriteLittleUnsignedInt(buffer *[]byte, v uint32)

func WriteLittleUnsignedLong

func WriteLittleUnsignedLong(buffer *[]byte, v uint64)

func WriteLittleUnsignedShort

func WriteLittleUnsignedShort(buffer *[]byte, v uint16)

func WriteLong

func WriteLong(buffer *[]byte, long int64)

func WriteShort

func WriteShort(buffer *[]byte, signed int16)

func WriteString

func WriteString(buffer *[]byte, str string)

func WriteUnsignedByte

func WriteUnsignedByte(buffer *[]byte, unsigned uint8)

func WriteUnsignedInt

func WriteUnsignedInt(buffer *[]byte, v uint32)

func WriteUnsignedLong

func WriteUnsignedLong(buffer *[]byte, v uint64)

func WriteUnsignedShort

func WriteUnsignedShort(buffer *[]byte, v uint16)

func WriteUnsignedVarInt

func WriteUnsignedVarInt(buffer *[]byte, value uint32)

func WriteUnsignedVarLong

func WriteUnsignedVarLong(buffer *[]byte, value uint64)

func WriteVarInt

func WriteVarInt(buffer *[]byte, value int32)

func WriteVarLong

func WriteVarLong(buffer *[]byte, value int64)

Types

type EndianType

type EndianType byte
const (
	BigEndian EndianType = iota
	LittleEndian
)

type Stream

type Stream struct {
	Offset int
	Buffer []byte
}

Stream is a container of a byte array and an offset. Reading from the stream increments the offset.

func NewStream

func NewStream() *Stream

NewStream returns a new stream.

func (*Stream) Feof

func (stream *Stream) Feof() bool

Feof checks if the stream offset reached the end of its buffer.

func (*Stream) Get

func (stream *Stream) Get(length int) []byte

Get reads the given amount of bytes from the buffer. If length is negative, reads the leftover bytes.

func (*Stream) GetBool

func (stream *Stream) GetBool() bool

func (*Stream) GetBuffer

func (stream *Stream) GetBuffer() []byte

GetBuffer returns the buffer of the stream.

func (*Stream) GetByte

func (stream *Stream) GetByte() byte

func (*Stream) GetDouble

func (stream *Stream) GetDouble() float64

func (*Stream) GetFloat

func (stream *Stream) GetFloat() float32

func (*Stream) GetInt

func (stream *Stream) GetInt() int32

func (*Stream) GetLengthPrefixedBytes

func (stream *Stream) GetLengthPrefixedBytes() []byte

func (*Stream) GetLittleDouble

func (stream *Stream) GetLittleDouble() float64

func (*Stream) GetLittleFloat

func (stream *Stream) GetLittleFloat() float32

func (*Stream) GetLittleInt

func (stream *Stream) GetLittleInt() int32

func (*Stream) GetLittleLong

func (stream *Stream) GetLittleLong() int64

func (*Stream) GetLittleShort

func (stream *Stream) GetLittleShort() int16

func (*Stream) GetLittleTriad

func (stream *Stream) GetLittleTriad() uint32

func (*Stream) GetLittleUnsignedInt

func (stream *Stream) GetLittleUnsignedInt() uint32

func (*Stream) GetLittleUnsignedLong

func (stream *Stream) GetLittleUnsignedLong() uint64

func (*Stream) GetLittleUnsignedShort

func (stream *Stream) GetLittleUnsignedShort() uint16

func (*Stream) GetLong

func (stream *Stream) GetLong() int64

func (*Stream) GetOffset

func (stream *Stream) GetOffset() int

GetOffset returns the current stream offset.

func (*Stream) GetShort

func (stream *Stream) GetShort() int16

func (*Stream) GetString

func (stream *Stream) GetString() string

func (*Stream) GetTriad

func (stream *Stream) GetTriad() uint32

func (*Stream) GetUnsignedByte

func (stream *Stream) GetUnsignedByte() byte

func (*Stream) GetUnsignedInt

func (stream *Stream) GetUnsignedInt() uint32

func (*Stream) GetUnsignedLong

func (stream *Stream) GetUnsignedLong() uint64

func (*Stream) GetUnsignedShort

func (stream *Stream) GetUnsignedShort() uint16

func (*Stream) GetUnsignedVarInt

func (stream *Stream) GetUnsignedVarInt() uint32

func (*Stream) GetUnsignedVarLong

func (stream *Stream) GetUnsignedVarLong() uint64

func (*Stream) GetVarInt

func (stream *Stream) GetVarInt() int32

func (*Stream) GetVarLong

func (stream *Stream) GetVarLong() int64

func (*Stream) PutBool

func (stream *Stream) PutBool(v bool)

func (*Stream) PutByte

func (stream *Stream) PutByte(v byte)

func (*Stream) PutBytes

func (stream *Stream) PutBytes(bytes []byte)

func (*Stream) PutDouble

func (stream *Stream) PutDouble(v float64)

func (*Stream) PutFloat

func (stream *Stream) PutFloat(v float32)

func (*Stream) PutInt

func (stream *Stream) PutInt(v int32)

func (*Stream) PutLengthPrefixedBytes

func (stream *Stream) PutLengthPrefixedBytes(bytes []byte)

func (*Stream) PutLittleDouble

func (stream *Stream) PutLittleDouble(v float64)

func (*Stream) PutLittleFloat

func (stream *Stream) PutLittleFloat(v float32)

func (*Stream) PutLittleInt

func (stream *Stream) PutLittleInt(v int32)

func (*Stream) PutLittleLong

func (stream *Stream) PutLittleLong(v int64)

func (*Stream) PutLittleShort

func (stream *Stream) PutLittleShort(v int16)

func (*Stream) PutLittleTriad

func (stream *Stream) PutLittleTriad(v uint32)

func (*Stream) PutLittleUnsignedInt

func (stream *Stream) PutLittleUnsignedInt(v uint32)

func (*Stream) PutLittleUnsignedLong

func (stream *Stream) PutLittleUnsignedLong(v uint64)

func (*Stream) PutLittleUnsignedShort

func (stream *Stream) PutLittleUnsignedShort(v uint16)

func (*Stream) PutLong

func (stream *Stream) PutLong(v int64)

func (*Stream) PutShort

func (stream *Stream) PutShort(v int16)

func (*Stream) PutString

func (stream *Stream) PutString(v string)

func (*Stream) PutTriad

func (stream *Stream) PutTriad(v uint32)

func (*Stream) PutUnsignedByte

func (stream *Stream) PutUnsignedByte(v byte)

func (*Stream) PutUnsignedInt

func (stream *Stream) PutUnsignedInt(v uint32)

func (*Stream) PutUnsignedLong

func (stream *Stream) PutUnsignedLong(v uint64)

func (*Stream) PutUnsignedShort

func (stream *Stream) PutUnsignedShort(v uint16)

func (*Stream) PutUnsignedVarInt

func (stream *Stream) PutUnsignedVarInt(v uint32)

func (*Stream) PutUnsignedVarLong

func (stream *Stream) PutUnsignedVarLong(v uint64)

func (*Stream) PutVarInt

func (stream *Stream) PutVarInt(v int32)

func (*Stream) PutVarLong

func (stream *Stream) PutVarLong(v int64)

func (*Stream) ResetStream

func (stream *Stream) ResetStream()

func (*Stream) SetBuffer

func (stream *Stream) SetBuffer(buffer []byte)

SetBuffer sets the buffer of the stream.

func (*Stream) SetOffset

func (stream *Stream) SetOffset(offset int)

SetOffset sets the offset of the stream.

Jump to

Keyboard shortcuts

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