Documentation ¶
Overview ¶
TODO Change Format API to have a FormatTo(.., io.writer), or similar, so we can avoid all the string concat.
TODO Move this file into a ints package ¶
TODO This file is full of panics, because I don't know the correct way to deal with errors under Lua
TODO Consider moving this into a separate package, so that the parser can't use the unexported fields (and forced to go via Getters, which "do the right thing" wrt extending and defaults.
TODO Change the Validate to collect errors, instead of stopping on first TODO Use validationError as much as possible
Shout out to https://github.com/wicast/xj2s for helping to generate the XML structs TODO I have special ufwb tags, do I need them anymore?
Index ¶
- Constants
- func LogAtLevel(level logrus.Level, args ...interface{})
- func Walk(u *Ufwb, walkFunc WalkFunc) []error
- func WalkFrom(u *Ufwb, element Element, walkFunc WalkFunc) []error
- func WriteXmlGrammar(w io.Writer, ufwb *Ufwb) error
- type Base
- type Binary
- func (b *Binary) Bytes(file io.ReaderAt, value *Value) ([]byte, error)
- func (b *Binary) DeriveFrom(element Element) error
- func (b *Binary) Description() string
- func (b *Binary) ElemType() string
- func (b *Binary) FillColour() Colour
- func (b *Binary) Format(file io.ReaderAt, value *Value) (string, error)
- func (b *Binary) Id() int
- func (b *Binary) Length() Expression
- func (b *Binary) LengthUnit() LengthUnit
- func (b *Binary) MustMatch() Bool
- func (b *Binary) Name() string
- func (b *Binary) Read(d *Decoder) (*Value, error)
- func (b *Binary) RepeatMax() Expression
- func (b *Binary) RepeatMin() Expression
- func (b *Binary) SetDescription(description string)
- func (b *Binary) SetFillColour(fillColour Colour)
- func (b *Binary) SetId(id int)
- func (b *Binary) SetLength(length Expression)
- func (b *Binary) SetLengthUnit(lengthUnit LengthUnit)
- func (b *Binary) SetMustMatch(mustMatch Bool)
- func (b *Binary) SetName(name string)
- func (b *Binary) SetRepeatMax(repeatMax Expression)
- func (b *Binary) SetRepeatMin(repeatMin Expression)
- func (b *Binary) SetStrokeColour(strokeColour Colour)
- func (b *Binary) SetValues(values []*FixedBinaryValue)
- func (b *Binary) StrokeColour() Colour
- func (b *Binary) Values() []*FixedBinaryValue
- type Bool
- type Colour
- type Colourful
- type ConstExpression
- type Custom
- func (c *Custom) DeriveFrom(element Element) error
- func (c *Custom) Description() string
- func (c *Custom) ElemType() string
- func (c *Custom) FillColour() Colour
- func (n *Custom) Format(file io.ReaderAt, value *Value) (string, error)
- func (c *Custom) Id() int
- func (c *Custom) Length() Expression
- func (c *Custom) LengthUnit() LengthUnit
- func (c *Custom) Name() string
- func (c *Custom) Read(d *Decoder) (*Value, error)
- func (*Custom) RepeatMax() Expression
- func (*Custom) RepeatMin() Expression
- func (c *Custom) Script() *Script
- func (c *Custom) SetDescription(description string)
- func (c *Custom) SetFillColour(fillColour Colour)
- func (c *Custom) SetId(id int)
- func (c *Custom) SetLength(length Expression)
- func (c *Custom) SetLengthUnit(lengthUnit LengthUnit)
- func (c *Custom) SetName(name string)
- func (c *Custom) SetScript(script *Script)
- func (c *Custom) SetStrokeColour(strokeColour Colour)
- func (c *Custom) StrokeColour() Colour
- type Decoder
- func (d *Decoder) Bits(length Expression, unit LengthUnit) (int64, error)
- func (d *Decoder) ByteOrder(e Endian) binary.ByteOrder
- func (d *Decoder) Bytes(length Expression, unit LengthUnit) (int64, error)
- func (d *Decoder) Decode() (*Value, error)
- func (d *Decoder) ParentBounds() *ElementBounds
- func (d *Decoder) String() string
- type Derivable
- type Display
- type Element
- type ElementBounds
- type ElementId
- type Elements
- type Endian
- type Eof
- type Expression
- type FixedBinaryValue
- type FixedStringValue
- type FixedValue
- type Formatter
- type Grammar
- func (g *Grammar) DeriveFrom(element Element) error
- func (g *Grammar) Description() string
- func (g *Grammar) ElemType() string
- func (g *Grammar) Format(file io.ReaderAt, value *Value) (string, error)
- func (g *Grammar) Id() int
- func (g *Grammar) Length() Expression
- func (g *Grammar) LengthUnit() LengthUnit
- func (g *Grammar) Name() string
- func (g *Grammar) Read(d *Decoder) (*Value, error)
- func (g *Grammar) RepeatMax() Expression
- func (g *Grammar) RepeatMin() Expression
- func (g *Grammar) SetDescription(description string)
- func (g *Grammar) SetId(id int)
- func (g *Grammar) SetName(name string)
- func (g *Grammar) SetRepeatMax(repeatMax Expression)
- func (g *Grammar) SetRepeatMin(repeatMin Expression)
- type GrammarRef
- func (g *GrammarRef) DeriveFrom(element Element) error
- func (g *GrammarRef) Description() string
- func (g *GrammarRef) Disabled() Bool
- func (g *GrammarRef) ElemType() string
- func (g *GrammarRef) Filename() string
- func (n *GrammarRef) Format(file io.ReaderAt, value *Value) (string, error)
- func (g *GrammarRef) Grammar() *Grammar
- func (g *GrammarRef) Id() int
- func (g *GrammarRef) Length() Expression
- func (g *GrammarRef) LengthUnit() LengthUnit
- func (g *GrammarRef) Name() string
- func (g *GrammarRef) Read(d *Decoder) (*Value, error)
- func (g *GrammarRef) RepeatMax() Expression
- func (g *GrammarRef) RepeatMin() Expression
- func (g *GrammarRef) SetDescription(description string)
- func (g *GrammarRef) SetDisabled(disabled Bool)
- func (g *GrammarRef) SetFilename(filename string)
- func (g *GrammarRef) SetGrammar(grammar *Grammar)
- func (g *GrammarRef) SetId(id int)
- func (g *GrammarRef) SetName(name string)
- func (g *GrammarRef) SetRepeatMax(repeatMax Expression)
- func (g *GrammarRef) SetRepeatMin(repeatMin Expression)
- func (g *GrammarRef) SetUti(uti string)
- func (g *GrammarRef) Uti() string
- type LengthUnit
- type Lengthable
- type Mask
- type Number
- func (n *Number) DeriveFrom(element Element) error
- func (n *Number) Description() string
- func (n *Number) Display() Display
- func (n *Number) ElemType() string
- func (n *Number) Endian() Endian
- func (n *Number) FillColour() Colour
- func (n *Number) Format(file io.ReaderAt, value *Value) (string, error)
- func (n *Number) Id() int
- func (n *Number) Int(file io.ReaderAt, value *Value) (int64, error)
- func (n *Number) Length() Expression
- func (n *Number) LengthUnit() LengthUnit
- func (n *Number) Masks() []*Mask
- func (n *Number) MaxVal() string
- func (n *Number) MinVal() string
- func (n *Number) MustMatch() Bool
- func (n *Number) Name() string
- func (n *Number) Read(d *Decoder) (*Value, error)
- func (n *Number) RepeatMax() Expression
- func (n *Number) RepeatMin() Expression
- func (n *Number) SetDescription(description string)
- func (n *Number) SetDisplay(display Display)
- func (n *Number) SetEndian(endian Endian)
- func (n *Number) SetFillColour(fillColour Colour)
- func (n *Number) SetId(id int)
- func (n *Number) SetLength(length Expression)
- func (n *Number) SetLengthUnit(lengthUnit LengthUnit)
- func (n *Number) SetMasks(masks []*Mask)
- func (n *Number) SetMaxVal(maxVal string)
- func (n *Number) SetMinVal(minVal string)
- func (n *Number) SetMustMatch(mustMatch Bool)
- func (n *Number) SetName(name string)
- func (n *Number) SetRepeatMax(repeatMax Expression)
- func (n *Number) SetRepeatMin(repeatMin Expression)
- func (n *Number) SetSigned(signed bool)
- func (n *Number) SetStrokeColour(strokeColour Colour)
- func (n *Number) SetValueExpression(valueExpression string)
- func (n *Number) SetValues(values []*FixedValue)
- func (n *Number) Signed() bool
- func (n *Number) StrokeColour() Colour
- func (n *Number) Uint(file io.ReaderAt, value *Value) (uint64, error)
- func (n *Number) ValueExpression() string
- func (n *Number) Values() []*FixedValue
- type Offset
- func (o *Offset) Additional() string
- func (o *Offset) DeriveFrom(element Element) error
- func (o *Offset) Description() string
- func (o *Offset) Display() Display
- func (o *Offset) ElemType() string
- func (o *Offset) Endian() Endian
- func (o *Offset) FillColour() Colour
- func (o *Offset) FollowNullReference() Bool
- func (n *Offset) Format(file io.ReaderAt, value *Value) (string, error)
- func (o *Offset) Id() int
- func (o *Offset) Length() Expression
- func (o *Offset) LengthUnit() LengthUnit
- func (o *Offset) Name() string
- func (o *Offset) Read(d *Decoder) (*Value, error)
- func (o *Offset) ReferencedSize() ElementId
- func (o *Offset) References() ElementId
- func (o *Offset) RelativeTo() ElementId
- func (o *Offset) RepeatMax() Expression
- func (o *Offset) RepeatMin() Expression
- func (o *Offset) SetAdditional(additional string)
- func (o *Offset) SetDescription(description string)
- func (o *Offset) SetDisplay(display Display)
- func (o *Offset) SetEndian(endian Endian)
- func (o *Offset) SetFillColour(fillColour Colour)
- func (o *Offset) SetFollowNullReference(followNullReference Bool)
- func (o *Offset) SetId(id int)
- func (o *Offset) SetLength(length Expression)
- func (o *Offset) SetLengthUnit(lengthUnit LengthUnit)
- func (o *Offset) SetName(name string)
- func (o *Offset) SetReferencedSize(referencedSize ElementId)
- func (o *Offset) SetReferences(references ElementId)
- func (o *Offset) SetRelativeTo(relativeTo ElementId)
- func (o *Offset) SetRepeatMax(repeatMax Expression)
- func (o *Offset) SetRepeatMin(repeatMin Expression)
- func (o *Offset) SetStrokeColour(strokeColour Colour)
- func (o *Offset) StrokeColour() Colour
- type Order
- type Padding
- func (*Padding) DeriveFrom(e Element) error
- func (p *Padding) Format(file io.ReaderAt, value *Value) (string, error)
- func (*Padding) Length() Expression
- func (*Padding) LengthUnit() LengthUnit
- func (p *Padding) Read(d *Decoder) (*Value, error)
- func (*Padding) RepeatMax() Expression
- func (*Padding) RepeatMin() Expression
- type Reader
- type Repeatable
- type Repeats
- type Script
- func (o *Script) DeriveFrom(element Element) error
- func (s *Script) Description() string
- func (s *Script) ElemType() string
- func (n *Script) Format(file io.ReaderAt, value *Value) (string, error)
- func (s *Script) Id() int
- func (s *Script) Language() string
- func (s *Script) Length() Expression
- func (s *Script) LengthUnit() LengthUnit
- func (s *Script) Name() string
- func (s *Script) Read(d *Decoder) (*Value, error)
- func (s *Script) RepeatMax() Expression
- func (s *Script) RepeatMin() Expression
- func (s *Script) RunLua(d *Decoder) error
- func (s *Script) SetDescription(description string)
- func (s *Script) SetId(id int)
- func (s *Script) SetLanguage(language string)
- func (s *Script) SetName(name string)
- func (s *Script) SetRepeatMax(repeatMax Expression)
- func (s *Script) SetRepeatMin(repeatMin Expression)
- func (s *Script) SetText(text string)
- func (s *Script) SetTyp(typ string)
- func (s *Script) Text() string
- func (s *Script) Typ() string
- type StackPrinter
- type String
- func (s *String) Delimiter() byte
- func (s *String) DeriveFrom(element Element) error
- func (s *String) Description() string
- func (s *String) ElemType() string
- func (s *String) Encoding() string
- func (s *String) FillColour() Colour
- func (s *String) Format(file io.ReaderAt, value *Value) (string, error)
- func (s *String) Id() int
- func (s *String) Length() Expression
- func (s *String) LengthUnit() LengthUnit
- func (s *String) MustMatch() Bool
- func (s *String) Name() string
- func (s *String) Read(d *Decoder) (*Value, error)
- func (s *String) RepeatMax() Expression
- func (s *String) RepeatMin() Expression
- func (s *String) SetDelimiter(delimiter byte)
- func (s *String) SetDescription(description string)
- func (s *String) SetEncoding(encoding string)
- func (s *String) SetFillColour(fillColour Colour)
- func (s *String) SetId(id int)
- func (s *String) SetLength(length Expression)
- func (s *String) SetLengthUnit(lengthUnit LengthUnit)
- func (s *String) SetMustMatch(mustMatch Bool)
- func (s *String) SetName(name string)
- func (s *String) SetRepeatMax(repeatMax Expression)
- func (s *String) SetRepeatMin(repeatMin Expression)
- func (s *String) SetStrokeColour(strokeColour Colour)
- func (s *String) SetTyp(typ string)
- func (s *String) SetValues(values []*FixedStringValue)
- func (s *String) StrokeColour() Colour
- func (s *String) Typ() string
- func (s *String) Values() []*FixedStringValue
- type StringExpression
- type StructRef
- func (s *StructRef) DeriveFrom(element Element) error
- func (s *StructRef) Description() string
- func (s *StructRef) Disabled() Bool
- func (s *StructRef) ElemType() string
- func (s *StructRef) FillColour() Colour
- func (n *StructRef) Format(file io.ReaderAt, value *Value) (string, error)
- func (s *StructRef) Id() int
- func (s *StructRef) Length() Expression
- func (s *StructRef) LengthUnit() LengthUnit
- func (s *StructRef) Name() string
- func (s *StructRef) Read(d *Decoder) (*Value, error)
- func (s *StructRef) RepeatMax() Expression
- func (s *StructRef) RepeatMin() Expression
- func (s *StructRef) SetDescription(description string)
- func (s *StructRef) SetDisabled(disabled Bool)
- func (s *StructRef) SetFillColour(fillColour Colour)
- func (s *StructRef) SetId(id int)
- func (s *StructRef) SetName(name string)
- func (s *StructRef) SetRepeatMax(repeatMax Expression)
- func (s *StructRef) SetRepeatMin(repeatMin Expression)
- func (s *StructRef) SetStrokeColour(strokeColour Colour)
- func (s *StructRef) SetStructure(structure *Structure)
- func (s *StructRef) StrokeColour() Colour
- func (s *StructRef) Structure() *Structure
- type Structure
- func (s *Structure) DeriveFrom(element Element) error
- func (s *Structure) Description() string
- func (s *Structure) Display() Display
- func (s *Structure) ElemType() string
- func (s *Structure) ElementByName(name string) Element
- func (s *Structure) Elements() []Element
- func (s *Structure) Encoding() string
- func (s *Structure) Endian() Endian
- func (s *Structure) FillColour() Colour
- func (n *Structure) Format(file io.ReaderAt, value *Value) (string, error)
- func (s *Structure) Id() int
- func (s *Structure) Length() Expression
- func (s *Structure) LengthOffset() Expression
- func (s *Structure) LengthUnit() LengthUnit
- func (s *Structure) Name() string
- func (s *Structure) Order() Order
- func (s *Structure) Read(d *Decoder) (*Value, error)
- func (s *Structure) RepeatMax() Expression
- func (s *Structure) RepeatMin() Expression
- func (s *Structure) SetDescription(description string)
- func (s *Structure) SetDisplay(display Display)
- func (s *Structure) SetElements(elements []Element)
- func (s *Structure) SetEncoding(encoding string)
- func (s *Structure) SetEndian(endian Endian)
- func (s *Structure) SetFillColour(fillColour Colour)
- func (s *Structure) SetId(id int)
- func (s *Structure) SetLength(length Expression)
- func (s *Structure) SetLengthOffset(lengthOffset Expression)
- func (s *Structure) SetLengthUnit(lengthUnit LengthUnit)
- func (s *Structure) SetName(name string)
- func (s *Structure) SetOrder(order Order)
- func (s *Structure) SetRepeatMax(repeatMax Expression)
- func (s *Structure) SetRepeatMin(repeatMin Expression)
- func (s *Structure) SetSigned(signed bool)
- func (s *Structure) SetStrokeColour(strokeColour Colour)
- func (s *Structure) Signed() bool
- func (s *Structure) StrokeColour() Colour
- type Transformable
- type Ufwb
- type Updatable
- type Value
- type WalkFunc
- type XmlBinary
- type XmlCustom
- type XmlElement
- type XmlFixedValue
- type XmlFixedValues
- type XmlGrammar
- type XmlGrammarRef
- type XmlIdName
- type XmlMask
- type XmlNumber
- type XmlOffset
- type XmlRepeats
- type XmlScript
- type XmlScriptElement
- type XmlScripts
- type XmlSource
- type XmlString
- type XmlStructRef
- type XmlStructure
- type XmlUfwb
Constants ¶
const ( Black = Colour(0x000000) White = Colour(0xffffff) )
const ( UnknownEndian Endian = 0 DynamicEndian = 1 BigEndian = 2 LittleEndian = 3 )
const DEBUG = true
const MAX_STACK = 10
const MAX_VALUES = 10000
Variables ¶
This section is empty.
Functions ¶
func LogAtLevel ¶
Types ¶
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
Base is what all Elements implement
func (*Base) Description ¶
type Binary ¶
type Binary struct { Xml *XmlBinary Base Repeats Colourful // contains filtered or unexported fields }
func (*Binary) DeriveFrom ¶
func (*Binary) Description ¶
func (*Binary) FillColour ¶
func (*Binary) Length ¶
func (b *Binary) Length() Expression
func (*Binary) LengthUnit ¶
func (b *Binary) LengthUnit() LengthUnit
func (*Binary) RepeatMax ¶
func (b *Binary) RepeatMax() Expression
func (*Binary) RepeatMin ¶
func (b *Binary) RepeatMin() Expression
func (*Binary) SetDescription ¶
func (*Binary) SetFillColour ¶
func (*Binary) SetLength ¶
func (b *Binary) SetLength(length Expression)
func (*Binary) SetLengthUnit ¶
func (b *Binary) SetLengthUnit(lengthUnit LengthUnit)
func (*Binary) SetMustMatch ¶
func (*Binary) SetRepeatMax ¶
func (b *Binary) SetRepeatMax(repeatMax Expression)
func (*Binary) SetRepeatMin ¶
func (b *Binary) SetRepeatMin(repeatMin Expression)
func (*Binary) SetStrokeColour ¶
func (*Binary) SetValues ¶
func (b *Binary) SetValues(values []*FixedBinaryValue)
func (*Binary) StrokeColour ¶
func (*Binary) Values ¶
func (b *Binary) Values() []*FixedBinaryValue
type ConstExpression ¶
type ConstExpression int64
func (ConstExpression) String ¶
func (e ConstExpression) String() string
type Custom ¶
func (*Custom) DeriveFrom ¶
func (*Custom) Description ¶
func (*Custom) FillColour ¶
func (*Custom) Length ¶
func (c *Custom) Length() Expression
func (*Custom) LengthUnit ¶
func (c *Custom) LengthUnit() LengthUnit
func (*Custom) RepeatMax ¶
func (*Custom) RepeatMax() Expression
func (*Custom) RepeatMin ¶
func (*Custom) RepeatMin() Expression
func (*Custom) SetDescription ¶
func (*Custom) SetFillColour ¶
func (*Custom) SetLength ¶
func (c *Custom) SetLength(length Expression)
func (*Custom) SetLengthUnit ¶
func (c *Custom) SetLengthUnit(lengthUnit LengthUnit)
func (*Custom) SetStrokeColour ¶
func (*Custom) StrokeColour ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func NewDecoderWithBounds ¶
func (*Decoder) Bits ¶
func (d *Decoder) Bits(length Expression, unit LengthUnit) (int64, error)
Bits returns the number of bits this length represents.
func (*Decoder) Bytes ¶
func (d *Decoder) Bytes(length Expression, unit LengthUnit) (int64, error)
Bytes returns the number of bytes this length represents. If the unit is in bits, it rounds up or down.
func (*Decoder) Decode ¶
Decode decodes the input using the given grammar, returning a Value for as much as could be parsed as well as the first error encountered
func (*Decoder) ParentBounds ¶
func (d *Decoder) ParentBounds() *ElementBounds
type Element ¶
type Element interface { ElementId Reader Lengthable Repeatable Updatable Derivable Formatter }
type ElementBounds ¶
type ElementBounds struct { Element Element Start int64 // Absolute byte offset of the start of these bounds End int64 // Absolute byte offset of the end of these bounds }
func (*ElementBounds) Length ¶
func (bounds *ElementBounds) Length() int64
func (*ElementBounds) String ¶
func (bounds *ElementBounds) String() string
type Expression ¶
func NewExpression ¶
func NewExpression(expr string) Expression
type FixedBinaryValue ¶
type FixedBinaryValue struct { Xml *XmlFixedValue // contains filtered or unexported fields }
type FixedStringValue ¶
type FixedStringValue struct { Xml *XmlFixedValue // contains filtered or unexported fields }
type FixedValue ¶
type FixedValue struct { Xml *XmlFixedValue // contains filtered or unexported fields }
TODO FixedValue is for what? Numbers? Rename to FixedNumberValue
type Grammar ¶
type Grammar struct { Xml *XmlGrammar Base Repeats Author string Ext string Email string Complete Bool Uti string Start *Structure Scripts []*Script Elements []Element }
func (*Grammar) DeriveFrom ¶
func (*Grammar) Description ¶
func (*Grammar) Length ¶
func (g *Grammar) Length() Expression
func (*Grammar) LengthUnit ¶
func (g *Grammar) LengthUnit() LengthUnit
func (*Grammar) RepeatMax ¶
func (g *Grammar) RepeatMax() Expression
func (*Grammar) RepeatMin ¶
func (g *Grammar) RepeatMin() Expression
func (*Grammar) SetDescription ¶
func (*Grammar) SetRepeatMax ¶
func (g *Grammar) SetRepeatMax(repeatMax Expression)
func (*Grammar) SetRepeatMin ¶
func (g *Grammar) SetRepeatMin(repeatMin Expression)
type GrammarRef ¶
type GrammarRef struct { Xml *XmlGrammarRef Base Repeats // contains filtered or unexported fields }
func (*GrammarRef) DeriveFrom ¶
func (g *GrammarRef) DeriveFrom(element Element) error
func (*GrammarRef) Description ¶
func (g *GrammarRef) Description() string
func (*GrammarRef) Disabled ¶
func (g *GrammarRef) Disabled() Bool
func (*GrammarRef) ElemType ¶
func (g *GrammarRef) ElemType() string
func (*GrammarRef) Filename ¶
func (g *GrammarRef) Filename() string
func (*GrammarRef) Grammar ¶
func (g *GrammarRef) Grammar() *Grammar
func (*GrammarRef) Id ¶
func (g *GrammarRef) Id() int
func (*GrammarRef) Length ¶
func (g *GrammarRef) Length() Expression
func (*GrammarRef) LengthUnit ¶
func (g *GrammarRef) LengthUnit() LengthUnit
func (*GrammarRef) Name ¶
func (g *GrammarRef) Name() string
func (*GrammarRef) RepeatMax ¶
func (g *GrammarRef) RepeatMax() Expression
func (*GrammarRef) RepeatMin ¶
func (g *GrammarRef) RepeatMin() Expression
func (*GrammarRef) SetDescription ¶
func (g *GrammarRef) SetDescription(description string)
func (*GrammarRef) SetDisabled ¶
func (g *GrammarRef) SetDisabled(disabled Bool)
func (*GrammarRef) SetFilename ¶
func (g *GrammarRef) SetFilename(filename string)
func (*GrammarRef) SetGrammar ¶
func (g *GrammarRef) SetGrammar(grammar *Grammar)
func (*GrammarRef) SetId ¶
func (g *GrammarRef) SetId(id int)
func (*GrammarRef) SetName ¶
func (g *GrammarRef) SetName(name string)
func (*GrammarRef) SetRepeatMax ¶
func (g *GrammarRef) SetRepeatMax(repeatMax Expression)
func (*GrammarRef) SetRepeatMin ¶
func (g *GrammarRef) SetRepeatMin(repeatMin Expression)
func (*GrammarRef) SetUti ¶
func (g *GrammarRef) SetUti(uti string)
func (*GrammarRef) Uti ¶
func (g *GrammarRef) Uti() string
type LengthUnit ¶
type LengthUnit int
const ( UnknownLengthUnit LengthUnit = iota BitLengthUnit ByteLengthUnit )
type Lengthable ¶
type Lengthable interface { Length() Expression LengthUnit() LengthUnit }
type Number ¶
type Number struct { Xml *XmlNumber Base Repeats Colourful Type string // TODO Convert to Type // contains filtered or unexported fields }
func (*Number) DeriveFrom ¶
func (*Number) Description ¶
func (*Number) FillColour ¶
func (*Number) Length ¶
func (n *Number) Length() Expression
func (*Number) LengthUnit ¶
func (n *Number) LengthUnit() LengthUnit
func (*Number) RepeatMax ¶
func (n *Number) RepeatMax() Expression
func (*Number) RepeatMin ¶
func (n *Number) RepeatMin() Expression
func (*Number) SetDescription ¶
func (*Number) SetDisplay ¶
func (*Number) SetFillColour ¶
func (*Number) SetLength ¶
func (n *Number) SetLength(length Expression)
func (*Number) SetLengthUnit ¶
func (n *Number) SetLengthUnit(lengthUnit LengthUnit)
func (*Number) SetMustMatch ¶
func (*Number) SetRepeatMax ¶
func (n *Number) SetRepeatMax(repeatMax Expression)
func (*Number) SetRepeatMin ¶
func (n *Number) SetRepeatMin(repeatMin Expression)
func (*Number) SetStrokeColour ¶
func (*Number) SetValueExpression ¶
func (*Number) SetValues ¶
func (n *Number) SetValues(values []*FixedValue)
func (*Number) StrokeColour ¶
func (*Number) ValueExpression ¶
func (*Number) Values ¶
func (n *Number) Values() []*FixedValue
type Offset ¶
type Offset struct { Xml *XmlOffset Base Repeats Colourful // contains filtered or unexported fields }
TODO Support parsing the Offsets
func (*Offset) Additional ¶
func (*Offset) DeriveFrom ¶
func (*Offset) Description ¶
func (*Offset) FillColour ¶
func (*Offset) FollowNullReference ¶
func (*Offset) Length ¶
func (o *Offset) Length() Expression
func (*Offset) LengthUnit ¶
func (o *Offset) LengthUnit() LengthUnit
func (*Offset) ReferencedSize ¶
func (*Offset) References ¶
func (*Offset) RelativeTo ¶
func (*Offset) RepeatMax ¶
func (o *Offset) RepeatMax() Expression
func (*Offset) RepeatMin ¶
func (o *Offset) RepeatMin() Expression
func (*Offset) SetAdditional ¶
func (*Offset) SetDescription ¶
func (*Offset) SetDisplay ¶
func (*Offset) SetFillColour ¶
func (*Offset) SetFollowNullReference ¶
func (*Offset) SetLength ¶
func (o *Offset) SetLength(length Expression)
func (*Offset) SetLengthUnit ¶
func (o *Offset) SetLengthUnit(lengthUnit LengthUnit)
func (*Offset) SetReferencedSize ¶
func (*Offset) SetReferences ¶
func (*Offset) SetRelativeTo ¶
func (*Offset) SetRepeatMax ¶
func (o *Offset) SetRepeatMax(repeatMax Expression)
func (*Offset) SetRepeatMin ¶
func (o *Offset) SetRepeatMin(repeatMin Expression)
func (*Offset) SetStrokeColour ¶
func (*Offset) StrokeColour ¶
type Padding ¶
type Padding struct {
Base
}
Padding is a pseudo Element created to represent unspecified regions in a file.
func (*Padding) DeriveFrom ¶
func (*Padding) Length ¶
func (*Padding) Length() Expression
func (*Padding) LengthUnit ¶
func (*Padding) LengthUnit() LengthUnit
func (*Padding) RepeatMax ¶
func (*Padding) RepeatMax() Expression
func (*Padding) RepeatMin ¶
func (*Padding) RepeatMin() Expression
type Reader ¶
type Reader interface { // Read from file and return a Value. // The Read method must leave the file offset at Value.Offset + Value.Len // TODO Enforce this! // Read should return what has been parsed, and any error encountered. // If no bytes could be read, then <nil, io.EOF> is returned. Read(decoder *Decoder) (*Value, error) }
type Repeatable ¶
type Repeatable interface { RepeatMin() Expression RepeatMax() Expression }
type Script ¶
type Script struct { Xml *XmlScriptElement Base Repeats XmlScript *XmlScript // contains filtered or unexported fields }
func (*Script) DeriveFrom ¶
func (*Script) Description ¶
func (*Script) Length ¶
func (s *Script) Length() Expression
func (*Script) LengthUnit ¶
func (s *Script) LengthUnit() LengthUnit
func (*Script) RepeatMax ¶
func (s *Script) RepeatMax() Expression
func (*Script) RepeatMin ¶
func (s *Script) RepeatMin() Expression
func (*Script) SetDescription ¶
func (*Script) SetLanguage ¶
func (*Script) SetRepeatMax ¶
func (s *Script) SetRepeatMax(repeatMax Expression)
func (*Script) SetRepeatMin ¶
func (s *Script) SetRepeatMin(repeatMin Expression)
type StackPrinter ¶
type StackPrinter []ElementBounds
func (StackPrinter) String ¶
func (stack StackPrinter) String() string
type String ¶
type String struct { Xml *XmlString Base Repeats Colourful // contains filtered or unexported fields }
func (*String) DeriveFrom ¶
func (*String) Description ¶
func (*String) FillColour ¶
func (*String) Length ¶
func (s *String) Length() Expression
func (*String) LengthUnit ¶
func (s *String) LengthUnit() LengthUnit
func (*String) RepeatMax ¶
func (s *String) RepeatMax() Expression
func (*String) RepeatMin ¶
func (s *String) RepeatMin() Expression
func (*String) SetDelimiter ¶
func (*String) SetDescription ¶
func (*String) SetEncoding ¶
func (*String) SetFillColour ¶
func (*String) SetLength ¶
func (s *String) SetLength(length Expression)
func (*String) SetLengthUnit ¶
func (s *String) SetLengthUnit(lengthUnit LengthUnit)
func (*String) SetMustMatch ¶
func (*String) SetRepeatMax ¶
func (s *String) SetRepeatMax(repeatMax Expression)
func (*String) SetRepeatMin ¶
func (s *String) SetRepeatMin(repeatMin Expression)
func (*String) SetStrokeColour ¶
func (*String) SetValues ¶
func (s *String) SetValues(values []*FixedStringValue)
func (*String) StrokeColour ¶
func (*String) Values ¶
func (s *String) Values() []*FixedStringValue
type StringExpression ¶
type StringExpression string
StringExpression needs to be evaluated
func (StringExpression) String ¶
func (e StringExpression) String() string
type StructRef ¶
type StructRef struct { Xml *XmlStructRef Base Repeats Colourful // contains filtered or unexported fields }
func (*StructRef) DeriveFrom ¶
func (*StructRef) Description ¶
func (*StructRef) FillColour ¶
func (*StructRef) Length ¶
func (s *StructRef) Length() Expression
func (*StructRef) LengthUnit ¶
func (s *StructRef) LengthUnit() LengthUnit
func (*StructRef) RepeatMax ¶
func (s *StructRef) RepeatMax() Expression
func (*StructRef) RepeatMin ¶
func (s *StructRef) RepeatMin() Expression
func (*StructRef) SetDescription ¶
func (*StructRef) SetDisabled ¶
func (*StructRef) SetFillColour ¶
func (*StructRef) SetRepeatMax ¶
func (s *StructRef) SetRepeatMax(repeatMax Expression)
func (*StructRef) SetRepeatMin ¶
func (s *StructRef) SetRepeatMin(repeatMin Expression)
func (*StructRef) SetStrokeColour ¶
func (*StructRef) SetStructure ¶
func (*StructRef) StrokeColour ¶
type Structure ¶
type Structure struct { Xml *XmlStructure Base Repeats Colourful // contains filtered or unexported fields }
func (*Structure) DeriveFrom ¶
func (*Structure) Description ¶
func (*Structure) ElementByName ¶
ElementByName returns a child element with this name, or nil
func (*Structure) FillColour ¶
func (*Structure) Length ¶
func (s *Structure) Length() Expression
func (*Structure) LengthOffset ¶
func (s *Structure) LengthOffset() Expression
func (*Structure) LengthUnit ¶
func (s *Structure) LengthUnit() LengthUnit
func (*Structure) RepeatMax ¶
func (s *Structure) RepeatMax() Expression
func (*Structure) RepeatMin ¶
func (s *Structure) RepeatMin() Expression
func (*Structure) SetDescription ¶
func (*Structure) SetDisplay ¶
func (*Structure) SetElements ¶
func (*Structure) SetEncoding ¶
func (*Structure) SetFillColour ¶
func (*Structure) SetLength ¶
func (s *Structure) SetLength(length Expression)
func (*Structure) SetLengthOffset ¶
func (s *Structure) SetLengthOffset(lengthOffset Expression)
func (*Structure) SetLengthUnit ¶
func (s *Structure) SetLengthUnit(lengthUnit LengthUnit)
func (*Structure) SetRepeatMax ¶
func (s *Structure) SetRepeatMax(repeatMax Expression)
func (*Structure) SetRepeatMin ¶
func (s *Structure) SetRepeatMin(repeatMin Expression)
func (*Structure) SetStrokeColour ¶
func (*Structure) StrokeColour ¶
type Transformable ¶
type Transformable interface {
// contains filtered or unexported methods
}
TODO Rename to TransformToElement or similar
type Ufwb ¶
type Value ¶
type Value struct { Offset int64 // In bytes from the beginning of the file Len int64 // In bytes Element Element Extra interface{} // Extra info defined by the Element Children []*Value ByteOrder binary.ByteOrder // Only used for Number, TODO, and TODO. Why have this? }
Value represents one of the parsed elements in the file. It doesn't contain the element, just the offset where it starts, and which element it is.
func (*Value) Description ¶
type WalkFunc ¶
TODO Move Errors out of this API, we shouldn't expose that, instead return a single error
type XmlBinary ¶
type XmlBinary struct { XMLName xml.Name `xml:"binary"` XmlIdName XmlRepeats Length string `xml:"length,attr,omitempty" ufwb:"ref"` LengthUnit string `xml:"lengthunit,attr,omitempty" ufwb:"lengthunit"` // "bit" MustMatch string `xml:"mustmatch,attr,omitempty" ufwb:"bool"` Unused string `xml:"unused,attr,omitempty" ufwb:"bool"` Disabled string `xml:"disabled,attr,omitempty" ufwb:"bool"` FillColour string `xml:"fillcolor,attr,omitempty" ufwb:"colour"` StrokeColour string `xml:"strokecolor,attr,omitempty" ufwb:"colour"` Values []*XmlFixedValue `xml:"fixedvalue,omitempty"` }
func (*XmlBinary) UnmarshalXML ¶
type XmlCustom ¶
type XmlCustom struct { XMLName xml.Name `xml:"custom"` XmlIdName Length string `xml:"length,attr,omitempty" ufwb:"ref"` LengthUnit string `xml:"lengthunit,attr,omitempty" ufwb:"lengthunit"` Script string `xml:"script,attr,omitempty" ufwb:"id"` FillColour string `xml:"fillcolor,attr,omitempty" ufwb:"colour"` StrokeColour string `xml:"strokecolor,attr,omitempty" ufwb:"colour"` }
type XmlElement ¶
type XmlElement interface { Transformable }
TODO Ensure all elements can be disabled, and perhaps move IdName into XmlElement
type XmlFixedValue ¶
type XmlFixedValues ¶
type XmlFixedValues struct { XMLName xml.Name `xml:"fixedvalues"` Values []*XmlFixedValue `xml:"fixedvalue,omitempty"` }
type XmlGrammar ¶
type XmlGrammar struct { XMLName xml.Name `xml:"grammar"` XmlIdName Author string `xml:"author,attr,omitempty"` Ext string `xml:"fileextension,attr,omitempty"` Email string `xml:"email,attr,omitempty"` Complete string `xml:"complete,attr,omitempty" ufwb:"bool"` Uti string `xml:"uti,attr,omitempty"` Start string `xml:"start,attr,omitempty" ufwb:"id"` Scripts XmlScripts `xml:"scripts"` Structures []*XmlStructure `xml:"structure,omitempty"` }
type XmlGrammarRef ¶
type XmlNumber ¶
type XmlNumber struct { XMLName xml.Name `xml:"number"` XmlIdName XmlRepeats Type string `xml:"type,attr,omitempty" ufwb:"number-type"` Length string `xml:"length,attr,omitempty" ufwb:"ref"` LengthUnit string `xml:"lengthunit,attr,omitempty" ufwb:"lengthunit"` // "", "bit" (default "byte") Endian string `xml:"endian,attr,omitempty" ufwb:"endian"` // "", "big", "little", "dynamic" Signed string `xml:"signed,attr,omitempty" ufwb:"bool"` // "", "yes", "no" MustMatch string `xml:"mustmatch,attr,omitempty" ufwb:"bool"` ValueExpression string `xml:"valueexpression,attr,omitempty"` MinVal string `xml:"minval,attr,omitempty" ufwb:"ref"` MaxVal string `xml:"maxval,attr,omitempty" ufwb:"ref"` Display string `xml:"display,attr,omitempty" ufwb:"display"` FillColour string `xml:"fillcolor,attr,omitempty" ufwb:"colour"` StrokeColour string `xml:"strokecolor,attr,omitempty" ufwb:"colour"` Disabled string `xml:"disabled,attr,omitempty" ufwb:"bool"` Values []*XmlFixedValue `xml:"fixedvalue,omitempty"` Masks []*XmlMask `xml:"mask,omitempty"` }
func (*XmlNumber) UnmarshalXML ¶
type XmlOffset ¶
type XmlOffset struct { XMLName xml.Name `xml:"offset"` XmlIdName XmlRepeats Length string `xml:"length,attr,omitempty" ufwb:"ref"` LengthUnit string `xml:"lengthunit,attr,omitempty" ufwb:"lengthunit"` // "", "bit" (default "byte") Endian string `xml:"endian,attr,omitempty" ufwb:"endian"` RelativeTo string `xml:"relative-to,attr,omitempty" ufwb:"id"` FollowNullReference string `xml:"follownullreference,attr,omitempty"` References string `xml:"references,attr,omitempty" ufwb:"id"` ReferencedSize string `xml:"referenced-size,attr,omitempty" ufwb:"id"` Additional string `xml:"additional,attr,omitempty"` // "stringOffset" Display string `xml:"display,attr,omitempty" ufwb:"display"` // "", "hex", "offset" FillColour string `xml:"fillcolor,attr,omitempty" ufwb:"colour"` StrokeColour string `xml:"strokecolor,attr,omitempty" ufwb:"colour"` }
type XmlRepeats ¶
type XmlScript ¶
type XmlScript struct { XMLName xml.Name `xml:"script"` XmlIdName Type string `xml:"type,attr,omitempty"` // DataType, Grammar, Generic Language string `xml:"language,attr,omitempty" ufwb:"lang"` Source *XmlSource `xml:"source,omitempty"` // Sometimes the text is defined here, or in the child Source element (example esf.grammar) Text string `xml:",chardata"` // TODO Should this be cdata? }
func (*XmlScript) UnmarshalXML ¶
type XmlScriptElement ¶
type XmlScripts ¶
type XmlScripts []*XmlScript
func (XmlScripts) MarshalXML ¶
func (s XmlScripts) MarshalXML(e *xml.Encoder, start xml.StartElement) error
func (*XmlScripts) UnmarshalXML ¶
func (s *XmlScripts) UnmarshalXML(decoder *xml.Decoder, start xml.StartElement) error
type XmlString ¶
type XmlString struct { XMLName xml.Name `xml:"string"` XmlIdName XmlRepeats Type string `xml:"type,attr,omitempty" ufwb:"string-type"` // "zero-terminated", "fixed-length" Length string `xml:"length,attr,omitempty" ufwb:"ref"` LengthUnit string `xml:"lengthunit,attr,omitempty" ufwb:"lengthunit"` Encoding string `xml:"encoding,attr,omitempty" ufwb:"encoding"` // Should be valid encoding MustMatch string `xml:"mustmatch,attr,omitempty" ufwb:"bool"` // "yes", "no" Delimiter string `xml:"delimiter,attr,omitempty"` FillColour string `xml:"fillcolor,attr,omitempty" ufwb:"colour"` StrokeColour string `xml:"strokecolor,attr,omitempty" ufwb:"colour"` Values []*XmlFixedValue `xml:"fixedvalue,omitempty"` }
func (*XmlString) UnmarshalXML ¶
type XmlStructRef ¶
type XmlStructRef struct { XMLName xml.Name `xml:"structref"` XmlIdName XmlRepeats Structure string `xml:"structure,attr,omitempty" ufwb:"id"` Disabled string `xml:"disabled,attr,omitempty" ufwb:"bool"` FillColour string `xml:"fillcolor,attr,omitempty" ufwb:"colour"` StrokeColour string `xml:"strokecolor,attr,omitempty" ufwb:"colour"` }
type XmlStructure ¶
type XmlStructure struct { XMLName xml.Name `xml:"structure"` XmlIdName XmlRepeats Length string `xml:"length,attr,omitempty" ufwb:"ref"` LengthUnit string `xml:"lengthunit,attr,omitempty" ufwb:"lengthunit"` LengthOffset string `xml:"lengthoffset,attr,omitempty"` Endian string `xml:"endian,attr,omitempty" ufwb:"endian"` Signed string `xml:"signed,attr,omitempty" ufwb:"bool"` Extends string `xml:"extends,attr,omitempty" ufwb:"id"` Order string `xml:"order,attr,omitempty"` Encoding string `xml:"encoding,attr,omitempty" ufwb:"encoding"` Alignment string `xml:"alignment,attr,omitempty"` // ?? Floating string `xml:"floating,attr,omitempty"` // ?? ConsistsOf string `xml:"consists-of,attr,omitempty" ufwb:"id"` Repeat string `xml:"repeat,attr,omitempty" ufwb:"id"` // TODO What is this field? ValueExpression string `xml:"valueexpression,attr,omitempty"` Debug string `xml:"debug,attr,omitempty" ufwb:"bool"` Disabled string `xml:"disabled,attr,omitempty" ufwb:"bool"` Display string `xml:"display,attr,omitempty" ufwb:"display"` FillColour string `xml:"fillcolor,attr,omitempty" ufwb:"colour"` StrokeColour string `xml:"strokecolor,attr,omitempty" ufwb:"colour"` Elements []XmlElement `xml:",any"` }
func (*XmlStructure) UnmarshalXML ¶
func (s *XmlStructure) UnmarshalXML(decoder *xml.Decoder, start xml.StartElement) error
UnmarshalXML correctly unmarshals a Structure and its children. This is needed because Go's xml parser doesn't handle the multiple unknown element, that need to be kept in order.