lsgo

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: MIT Imports: 18 Imported by: 0

README

TODO

Documentation

Overview

Adapted from the image package

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrVectorTooBig    = errors.New("the vector is too big cannot marshal to an xml element")
	ErrInvalidNameKey  = errors.New("invalid name key")
	ErrKeyDoesNotMatch = errors.New("key for this node does not match")
)
View Source
var ErrFormat = errors.New("lsgo: unknown format")

ErrFormat indicates that decoding encountered an unknown format.

Functions

func Decompress

func Decompress(compressed io.Reader, uncompressedSize int, compressionFlags byte, chunked bool) io.ReadSeeker

func LimitReadSeeker

func LimitReadSeeker(r io.ReadSeeker, n int64) io.ReadSeeker

LimitReadSeeker returns a Reader that reads from r but stops with EOF after n bytes. The underlying implementation is a *LimitedReader.

func MakeCompressionFlags

func MakeCompressionFlags(method CompressionMethod, level CompressionLevel) int

func NewFilter

func NewFilter(f map[string][]string, l log.Logger) log.Logger

NewFilter allows filtering of l

func ReadCString

func ReadCString(r io.Reader, length int) (string, error)

func RegisterFormat added in v0.1.0

func RegisterFormat(name, magic string, decode func(io.ReadSeeker) (Resource, error))

RegisterFormat registers an image format for use by Decode. Name is the name of the format, like "jpeg" or "png". Magic is the magic prefix that identifies the format's encoding. The magic string can contain "?" wildcards that each match any one byte. Decode is the function that decodes the encoded image. DecodeConfig is the function that decodes just its configuration.

func SupportedFormat added in v0.1.0

func SupportedFormat(signature []byte) bool

Types

type CompressionLevel

type CompressionLevel int
const (
	FastCompression    CompressionLevel = 0x10
	DefaultCompression CompressionLevel = 0x20
	MaxCompression     CompressionLevel = 0x40
)

func CompressionFlagsToLevel

func CompressionFlagsToLevel(flags byte) CompressionLevel

type CompressionMethod

type CompressionMethod int
const (
	CMInvalid CompressionMethod = iota - 1
	CMNone
	CMZlib
	CMLZ4
)

func CompressionFlagsToMethod

func CompressionFlagsToMethod(flags byte) CompressionMethod

type DataType

type DataType int
const (
	DTNone DataType = iota
	DTByte
	DTShort
	DTUShort
	DTInt
	DTUInt
	DTFloat
	DTDouble
	DTIVec2
	DTIVec3
	DTIVec4
	DTVec2
	DTVec3
	DTVec4
	DTMat2
	DTMat3
	DTMat3x4
	DTMat4x3
	DTMat4
	DTBool
	DTString
	DTPath
	DTFixedString
	DTLSString
	DTULongLong
	DTScratchBuffer
	// Seems to be unused?
	DTLong
	DTInt8
	DTTranslatedString
	DTWString
	DTLSWString
	DTUUID
	DTInt64
	DTTranslatedFSString
	// Last supported datatype, always keep this one at the end
	DTMax = iota - 1
)

func (DataType) GetColumns

func (dt DataType) GetColumns() (int, error)

func (DataType) GetRows

func (dt DataType) GetRows() (int, error)

func (*DataType) MarshalXMLAttr

func (dt *DataType) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (DataType) String

func (dt DataType) String() string

type FileVersion

type FileVersion uint32
const (
	// Initial version of the LSF format
	VerInitial FileVersion = iota + 1

	// LSF version that added chunked compression for substreams
	VerChunkedCompress

	// LSF version that extended the node descriptors
	VerExtendedNodes

	// BG3 version, no changes found so far apart from version numbering
	VerBG3

	// Latest version supported by this library
	MaxVersion = iota
)

type HeaderError

type HeaderError struct {
	Expected []byte
	Got      []byte
}

func (HeaderError) Error

