Documentation
¶
Index ¶
- Constants
- Variables
- func Align[K Integer](s io.Seeker, lim K) (K, error)
- func At[K Integer](w io.Seeker) (K, error)
- func Bitget[OUT Integer, IN Integer](bitlist IN, bits int, pos int) OUT
- func BitgetFlag[IN Integer](bitlist IN, pos int) bool
- func BitgetSigned[OUT Integer, IN Integer](bitlist IN, bits int, pos int) OUT
- func Bitset[IN Integer, VAL Integer](bitlist IN, val VAL, bits int, pos int) IN
- func BitsetFlag[IN Integer](bitlist IN, flag bool, pos int) IN
- func Decode[T any](r io.Reader) (v T, err error)
- func DecodeFixedPoint(rawData uint64, signBits int, wholeBits int, fractBits int) float64
- func FillerArray[K any](length int, value K) []K
- func Get(buf []byte, pos int, data ...any) error
- func GetEndianFromSignature(signature [2]byte) binary.ByteOrder
- func Pad[K Integer](n K, lim K) K
- func PadTo[K Integer](n K, lim K) K
- func Put(buf []byte, pos int, data ...any) ([]byte, error)
- func PutAny[K any](buf []K, pos int, data ...K) []K
- func Read(r io.Reader, data ...any) error
- func ReadAt[K Integer](r io.ReaderAt, at K, data ...any) error
- func ReadBytesAsInt(r io.Reader, numBytes int) (uint64, error)
- func ReadFixedPoint(r io.Reader, signBits int, wholeBits int, fractBits int) (float64, error)
- func ReadSingle[K any](r io.Reader) K
- func ReadString(r io.Reader, format StringFormat, fixedLength int) (string, error)
- func ReadWithOrder(r io.Reader, buf []byte, byteOrder binary.ByteOrder) (n int, err error)
- func Seek[K Integer](s io.Seeker, offset K, whence int) (K, error)
- func Skip[K Integer](w io.Seeker, num K) (K, error)
- func StructTagAdd(tag reflect.StructTag, key string, value string) reflect.StructTag
- func StructTagFind(tag reflect.StructTag, key string) (start int, end int, ok bool)
- func StructTagRemove(tag reflect.StructTag, key string) reflect.StructTag
- func Write(w io.Writer, data ...any) error
- func WriteAt[K Integer](w io.WriterAt, at K, data ...any) error
- func WritePadded(w io.Writer, lim int, filler byte, data ...any) error
- type Decodable
- type Endianed
- type EndianedReader
- type EndianedWriter
- type Integer
- type StringFormat
Constants ¶
const ( StringFormat_Invalid = StringFormat(0) StringFormat_ASCII )
Variables ¶
var DefaultEndian binary.ByteOrder = binary.LittleEndian
var ErrInvalidByteOrder = errors.New("invalid byte order, expected 0xFEFF or 0xFFFE")
var ErrInvalidByteOrderType = errors.New("invalid byte order type, expected [2]byte")
var ErrInvalidFixedPointBits = errors.New("invalid fixed point bits, bit counts cannot be below 0")
var ErrInvalidFixedPointSign = errors.New("invalid fixed point sign, sign can only be 0 or 1 bit")
var ErrInvalidFixedPointSignature = errors.New("invalid fixed point tag, expected \"int,int,int\"")
var ErrInvalidFixedPointSize = errors.New("invalid fixed point size, expected multiple of 8 bits, max 64")
var ErrInvalidFixedPointType = errors.New("invalid fixed point type, expected float32 or float64")
var ErrInvalidTellType = errors.New("invalid seekpos type, expected integer")
var ErrNotSeeker = errors.New("reader does not implement io.Seeker")
var ErrSliceMissingLength = errors.New("cannot decode slice without length tag")
var ErrUnknownNamedInt = errors.New("malformed int or invalid named int field")
var ErrUnknownString = errors.New("unknown string type")
var SignatureBE = [2]byte{0xFE, 0xFF}
var SignatureLE = [2]byte{0xFF, 0xFE}
Functions ¶
func BitgetFlag ¶ added in v0.2.0
func BitgetSigned ¶ added in v0.2.0
func BitsetFlag ¶ added in v0.2.0
func DecodeFixedPoint ¶ added in v0.4.0
func GetEndianFromSignature ¶ added in v0.2.0
func Read ¶
Read data from r into data. All entries in data should be pointers/references. Errors are ignored.
func ReadBytesAsInt ¶ added in v0.4.0
func ReadFixedPoint ¶ added in v0.4.0
func ReadSingle ¶
Return single read value. Errors are ignored.
func ReadString ¶ added in v0.4.0
func ReadWithOrder ¶ added in v0.4.0
Reads bytes as if an integer was read. If big endian, this is the same as reading normally. If little endian, the bytes will be in reversed before being returned.
func StructTagAdd ¶ added in v0.2.0
Adds a key/value pair to the struct tag
func StructTagFind ¶ added in v0.2.0
This is modified code from the GO standard library. It finds the position of a specific key/value pair in a tag.
func StructTagRemove ¶ added in v0.2.0
Removes a key/value pair from the struct tag
Types ¶
type EndianedReader ¶ added in v0.2.0
func (*EndianedReader) GetEndian ¶ added in v0.2.0
func (r *EndianedReader) GetEndian() binary.ByteOrder
func (*EndianedReader) ReadWithOrder ¶ added in v0.2.0
func (r *EndianedReader) ReadWithOrder(buf []byte) (n int, err error)
Reads bytes as if an integer was read. If big endian, this is the same as reading normally. If little endian, the bytes will be in reversed before being returned.
type EndianedWriter ¶ added in v0.2.0
func (*EndianedWriter) GetEndian ¶ added in v0.2.0
func (w *EndianedWriter) GetEndian() binary.ByteOrder
func (*EndianedWriter) WriteWithOrder ¶ added in v0.2.0
func (r *EndianedWriter) WriteWithOrder(buf []byte) (n int, err error)
Writes bytes as if an integer was written. If big endian, this is the same as writing normally. If little endian, the bytes will be written in reverse order.
type StringFormat ¶ added in v0.4.0
type StringFormat int
func StringFormatFromString ¶ added in v0.4.0
func StringFormatFromString(format string) StringFormat