func (n *Number) Uint(file io.ReaderAt, value *Value) (uint64, error) {
	i, err := n.int(file, value)
	if err != nil {
		return 0, err
	}
	if n.Signed() {
		return uint64(reflect.ValueOf(i).Int()), nil
	} else {
		return reflect.ValueOf(i).Uint(), nil
	}
}
Uint returns the value this file/value refers to cast to a uint64.
package ufwb
import (
	"fmt"
	"io"
	"reflect"
	"bramp.net/dsector/input"
	"bytes"
	"encoding/binary"
	log "github.com/Sirupsen/logrus"
)
var padElement = &Padding{Base: Base{"Padding", 0, "", ""}}
func (u *Ufwb) Read(d *Decoder) (*Value, error) {
	return d.read(u.Grammar)
}
func (g *Grammar) Read(d *Decoder) (*Value, error) {
	start, err := d.f.Tell()
	if err != nil {
		return nil, &validationError{e: g, err: err}
	}
	value := &Value{
		Offset:  start,
		Len:     0,
		Element: g,
	}
	elements := Elements([]Element{g.Start})
	return elements.Read(d, value, FixedOrder)
}
func isEof(err error) bool {
	if err == io.EOF {
		return true
	}
	if e, ok := err.(Eof); ok {
		return e.IsEof()
	}
	return false
}
func (elements Elements) Read(d *Decoder, value *Value, order Order) (*Value, error) {
	parent := value.Element
	start := value.Offset
	bounds := d.ParentBounds()
	bounds_remaining := bounds.End - start
	if DEBUG && bounds.Start > start {
		panic(fmt.Sprintf("Starting before bounds %d < %d", start, bounds.Start))
	}
	childrenCount := make(map[ElementId]int64)
	i := 0
	eof := false
	log.Debugf("[0x%x] Starting %s (bounds: [0x%x-0x%x], max length: %d)", start, parent.IdString(), bounds.Start, bounds.End, bounds_remaining)
	for value.Len <= bounds_remaining && i < len(elements) {
		e := elements[i]
		max, err := d.eval(e.RepeatMax())
		if err != nil {
			return nil, &validationError{e: e, err: fmt.Errorf("RepeatMax eval failed: %s", err.Error())}
		}
		if childrenCount[e] >= max {
			log.Debugf("Skipping %s found %d of %d", e.IdString(), childrenCount[e], max)
			i++
			continue
		}
		min, err := d.eval(e.RepeatMin())
		if err != nil {
			return nil, &validationError{e: e, err: fmt.Errorf("RepeatMin eval failed: %s", err.Error())}
		}
		_, err = d.f.Seek(start+value.Len, io.SeekStart)
		if err != nil {
			return nil, &validationError{e: parent, err: err}
		}
		v, err := d.read(e)
		eof = isEof(err)
		if v != nil && (err == nil || eof) {
			value.Children = append(value.Children, v)
			value.Len += v.Len
			childrenCount[v.Element]++
			if order == VariableOrder {
				log.Debugf("reset")
				i = 0
			}
		}
		if err != nil {
			switch order {
			case FixedOrder:
				if childrenCount[e] >= min {
					i++
					continue
				}
				return nil, err
			case VariableOrder:
				if i < len(elements)-1 {
					log.Debugf("[0x%x] Move on from: %s to: %s", start, elements[i].IdString(), elements[i+1].IdString())
				} else {
					log.Debugf("[0x%x] Move on from: %s to: end", start, elements[i].IdString())
				}
				i++
			default:
				return nil, &validationError{e: parent, err: fmt.Errorf("unknown order: %d", order)}
			}
		}
	}
	if parent.Length() != nil {
		log.Debugf("%s Loop %v, %v < %v, %v < %v", parent.IdString(), eof, value.Len, bounds_remaining, i, len(elements))
		if bounds_remaining > value.Len {
			log.Debugf("parent larger than children parent: %v, child: %v", bounds, value)
			padding := &Value{
				Offset:  start + value.Len,
				Len:     bounds_remaining - value.Len,
				Element: padElement,
			}
			value.Children = append(value.Children, padding)
			value.Len = bounds_remaining
			panic(fmt.Sprintf("While developing we shouldn't need to add any padding! %v", padding))
		} else if value.Len > bounds_remaining {
			panic(fmt.Sprintf("children's length is greater than the parent length, %d vs %d", value.Len, bounds_remaining))
		}
	}
	for _, e := range elements {
		min, err := d.eval(e.RepeatMin())
		if err != nil {
			return nil, &validationError{e: e, err: fmt.Errorf("RepeatMin eval failed: %s", err.Error())}
		}
		if childrenCount[e] < min {
			return nil, &validationError{e: parent, err: fmt.Errorf("child %s repeated %d times, less than %d times required", e.IdString(), childrenCount[e], min)}
		}
	}
	if eof {
		return value, io.EOF
	}
	return value, nil
}
func (s *Structure) Read(d *Decoder) (*Value, error) {
	start, err := d.f.Tell()
	if err != nil {
		return nil, &validationError{e: s, err: err}
	}
	value := &Value{
		Offset:  start,
		Element: s,
	}
	elements := Elements(s.Elements())
	return elements.Read(d, value, s.Order())
}
func (s *String) read(d *Decoder) (*Value, error) {
	start, err := d.f.Tell()
	if err != nil {
		return nil, err
	}
	end := d.ParentBounds().End
	maxLen := end - start
	var v *Value
	switch s.Typ() {
	case "zero-terminated", "delimiter-terminated":
		n, err := input.ReadUntil(d.f, s.delimiter, maxLen)
		if err != nil {
			return nil, err
		}
		v = &Value{Offset: start, Len: n, Element: s}
	case "fixed-length":
		v, err = lengthValue(d, s)
		if err != nil {
			return nil, err
		}
		if _, err = input.ReadAndDiscard(d.f, v.Len); err != nil {
			return nil, err
		}
	case "pascal":
		i, err := readInt(d.f, 1, false, binary.LittleEndian)
		if err != nil {
			return nil, err
		}
		length := int64(i.(uint8))
		if _, err = input.ReadAndDiscard(d.f, length); err != nil {
			return nil, err
		}
		v = &Value{Offset: start, Len: length + 1, Element: s}
	default:
		return nil, fmt.Errorf("unknown string type %q", s.Typ())
	}
	return v, nil
}
func (s *String) Read(d *Decoder) (*Value, error) {
	v, err := s.read(d)
	if err != nil && err != io.EOF {
		err = &validationError{e: s, err: err}
	}
	return v, err
}
func lengthValue(d *Decoder, element Element) (*Value, error) {
	start, err := d.f.Tell()
	if err != nil {
		return nil, err
	}
	length, err := d.Bytes(element.Length(), element.LengthUnit())
	if err != nil {
		return nil, err
	}
	end := d.ParentBounds().End
	maxLen := end - start
	if maxLen == 0 {
		return nil, io.EOF
	}
	if length > maxLen {
		return nil, io.ErrUnexpectedEOF
	}
	return &Value{
		Offset:  start,
		Len:     length,
		Element: element,
	}, nil
}
func (b *Binary) Read(d *Decoder) (*Value, error) {
	v, err := lengthValue(d, b)
	if err != nil {
		if err != io.EOF {
			err = &validationError{e: b, err: err}
		}
		return nil, err
	}
	bs, err := b.Bytes(d.f, v)
	if err != nil {
		return nil, &validationError{e: b, err: err}
	}
	values := b.Values()
	if len(values) > 0 && b.MustMatch().bool() {
		for _, fv := range values {
			if bytes.Equal(fv.value, bs) {
				v.Extra = fv
				return v, nil
			}
		}
		f, err := b.format(bs)
		if err != nil {
			return v, &assertationError{e: b, err: fmt.Errorf("failed to format %v: %s", bs, err)}
		}
		formatedValues, err := b.formatValues()
		if err != nil {
			return v, &assertationError{e: b, err: fmt.Errorf("failed to format values %v: %s", values, err)}
		}
		return nil, &validationError{
			e:   b,
			err: fmt.Errorf("%q does match any of the fixed values %q", f, formatedValues),
		}
	}
	return v, nil
}
func (b *Binary) Bytes(file io.ReaderAt, value *Value) ([]byte, error) {
	out := make([]byte, value.Len, value.Len)
	n, err := input.ReadFullAt(file, out, value.Offset)
	if err != nil {
		return nil, &validationError{e: b, err: err}
	}
	return out[:n], nil
}
func (n *Number) int(file io.ReaderAt, value *Value) (interface{}, error) {
	if n != value.Element {
		return 0, &assertationError{e: n, err: fmt.Errorf("reading value %v of another element", value)}
	}
	b := make([]byte, value.Len, value.Len)
	if _, err := input.ReadFullAt(file, b, value.Offset); err != nil {
		return 0, &validationError{e: n, err: err}
	}
	r := bytes.NewReader(b)
	i, err := readInt(r, value.Len, n.Signed(), value.ByteOrder)
	if err != nil && err != io.EOF {  
		return 0, &validationError{e: n, err: err}
	}
	return i, err
}
func (n *Number) Int(file io.ReaderAt, value *Value) (int64, error) {
	i, err := n.int(file, value)
	if err != nil {
		return 0, err
	}
	if n.Signed() {
		return reflect.ValueOf(i).Int(), nil
	} else {
		return int64(reflect.ValueOf(i).Uint()), nil
	}
}