binary

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2018 License: MIT Imports: 3 Imported by: 23

README

Binary

This is binary library for Medaka written in Go.

License

These codes are under the MIT License.

Documentation

Index

Constants

View Source
const (
	// ByteSize is byte size of Byte
	ByteSize = 1

	// ShortSize is byte size of Short
	ShortSize = 2

	// IntSize is byte size of Int
	IntSize = 4

	// LongSize is byte size of Long
	LongSize = 8

	// FloatSize is byte size of Float
	FloatSize = 4

	// DoubleSize is byte size of Double
	DoubleSize = 8
)

Variables

View Source
var BigEndian bigEndian

BigEndian .

View Source
var ErrNotEnought = errors.New("binary: not enough")
View Source
var LittleEndian littleEndian

LittleEndian .

Functions

func Read

func Read(reader io.Reader, order Order, data interface{}) error

Read reads data into b by order

func ReadByte

func ReadByte(v []byte) byte

func ReadDouble

func ReadDouble(v []byte) float64

func ReadFloat

func ReadFloat(v []byte) float32

func ReadInt

func ReadInt(v []byte) int32

func ReadLDouble

func ReadLDouble(v []byte) float64

func ReadLFloat

func ReadLFloat(v []byte) float32

func ReadLInt

func ReadLInt(v []byte) int32

func ReadLLong

func ReadLLong(v []byte) int64

func ReadLShort

func ReadLShort(v []byte) int16

func ReadLUInt

func ReadLUInt(v []byte) uint32

func ReadLULong

func ReadLULong(v []byte) uint64

func ReadLUShort

func ReadLUShort(v []byte) uint16

func ReadLong

func ReadLong(v []byte) int64

func ReadSByte

func ReadSByte(v []byte) int8

func ReadShort

func ReadShort(v []byte) int16

func ReadUInt

func ReadUInt(v []byte) uint32

func ReadULong

func ReadULong(v []byte) uint64

func ReadUShort

func ReadUShort(v []byte) uint16

func Write

func Write(writer io.Writer, order Order, data interface{}) error

Write writes the contents of data into buffer by order

func WriteByte

func WriteByte(v byte) []byte

func WriteDouble

func WriteDouble(v float64) []byte

func WriteFloat

func WriteFloat(v float32) []byte

func WriteInt

func WriteInt(v int32) []byte

func WriteLDouble

func WriteLDouble(v float64) []byte

func WriteLFloat

func WriteLFloat(v float32) []byte

func WriteLInt

func WriteLInt(v int32) []byte

func WriteLLong

func WriteLLong(v int64) []byte

func WriteLShort

func WriteLShort(v int16) []byte

func WriteLUInt

func WriteLUInt(v uint32) []byte

func WriteLULong

func WriteLULong(v uint64) []byte

func WriteLUShort

func WriteLUShort(v uint16) []byte

func WriteLong

func WriteLong(v int64) []byte

func WriteSByte

func WriteSByte(v int8) []byte

func WriteShort

func WriteShort(v int16) []byte

func WriteUInt

func WriteUInt(v uint32) []byte

func WriteULong

func WriteULong(v uint64) []byte

func WriteUShort

func WriteUShort(v uint16) []byte

Types

type Order

type Order interface {
	Byte(v []byte) byte
	SByte(v []byte) int8
	Short(v []byte) int16
	UShort(v []byte) uint16
	Int(v []byte) int32
	UInt(v []byte) uint32
	Long(v []byte) int64
	ULong(v []byte) uint64
	Float(v []byte) float32
	Double(v []byte) float64
	PutByte(v byte) []byte
	PutSByte(v int8) []byte
	PutShort(v int16) []byte
	PutUShort(v uint16) []byte
	PutInt(v int32) []byte
	PutUInt(v uint32) []byte
	PutLong(v int64) []byte
	PutULong(v uint64) []byte
	PutFloat(v float32) []byte
	PutDouble(v float64) []byte
}

Order for Raknet Protocol