func (he HeaderError) Error() string

type Ivec

type Ivec []int

func (Ivec) String

func (i Ivec) String() string

type LSMetadata

type LSMetadata struct {
	Timestamp uint64 `xml:"-"`
	Major     uint32 `xml:"major,attr"`
	Minor     uint32 `xml:"minor,attr"`
	Revision  uint32 `xml:"revision,attr"`
	Build     uint32 `xml:"build,attr"`
}

type LimitedReadSeeker

type LimitedReadSeeker struct {
	R io.ReadSeeker // underlying reader
	N int64         // max bytes remaining
}

A LimitedReadSeeker reads from R but limits the amount of data returned to just N bytes. Each call to Read updates N to reflect the new amount remaining. Read returns EOF when N <= 0 or when the underlying R returns EOF.

func (*LimitedReadSeeker) Read

func (l *LimitedReadSeeker) Read(p []byte) (n int, err error)

func (*LimitedReadSeeker) Seek

func (l *LimitedReadSeeker) Seek(offset int64, whence int) (int64, error)

type Mat

type Mat mat.Dense

func (Mat) MarshalXML

func (m Mat) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type Node

type Node struct {
	Name       string          `xml:"id,attr"`
	Parent     *Node           `xml:"-"`
	Attributes []NodeAttribute `xml:"attribute"`
	Children   []*Node         `xml:"children>node,omitempty"`

	RegionName string `xml:"-"`
}

func (*Node) AppendChild

func (n *Node) AppendChild(child *Node)

func (Node) ChildCount

func (n Node) ChildCount() (sum int)

func (Node) MarshalXML

func (n Node) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type NodeAttribute

type NodeAttribute struct {
	Name  string      `xml:"id,attr"`
	Type  DataType    `xml:"type,attr"`
	Value interface{} `xml:"value,attr"`
}

func ReadAttribute

func ReadAttribute(r io.ReadSeeker, name string, DT DataType, length uint, l log.Logger) (NodeAttribute, error)

func (*NodeAttribute) FromString

func (na *NodeAttribute) FromString(str string) error

func (NodeAttribute) GetColumns

func (na NodeAttribute) GetColumns() (int, error)

func (NodeAttribute) GetRows

func (na NodeAttribute) GetRows() (int, error)

func (NodeAttribute) IsNumeric

func (na NodeAttribute) IsNumeric() bool

func (NodeAttribute) MarshalXML

func (na NodeAttribute) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (NodeAttribute) String

func (na NodeAttribute) String() string

type Resource

type Resource struct {
	Metadata LSMetadata `xml:"version"`
	Regions  []*Node    `xml:"region"`
}

func Decode added in v0.1.0

func Decode(r io.ReadSeeker) (Resource, string, error)

func (*Resource) Read

func (r *Resource) Read(io.Reader)

type TranslatedFSString

type TranslatedFSString struct {
	TranslatedString
	Arguments []TranslatedFSStringArgument
}

func ReadTranslatedFSString

func ReadTranslatedFSString(r io.ReadSeeker, version FileVersion) (TranslatedFSString, error)

type TranslatedFSStringArgument

type TranslatedFSStringArgument struct {
	String TranslatedFSString
	Key    string
	Value  string
}

type TranslatedString

type TranslatedString struct {
	Version uint16
	Value   string
	Handle  string
}

func ReadTranslatedString

func ReadTranslatedString(r io.ReadSeeker, version FileVersion, engineVersion uint32) (TranslatedString, error)

func (TranslatedString) MarshalXML

func (ts TranslatedString) MarshalXML(e *xml.Encoder, start *xml.StartElement) error

type Vec

type Vec []float64

func (Vec) MarshalXML

func (v Vec) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type XMLMarshaler

type XMLMarshaler interface {
	MarshalXML(e *xml.Encoder, start *xml.StartElement) error
}

XMLMarshaler has a pointer to start in order to append multiple attributes to the xml element

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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