Documentation
¶
Overview ¶
Package push provides basic routines to push data of individual values of different types and some not-so-basic to push data of blocks from save files of Grim Dawn
Index ¶
- func Block(ctx gdcx.Context, kind uint32) iter.Seq[gdcx.Context]
- func Bool(ctx gdcx.Context, v bool)
- func Byte(ctx gdcx.Context, v byte)
- func CheckInt(ctx gdcx.Context, v int)
- func Float32(ctx gdcx.Context, v float32)
- func Int(ctx gdcx.Context, v int)
- func Safe[T comparable](ctx gdcx.Context, v T, err error) func(func() bool)
- func Slice[T any](ctx gdcx.Context, v []T, p func(gdcx.Context, T))
- func State(ctx gdcx.Context)
- func String(ctx gdcx.Context, v string)
- func StringUtf16(ctx gdcx.Context, v string)
- func Uint32(ctx gdcx.Context, v uint32)
- func Uuid(ctx gdcx.Context, v [16]byte)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Block ¶
Block takes an instance of gdcx.Context and a `uint32` value with kind of a block, and returns an iterator of the context. The iterator properly pushes the block's prefix and suffix, yielding between and calculating the resulting block size. If the context is nil, has been halted or is halted during yield, the iterator returns.
func Bool ¶
Bool takes an instance of gdcx.Context and a `bool` value, and pushed zero byte, if the value is false, or byte of 1 otherwise. Its behavior is based on Byte completely.
func Byte ¶
Byte takes an instance of gdcx.Context 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 is nil or has been halted.
func CheckInt ¶
CheckInt takes an instance of gdcx.Context and an `int` value, and checks, if the value is in range of [0, math.MaxUint32]. If the context is nil or the value is in range, it does nothig. Otherwise it halts the context with the corresponding error.
func Float32 ¶
Float32 takes a instance of gdcx.Context and a `float32` value, and pushes the value onto data stack of the context. Its behavior is based on Uint32 completely.
func Int ¶
Int takes an instance of gdcx.Context and an `int` value, checks, if the value is in proper range with CheckInt, and tries to push it with Uint32. Its behavior is defined by the functions completely.
func Safe ¶
func Safe[T comparable](ctx gdcx.Context, v T, err error) func(func() bool)
Safe is a wrapper around the checks in the provided instance of gdcx.Context and the provided instance of comparable `T`. It yields to the provided function, if the context is not nil and hasn't been halted, and the instance of `T` doesn't default value. If the instance has default value, it halts the context with the provided error value. It is supposed to be used in `for range` clause:
for range Safe(ctx, v, errVNil) {
// This block of code is assured to have non-nil not-halted ctx
// and v with non-default (like nil) value
}
func Slice ¶
Slice accepts an instance of gdcx.Context, a slice of values of type `T` and a function p, which accepts a context too with a value of type `T`. Slice pushes to the data stack of the context length of the slice and then all the elements with help of p. It returns, if the context is nil, has been halted or is halted in the process. It halts the context with a corresponding error, if p is nil. It treats nil slices as zero-lengthed ones.
func State ¶
States takes an instance of gdcx.Context and pushes its state to its data stack as is without any transforming. It does nothing, if the context is nil or has been halted.
func String ¶
String takes an instance of gdcx.Context and a string value, and pushes length of the string and its content to the data stack of the context with help of Uint32 and Byte. If the context is nil or has been halted, it does nothing.
func StringUtf16 ¶
StringUtf16 takes an instance of gdcx.Context and a string value, and pushes length of the string and its content to the data stack of the context with help of Uint32 and Byte in format of UTF-16 little endian encoding. If the context is nil or has been halted, it does nothing.
func Uint32 ¶
Uint32 takes an instance of gdcx.Context and a `uint32` value, encrypts the value 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 is nil or has been halted.
Types ¶
This section is empty.