Documentation ¶
Overview ¶
Package d2datautils is a utility package that provides helper functions/classes for parsing the original diablo2 files. (eg. parsers for binary files that aren't byte-aligned)
Index ¶
- type BitMuncher
- func (v *BitMuncher) BitsRead() int
- func (v BitMuncher) Copy() *BitMuncher
- func (v *BitMuncher) GetBit() uint32
- func (v *BitMuncher) GetBits(bits int) uint32
- func (v *BitMuncher) GetByte() byte
- func (v *BitMuncher) GetInt32() int32
- func (v *BitMuncher) GetSignedBits(bits int) int
- func (v *BitMuncher) GetUInt32() uint32
- func (v *BitMuncher) Init(data []byte, offset int) *BitMuncher
- func (v *BitMuncher) MakeSigned(value uint32, bits int) int32
- func (v *BitMuncher) Offset() int
- func (v *BitMuncher) SetBitsRead(n int)
- func (v *BitMuncher) SetOffset(n int)
- func (v *BitMuncher) SkipBits(bits int)
- type BitStream
- type StreamReader
- func (v *StreamReader) EOF() bool
- func (v *StreamReader) Position() uint64
- func (v *StreamReader) Read(p []byte) (n int, err error)
- func (v *StreamReader) ReadByte() (byte, error)
- func (v *StreamReader) ReadBytes(count int) ([]byte, error)
- func (v *StreamReader) ReadInt16() (int16, error)
- func (v *StreamReader) ReadInt32() (int32, error)
- func (v *StreamReader) ReadInt64() (int64, error)
- func (v *StreamReader) ReadUInt16() (uint16, error)
- func (v *StreamReader) ReadUInt32() (uint32, error)
- func (v *StreamReader) ReadUInt64() (uint64, error)
- func (v *StreamReader) SetPosition(newPosition uint64)
- func (v *StreamReader) Size() uint64
- func (v *StreamReader) SkipBytes(count int)
- type StreamWriter
- func (v *StreamWriter) GetBytes() []byte
- func (v *StreamWriter) PushBit(b bool)
- func (v *StreamWriter) PushBits(b byte, bits int)
- func (v *StreamWriter) PushBits16(b uint16, bits int)
- func (v *StreamWriter) PushBits32(b uint32, bits int)
- func (v *StreamWriter) PushBytes(b ...byte)
- func (v *StreamWriter) PushInt16(val int16)
- func (v *StreamWriter) PushInt32(val int32)
- func (v *StreamWriter) PushInt64(val int64)
- func (v *StreamWriter) PushUint16(val uint16)
- func (v *StreamWriter) PushUint32(val uint32)
- func (v *StreamWriter) PushUint64(val uint64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BitMuncher ¶
type BitMuncher struct {
// contains filtered or unexported fields
}
BitMuncher is used for parsing files that are not byte-aligned such as the DCC files.
func CopyBitMuncher ¶
func CopyBitMuncher(source *BitMuncher) *BitMuncher
CopyBitMuncher Creates a copy of the source BitMuncher
func CreateBitMuncher ¶
func CreateBitMuncher(data []byte, offset int) *BitMuncher
CreateBitMuncher Creates a BitMuncher
func (*BitMuncher) BitsRead ¶
func (v *BitMuncher) BitsRead() int
BitsRead returns the number of bits the BitMuncher has read
func (*BitMuncher) GetBit ¶
func (v *BitMuncher) GetBit() uint32
GetBit reads a bit and returns it as uint32
func (*BitMuncher) GetBits ¶
func (v *BitMuncher) GetBits(bits int) uint32
GetBits given a number of bits to read, reads that number of bits and retruns as a uint32
func (*BitMuncher) GetInt32 ¶
func (v *BitMuncher) GetInt32() int32
GetInt32 reads an int32 from data
func (*BitMuncher) GetSignedBits ¶
func (v *BitMuncher) GetSignedBits(bits int) int
GetSignedBits Given a number of bits, reads that many bits and returns as int
func (*BitMuncher) GetUInt32 ¶
func (v *BitMuncher) GetUInt32() uint32
GetUInt32 reads an unsigned uint32 from data
func (*BitMuncher) Init ¶
func (v *BitMuncher) Init(data []byte, offset int) *BitMuncher
Init initializes the BitMuncher with data and an offset
func (*BitMuncher) MakeSigned ¶
func (v *BitMuncher) MakeSigned(value uint32, bits int) int32
MakeSigned converts a uint32 value into an int32
func (*BitMuncher) Offset ¶
func (v *BitMuncher) Offset() int
Offset returns the offset of the BitMuncher
func (*BitMuncher) SetBitsRead ¶
func (v *BitMuncher) SetBitsRead(n int)
SetBitsRead sets the number of bits the BitMuncher has read
func (*BitMuncher) SetOffset ¶
func (v *BitMuncher) SetOffset(n int)
SetOffset sets the offset of the BitMuncher
func (*BitMuncher) SkipBits ¶
func (v *BitMuncher) SkipBits(bits int)
SkipBits skips bits, incrementing the offset and bits read
type BitStream ¶
type BitStream struct {
// contains filtered or unexported fields
}
BitStream is a utility class for reading groups of bits from a stream
func CreateBitStream ¶
CreateBitStream creates a new BitStream
func (*BitStream) EnsureBits ¶
EnsureBits ensures that the specified number of bits are available
type StreamReader ¶
type StreamReader struct {
// contains filtered or unexported fields
}
StreamReader allows you to read data from a byte array in various formats
func CreateStreamReader ¶
func CreateStreamReader(source []byte) *StreamReader
CreateStreamReader creates an instance of the stream reader
func (*StreamReader) EOF ¶
func (v *StreamReader) EOF() bool
EOF returns if the stream position is reached to the end of the data, or not
func (*StreamReader) Position ¶
func (v *StreamReader) Position() uint64
Position returns the current stream position
func (*StreamReader) Read ¶
func (v *StreamReader) Read(p []byte) (n int, err error)
Read implements io.Reader
func (*StreamReader) ReadByte ¶
func (v *StreamReader) ReadByte() (byte, error)
ReadByte reads a byte from the stream
func (*StreamReader) ReadBytes ¶
func (v *StreamReader) ReadBytes(count int) ([]byte, error)
ReadBytes reads multiple bytes
func (*StreamReader) ReadInt16 ¶
func (v *StreamReader) ReadInt16() (int16, error)
ReadInt16 returns a int16 word from the stream
func (*StreamReader) ReadInt32 ¶
func (v *StreamReader) ReadInt32() (int32, error)
ReadInt32 returns an int32 dword from the stream
func (*StreamReader) ReadInt64 ¶
func (v *StreamReader) ReadInt64() (int64, error)
ReadInt64 returns a uint64 qword from the stream
func (*StreamReader) ReadUInt16 ¶
func (v *StreamReader) ReadUInt16() (uint16, error)
ReadUInt16 returns a uint16 word from the stream
func (*StreamReader) ReadUInt32 ¶
func (v *StreamReader) ReadUInt32() (uint32, error)
ReadUInt32 returns a uint32 dword from the stream nolint
func (*StreamReader) ReadUInt64 ¶
func (v *StreamReader) ReadUInt64() (uint64, error)
ReadUInt64 returns a uint64 qword from the stream nolint
func (*StreamReader) SetPosition ¶
func (v *StreamReader) SetPosition(newPosition uint64)
SetPosition sets the stream position with the given position
func (*StreamReader) Size ¶
func (v *StreamReader) Size() uint64
Size returns the total size of the stream in bytes
func (*StreamReader) SkipBytes ¶
func (v *StreamReader) SkipBytes(count int)
SkipBytes moves the stream position forward by the given amount
type StreamWriter ¶
type StreamWriter struct {
// contains filtered or unexported fields
}
StreamWriter allows you to create a byte array by streaming in writes of various sizes
func CreateStreamWriter ¶
func CreateStreamWriter() *StreamWriter
CreateStreamWriter creates a new StreamWriter instance
func (*StreamWriter) GetBytes ¶
func (v *StreamWriter) GetBytes() []byte
GetBytes returns the the byte slice of the underlying data
func (*StreamWriter) PushBit ¶
func (v *StreamWriter) PushBit(b bool)
PushBit pushes single bit into stream WARNING: if you'll use PushBit, offset'll be less than 8, and if you'll use another Push... method, bits'll not be pushed
func (*StreamWriter) PushBits ¶
func (v *StreamWriter) PushBits(b byte, bits int)
PushBits pushes bits (with max range 8)
func (*StreamWriter) PushBits16 ¶
func (v *StreamWriter) PushBits16(b uint16, bits int)
PushBits16 pushes bits (with max range 16)
func (*StreamWriter) PushBits32 ¶
func (v *StreamWriter) PushBits32(b uint32, bits int)
PushBits32 pushes bits (with max range 32)
func (*StreamWriter) PushBytes ¶
func (v *StreamWriter) PushBytes(b ...byte)
PushBytes writes a bytes to the stream
func (*StreamWriter) PushInt16 ¶
func (v *StreamWriter) PushInt16(val int16)
PushInt16 writes a int16 word to the stream
func (*StreamWriter) PushInt32 ¶
func (v *StreamWriter) PushInt32(val int32)
PushInt32 writes a int32 dword to the stream
func (*StreamWriter) PushInt64 ¶
func (v *StreamWriter) PushInt64(val int64)
PushInt64 writes a uint64 qword to the stream
func (*StreamWriter) PushUint16 ¶
func (v *StreamWriter) PushUint16(val uint16)
PushUint16 writes an uint16 word to the stream nolint
func (*StreamWriter) PushUint32 ¶
func (v *StreamWriter) PushUint32(val uint32)
PushUint32 writes a uint32 dword to the stream nolint
func (*StreamWriter) PushUint64 ¶
func (v *StreamWriter) PushUint64(val uint64)
PushUint64 writes a uint64 qword to the stream nolint