Documentation
¶
Overview ¶
Package arz provides tools to work with ARZ-databases, which have been used in Grim Dawn game. Main workhorses of the library are functions Decode and Encode, which allow to parse content of an ARZ-database and, vice versa, compile it from description of records.
Index ¶
Constants ¶
const ( // FieldTypeInt32 marks, that values of the field should be // interpretted as 32-bit signed integers FieldTypeInt32 uint16 = iota // FiledTypeFloat32 marks, that values of the field should be // interpretted as single-precision floating-point numbers FieldTypeFloat32 // FieldTypeString marks, that values of the field should be // interpretted as indices in global database table of strings FieldTypeString // FieldTypeBool marks, that values of the field should be interpretted // as boolean values: zero would mean boolean false and any non-zero // value would mean boolean true FieldTypeBool )
const Version = "v2.1.0"
Version of the library
Variables ¶
var ErrFieldsDataOutOfRange error = &errFieldsDataOutOfRange{}
The singleton instance of [errFieldsDataOutOfRange] as a signal, that database can't access fields of a record due to invalid data in the record
var ErrInvalidHeader error = &errInvalidHeader{}
The singleton instance of [errInvalidHeader] as a signal, that header of a database is invalid
var ErrInvalidString error = &errInvalidString{}
The singleton instance of [errInvalidString] as a signal, that database string is invalid
var ErrInvalidStringSection error = &errInvalidStringSection{}
The singleton instance of [errInvalidStringSection] as a signal, that string section of a database is invalid
var ErrNotEnoughData error = &errNotEnoughData{}
The singleton instance of [errNotEnoughData] as a signal, that there is not enough data to decode a header
Functions ¶
func Encode ¶ added in v2.1.0
Encode takes a slice of instances of EncRec and encodes the records into a slice of bytes accordingly to the format of ARZ-databases. It is supposed to encode _small_ amount of data, so it assumes, that no input record sports a field with more than 65535 values and that the positions and offsets fit into unsigned 32-bit integers well.
Types ¶
type Db ¶
type Db struct {
// contains filtered or unexported fields
}
Db is a type of depictions of ARZ-databases
func Decode ¶
Decode takes a slice of bytes with data of an ARZ-database, parses it and returns a pointer to Db instance with the parsed information. It checks the data on consistency and returns a corresponding error in case of found disrepancies.
func (*Db) Fields ¶
Fields takes a record's decription and returns a prepared instance of Fields with the data decompressed from the database. The instance is valid until the next call of the method. If the description is malformed or an error has happened during the decompression, the method returns a corresponding error.
func (*Db) Records ¶
Records takes a function, which collects instances of Record, and iterates over the records data from the database, yielding the records to the function until it returns boolean false. It is supposed to be used in 'for range' constructions. The method does nothing, if the function is nil. It doesn't panic, if the records data is malformed.
type EncRec ¶ added in v2.1.0
type EncRec struct {
// Name is the name of the record
Name string
// Tag is the tag of the record
Tag string
// Ints is a collection of fields of the record with integer values.
// Nil collection should be treated as empty.
Ints map[string][]int32
// Floats is a collection of fields of the record with single-precision
// floating point values. Nil collection should be treated as empty.
Floats map[string][]float32
// Strings is a collection of fields of the record with string values.
// Nil collection should be treated as empty.
Strings map[string][]string
// Bools is a collection of fields of the record with boolean values.
// Nil collection should be treated as empty.
Bools map[string][]bool
}
EncRec represents records of ARZ-database for the process of encoding
type ErrNotSupported ¶ added in v2.1.0
type ErrNotSupported struct {
// contains filtered or unexported fields
}
ErrNotSupported represents errors, which signal, that the database's version is not supported
func (*ErrNotSupported) Error ¶ added in v2.1.0
func (e *ErrNotSupported) Error() string
Error returns a description of the error. It implements the corresponding method of the interface error.
func (*ErrNotSupported) Version ¶ added in v2.1.0
func (e *ErrNotSupported) Version() uint32
Version returns version of the database
type ErrStringNotSupported ¶ added in v2.1.0
type ErrStringNotSupported struct {
// contains filtered or unexported fields
}
ErrStringNotSupported represents errors, which signal, that decoding of a database string is not supported
func (*ErrStringNotSupported) Error ¶ added in v2.1.0
func (e *ErrStringNotSupported) Error() string
Error returns a description of the error. It implements the corresponding method of the interface error.
func (*ErrStringNotSupported) Len ¶ added in v2.1.0
func (e *ErrStringNotSupported) Len() uint32
Len returns length of the database string
func (*ErrStringNotSupported) Pos ¶ added in v2.1.0
func (e *ErrStringNotSupported) Pos() int
Pos returns position of the database string within the data
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
Field is a type of fields of records of ARZ-archives
func (Field) Value ¶
Value returns value of the field, if the field has exactly one value. It has no sense in other cases. The value must be interpreted with help of [Type] of the field.
func (Field) ValuesAmount ¶
ValuesAmount returns amount of field's values
type Fields ¶
type Fields struct {
// contains filtered or unexported fields
}
Fields is a type of intermediate holders of decompressed data of fields, which main purpose is to provide iterators over fields and their values
func (Fields) Seq ¶
Seq takes a yielding function, which collects fields and iterators of their values, and yields the fields and values from the inner data to the function. It does nothing, if the function is nil. If a current field has exactly one value, the method yields nil iterator over values, as it fills the only value directly in the field. If the inner data is malformed or inconsistent, the method doesn't produce excess fuss, yielding the fields and values, while it's possible. So, its behavior allows to get less values for a field, if the data is invalid.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
arzlist
command
|
|
|
Package internal is a container of subpackages, which should be protected from import to other projects
|
Package internal is a container of subpackages, which should be protected from import to other projects |
|
strpac
Package strpac provides tools to pack descriptions of strings in ARZ-archives of Grim Dawn game.
|
Package strpac provides tools to pack descriptions of strings in ARZ-archives of Grim Dawn game. |