Documentation ¶
Overview ¶
Adapted from the image package
Index ¶
- Variables
- func Decompress(compressed io.Reader, uncompressedSize int, compressionFlags byte, ...) io.ReadSeeker
- func LimitReadSeeker(r io.ReadSeeker, n int64) io.ReadSeeker
- func MakeCompressionFlags(method CompressionMethod, level CompressionLevel) int
- func NewFilter(f map[string][]string, l log.Logger) log.Logger
- func ReadCString(r io.Reader, length int) (string, error)
- func RegisterFormat(name, magic string, decode func(io.ReadSeeker) (Resource, error))
- func SupportedFormat(signature []byte) bool
- type CompressionLevel
- type CompressionMethod
- type DataType
- type FileVersion
- type HeaderError
- type Ivec
- type LSMetadata
- type LimitedReadSeeker
- type Mat
- type Node
- type NodeAttribute
- func (na *NodeAttribute) FromString(str string) error
- func (na NodeAttribute) GetColumns() (int, error)
- func (na NodeAttribute) GetRows() (int, error)
- func (na NodeAttribute) IsNumeric() bool
- func (na NodeAttribute) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (na NodeAttribute) String() string
- type Resource
- type TranslatedFSString
- type TranslatedFSStringArgument
- type TranslatedString
- type Vec
- type XMLMarshaler
Constants ¶
This section is empty.
Variables ¶
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") )
var ErrFormat = errors.New("lsgo: unknown format")
ErrFormat indicates that decoding encountered an unknown format.
var Logger log.Logger = log.NewNopLogger()
Functions ¶
func Decompress ¶
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 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
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 (*DataType) MarshalXMLAttr ¶
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 ¶
func (HeaderError) Error ¶
func (he HeaderError) Error() string
type LSMetadata ¶
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.
type Mat ¶
func (Mat) MarshalXML ¶
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 (Node) ChildCount ¶
func (Node) MarshalXML ¶
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"` }
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 ¶
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 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