type Stream

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

Stream is basic binary stream.

func NewStream

func NewStream() *Stream

NewStream returns new Stream

func NewStreamBytes

func NewStreamBytes(b []byte) *Stream

NewStreamBytes returns new Stream from bytes

func (*Stream) AllBytes

func (bs *Stream) AllBytes() []byte

AllBytes return all bytes

func (*Stream) Bool

func (bs *Stream) Bool(value *bool) error

Bool sets byte got from buffer as bool to value

func (*Stream) Byte

func (bs *Stream) Byte(value *byte) error

Byte sets byte(unsign) got from buffer to value

func (*Stream) Bytes

func (bs *Stream) Bytes() []byte

Bytes returns the bytes left from Buffer.

func (*Stream) Get

func (bs *Stream) Get(n int) []byte

Get returns n bytes from Buffer with []byte

func (*Stream) Int

func (bs *Stream) Int(value *int32) error

Int sets int got from buffer to value

func (*Stream) LSShort

func (bs *Stream) LSShort(value *int16) error

LSShort sets short(sign) got from buffer as LittleEndian to value

func (*Stream) LShort

func (bs *Stream) LShort(value *uint16) error

LShort sets short(unsign) got from buffer as LittleEndian to value

func (*Stream) Len

func (bs *Stream) Len() int

Len returns len the bytes left

func (*Stream) Long

func (bs *Stream) Long(value *int64) error

Long sets long got from buffer to value

func (*Stream) Off

func (bs *Stream) Off() int

Off returns offset

func (*Stream) Pad

func (bs *Stream) Pad(le int) error

Pad puts empty bytes (0x00) of le (len).

func (*Stream) Put

func (bs *Stream) Put(value []byte) error

Put puts value to buffer

func (*Stream) PutBool

func (bs *Stream) PutBool(value bool) error

PutBool puts bool as byte from value to buffer

func (*Stream) PutByte

func (bs *Stream) PutByte(value byte) error

PutByte puts byte(unsign) from value to buffer

func (*Stream) PutInt

func (bs *Stream) PutInt(value int32) error

PutInt puts int from value to buffer

func (*Stream) PutLSShort

func (bs *Stream) PutLSShort(value int16) error

PutLSShort puts short(sign) from value to buffer as LittleEndian

func (*Stream) PutLShort

func (bs *Stream) PutLShort(value uint16) error

PutLShort puts short(unsign) from value to buffer as LittleEndian

func (*Stream) PutLong

func (bs *Stream) PutLong(value int64) error

PutLong puts long from value to buffer

func (*Stream) PutSByte

func (bs *Stream) PutSByte(value int8) error

PutSByte puts byte(sign) from value to buffer

func (*Stream) PutSShort

func (bs *Stream) PutSShort(value int16) error

PutSShort puts short(sign) from value to buffer

func (*Stream) PutShort

func (bs *Stream) PutShort(value uint16) error

PutShort puts short(unsign) from value to buffer

func (*Stream) Read

func (bs *Stream) Read(p []byte) (n int, err error)

Read reads and sets p

func (*Stream) Reset

func (bs *Stream) Reset()

Reset resets Buffer

func (*Stream) SByte

func (bs *Stream) SByte(value *int8) error

SByte sets byte(sign) got from buffer to value

func (*Stream) SShort

func (bs *Stream) SShort(value *int16) error

SShort sets short(sign) got from buffer to value

func (*Stream) SetBytes

func (bs *Stream) SetBytes(b []byte)

SetBytes sets bytes

func (*Stream) Short

func (bs *Stream) Short(value *uint16) error

Short sets short(unsign) got from buffer to value

func (*Stream) Skip

func (bs *Stream) Skip(n int)

Skip skips n bytes on buffer

func (*Stream) Write

func (bs *Stream) Write(p []byte) (n int, err error)

Write writes p

type Triad

type Triad uint32

Triad is using special value in Raknet

Jump to

Keyboard shortcuts

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