azcs

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ST_BINARYFLAG_MASK             = 0xF8
	ST_BINARY_VALUE_SIZE_MASK      = 0x07
	ST_BINARYFLAG_ELEMENT_HEADER   = 1 << 3
	ST_BINARYFLAG_HAS_VALUE        = 1 << 4
	ST_BINARYFLAG_EXTRA_SIZE_FIELD = 1 << 5
	ST_BINARYFLAG_HAS_NAME         = 1 << 6
	ST_BINARYFLAG_HAS_VERSION      = 1 << 7
	ST_BINARYFLAG_ELEMENT_END      = 0
)
View Source
const (
	TypeField  = "__type"
	ValueField = "__value"
)

Variables

View Source
var (
	DefaultTypeResolver TypeResolver = func(element *Element) string {
		typ := element.Type.String()
		if !element.SpecializedType.IsNil() {
			typ = element.SpecializedType.String()
		}

		if DefaultTypeRegistry.Has(typ) {
			return DefaultTypeRegistry.Get(typ)
		}

		return typ
	}
	DefaultHashResolver HashResolver = func(element *Element) string {
		hash := element.NameCrc

		if DefaultHashRegistry.Has(hash) {
			return DefaultHashRegistry.Get(hash)
		}

		formattedHash := fmt.Sprintf("0x%08x", hash)

		return formattedHash
	}
)
View Source
var (
	EOE = fmt.Errorf("end of element")
)

Functions

func GetReader added in v0.7.4

func GetReader(path string, isCompressed bool) (io.ReadCloser, error)

func IsAzcsFile added in v0.7.4

func IsAzcsFile(path string) (bool, bool, error)

func LoadHashes

func LoadHashes(filePath string, registry *HashRegistry) error

func LoadTypes

func LoadTypes(filePath string, registry *TypeRegistry) error

func ResolveStream added in v0.6.2

func ResolveStream(stream *Stream, typeResolver TypeResolver, hashResolver HashResolver) (any, error)

func StoreHashes

func StoreHashes(filePath string, registry *HashRegistry) error

func StoreTypes

func StoreTypes(filePath string, registry *TypeRegistry) error

Types

type Element

type Element struct {
	Type            uuid.UUID
	SpecializedType uuid.UUID
	NameCrc         uint32
	Version         uint8
	DataSize        uint32
	Data            []byte
	Elements        []*Element
}

func (Element) ResolveType

func (element Element) ResolveType() uuid.UUID

type HashRegistry

type HashRegistry struct {
	// contains filtered or unexported fields
}
var DefaultHashRegistry *HashRegistry

func NewHashRegistry

func NewHashRegistry() *HashRegistry

func (*HashRegistry) Add

func (registry *HashRegistry) Add(value string) error

func (*HashRegistry) Get

func (registry *HashRegistry) Get(hash uint32) string

func (*HashRegistry) Has

func (registry *HashRegistry) Has(hash uint32) bool

func (*HashRegistry) Hashes

func (registry *HashRegistry) Hashes() map[uint32]string

func (*HashRegistry) Remove

func (registry *HashRegistry) Remove(hash uint32)

type HashResolver added in v0.6.2

type HashResolver func(element *Element) string

type JsonFloat32 added in v0.6.2

type JsonFloat32 float32

func (JsonFloat32) MarshalJSON added in v0.6.2

func (v JsonFloat32) MarshalJSON() ([]byte, error)

func (*JsonFloat32) UnmarshalJSON added in v0.6.2

func (v *JsonFloat32) UnmarshalJSON(b []byte) error

type JsonFloat64 added in v0.6.2

type JsonFloat64 float64

func (JsonFloat64) MarshalJSON added in v0.6.2

func (v JsonFloat64) MarshalJSON() ([]byte, error)

func (*JsonFloat64) UnmarshalJSON added in v0.6.2

func (v *JsonFloat64) UnmarshalJSON(b []byte) error

type Stream

type Stream struct {
	Version  uint32
	Elements []*Element
}

func Parse

func Parse(r io.Reader) (*Stream, error)

type TypeRegistry

type TypeRegistry struct {
	// contains filtered or unexported fields
}
var DefaultTypeRegistry *TypeRegistry

func NewTypeRegistry

func NewTypeRegistry() *TypeRegistry

func (*TypeRegistry) Add

func (registry *TypeRegistry) Add(id string, value string) error

func (*TypeRegistry) Get

func (registry *TypeRegistry) Get(id string) string

func (*TypeRegistry) Has

func (registry *TypeRegistry) Has(id string) bool

func (*TypeRegistry) Remove

func (registry *TypeRegistry) Remove(id string)

func (*TypeRegistry) Types

func (registry *TypeRegistry) Types() map[string]string

type TypeResolver added in v0.6.2

type TypeResolver func(element *Element) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL