Documentation
¶
Overview ¶
Package push provides low-level routines to encode values accordingly to the format of save files of Grim Dawn. The routines "push" encoded values to decoding/encoding context almost in terms of enqueuing of data, transforming the context in the process.
Index ¶
- func Block(ctx *gdio.Decenc, kind uint32) func(func() bool)
- func Bool(ctx *gdio.Decenc, v bool)
- func Byte(ctx *gdio.Decenc, v byte)
- func CheckInt(ctx *gdio.Decenc, v int)
- func Each[T any](ctx *gdio.Decenc, s []T, pushSize bool) iter.Seq[*T]
- func Float32(ctx *gdio.Decenc, v float32)
- func Int(ctx *gdio.Decenc, v int)
- func Slice[T any](ctx *gdio.Decenc, v []T, p func(*gdio.Decenc, T))
- func State(ctx *gdio.Decenc)
- func String(ctx *gdio.Decenc, v string)
- func StringUtf16(ctx *gdio.Decenc, v string)
- func Uint32(ctx *gdio.Decenc, v uint32)
- func Uuid(ctx *gdio.Decenc, u uuid.UUID)
- type ErrOutOfRange
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Block ¶
Block takes a pointer to an instance of gdio.Decenc with kind of a block and returns an iterator, which wraps around the general processing of a block. The iterator properly pushes the block's prefix and suffix, yielding between and calculating the resulting block size. If the context has been halted or is halted during yield, the iterator returns immediately.
The function is supposed to be used in "for range" loop construction. It can panic, if the provided yield function is nil.
func Bool ¶
Bool takes a pointer to an instance of gdio.Decenc with a boolean value and pushes zero byte, if the value is false, or byte of one otherwise. Its behavior is based on Byte completely.
func Byte ¶
Byte takes a pointer to an instance of gdio.Decenc and a byte, encrypts the byte with help of the context's state and pushes the encrypted byte to the context's data stack, transforming the context's state in the process. It does nothing if the context has been halted.
func CheckInt ¶
CheckInt takes a pointer to an instance of gdio.Decenc with an integer. It halts the context with an instance of ErrOutOfRange, if the value is not in the range [0, math.MaxUint32], otherwise it does nothing.
func Each ¶
Each is a generic function to push elements of a slice to a context with the size of the slice or without it. It takes a pointer to an instance of gdio.Decenc, a slice of instances of T and a boolean flag of size's push. It returns an iterator function over pointers to the elements of the slice, which should be pushed to the context. The iterator pushes the slice's size to the context, if the provided flag is set. If the context has been halted, it stops the iteration.
The function is supposed to be used in "for range" loop construction. It can panic, if the provided yield function is nil.
func Float32 ¶
Float32 takes a pointer to an instance of gdio.Decenc with a number in single-precision floating-point format and pushes the number to the context. Its behavior is based on Uint32 completely.
func Int ¶
Int takes a pointer to an instance of gdio.Decenc with an integer, checks, if the number is in proper range with CheckInt, and tries to push it with Uint32. Its behavior is defined by the functions completely.
func Slice ¶
Slice takes a pointer to an instance of gdio.Decenc, a slice of values of type T and a function p, which takes a context too with a value of type T. Slice pushes length of the slice to the context and then all the elements with help of p until the end of the slice or the context halts. It does nothing if the context has already been halted.
func State ¶
State takes a pointer to an instance of gdio.Decenc and pushes state of the context to the context as is without any transformation. It does nothing if the context has been halted.
func String ¶
String takes a pointer to an instance of gdio.Decenc with a string value and pushes length of the string and its content to the context with help of Uint32 and Byte. It does nothing if the context has already been halted.
func StringUtf16 ¶
StringUtf16 takes a pointer to an instance of gdio.Decenc with a string value and pushes length of the string and its content to the context with help of Each in format of UTF-16 little endian encoding. It does nothing if the context has already been halted.
func Uint32 ¶
Uint32 takes a pointer to an instance of gdio.Decenc and an unsigned 32-bit integer, encrypts the number with help of the context's state and pushes the encrypted value to the context's data stack in little-endian order, transforming the context's state in the process. It does nothing if the context has been halted.
Types ¶
type ErrOutOfRange ¶
type ErrOutOfRange int
ErrOutOfRange represents errors, which signal, that an integer value is out of range [0, math.MaxUint32]
func (*ErrOutOfRange) Error ¶
func (e *ErrOutOfRange) Error() string
Error returns a description of the error. It implements the corresponding method of the interface error.
func (*ErrOutOfRange) Value ¶
func (e *ErrOutOfRange) Value() int
Value returns the value, which is out of the range