Beispiel #1
0
func loadWildMin(ls *persist.LoadSaver) Frame {
	return WildMin{
		OffType(ls.LoadByte()),
		ls.LoadInt(),
		patterns.Load(ls),
	}
}
Beispiel #2
0
func Save(c core.Matcher, ls *persist.LoadSaver) {
	if c == nil {
		ls.SaveSmallInt(0)
		return
	}
	ls.SaveSmallInt(int(*c.(*Matcher)))
}
Beispiel #3
0
// Save persists the pattern.
func (c Choice) Save(ls *persist.LoadSaver) {
	ls.SaveByte(choiceLoader)
	ls.SaveSmallInt(len(c))
	for _, pat := range c {
		pat.Save(ls)
	}
}
Beispiel #4
0
// Save persists the pattern.
func (l List) Save(ls *persist.LoadSaver) {
	ls.SaveByte(listLoader)
	ls.SaveSmallInt(len(l))
	for _, pat := range l {
		pat.Save(ls)
	}
}
Beispiel #5
0
func loadFixed(ls *persist.LoadSaver) Frame {
	return Fixed{
		OffType(ls.LoadByte()),
		ls.LoadInt(),
		patterns.Load(ls),
	}
}
Beispiel #6
0
func (fs *frameSet) save(ls *persist.LoadSaver) {
	ls.SaveSmallInt(len(fs.set))
	for _, f := range fs.set {
		f.Save(ls)
	}
	ls.SaveInts(fs.testTreeIndex)
}
Beispiel #7
0
func loadBMH(ls *persist.LoadSaver) Pattern {
	bmh := &BMHSequence{}
	bmh.Seq = Sequence(ls.LoadBytes())
	for i := range bmh.Shift {
		bmh.Shift[i] = ls.LoadSmallInt()
	}
	return bmh
}
Beispiel #8
0
func saveTestNodes(ls *persist.LoadSaver, tns []*testNode) {
	ls.SaveSmallInt(len(tns))
	for _, n := range tns {
		n.Frame.Save(ls)
		ls.SaveInts(n.success)
		saveTestNodes(ls, n.tests)
	}
}
Beispiel #9
0
func loadRBMH(ls *persist.LoadSaver) Pattern {
	rbmh := &RBMHSequence{}
	rbmh.Seq = Sequence(ls.LoadBytes())
	for i := range rbmh.Shift {
		rbmh.Shift[i] = ls.LoadSmallInt()
	}
	return rbmh
}
Beispiel #10
0
func loadList(ls *persist.LoadSaver) Pattern {
	le := ls.LoadSmallInt()
	list := make(List, le)
	for i := range list {
		list[i] = Load(ls)
	}
	return list
}
Beispiel #11
0
func loadChoice(ls *persist.LoadSaver) Pattern {
	l := ls.LoadSmallInt()
	choices := make(Choice, l)
	for i := range choices {
		choices[i] = Load(ls)
	}
	return choices
}
Beispiel #12
0
func (i *Identifier) Save(ls *persist.LoadSaver) {
	ls.SaveByte(core.LOC)
	ls.SaveSmallInt(len(i.infos))
	for k, v := range i.infos {
		ls.SaveString(k)
		ls.SaveString(v.name)
		ls.SaveString(v.longName)
		ls.SaveString(v.mimeType)
	}
	i.Base.Save(ls)
}
Beispiel #13
0
// Load loads the Pattern, choosing the correct Loader by the leading id byte.
func Load(ls *persist.LoadSaver) Pattern {
	id := ls.LoadByte()
	l := loaders[int(id)]
	if l == nil {
		if ls.Err == nil {
			ls.Err = errors.New("bad pattern loader")
		}
		return nil
	}
	return l(ls)
}
Beispiel #14
0
// LoadIdentifier applies the appropriate IdentifierLoader to load an identifier.
func LoadIdentifier(ls *persist.LoadSaver) Identifier {
	id := ls.LoadByte()
	l := loaders[int(id)]
	if l == nil {
		if ls.Err == nil {
			ls.Err = errors.New("bad identifier loader")
		}
		return nil
	}
	return l(ls)
}
Beispiel #15
0
func Load(ls *persist.LoadSaver) core.Matcher {
	if !ls.LoadBool() {
		return nil
	}
	ret := make(Matcher, ls.LoadTinyUInt())
	for i := range ret {
		ret[i] = loadCM(ls)
		ret[i].ctype = ctypes[ret[i].conType]
		ret[i].entryBufs = siegreader.New()
	}
	return ret
}
Beispiel #16
0
func Save(c core.Matcher, ls *persist.LoadSaver) {
	if c == nil {
		ls.SaveSmallInt(0)
		return
	}
	m := c.(Matcher)
	ls.SaveSmallInt(len(m))
	for k, v := range m {
		ls.SaveString(k)
		ls.SaveSmallInt(len(v))
		for _, w := range v {
			ls.SaveSmallInt(w)
		}
	}
}
Beispiel #17
0
func loadTestNodes(ls *persist.LoadSaver) []*testNode {
	l := ls.LoadSmallInt()
	if l == 0 {
		return nil
	}
	ret := make([]*testNode, l)
	for i := range ret {
		ret[i] = &testNode{
			frames.Load(ls),
			ls.LoadInts(),
			loadTestNodes(ls),
		}
	}
	return ret
}
Beispiel #18
0
func Load(ls *persist.LoadSaver) core.Identifier {
	i := &Identifier{}
	i.infos = make(map[string]formatInfo)
	le := ls.LoadSmallInt()
	for j := 0; j < le; j++ {
		i.infos[ls.LoadString()] = formatInfo{
			ls.LoadString(),
			ls.LoadBool(),
			ls.LoadInts(),
			ls.LoadInts(),
		}
	}
	i.Base = identifier.Load(ls)
	return i
}
Beispiel #19
0
func (c *ContainerMatcher) save(ls *persist.LoadSaver) {
	ls.SaveInts(c.startIndexes)
	ls.SaveTinyUInt(int(c.conType))
	saveCTests(ls, c.nameCTest)
	ls.SaveInts(c.parts)
	c.priorities.Save(ls)
	ls.SaveString(c.extension)
}
Beispiel #20
0
func Load(ls *persist.LoadSaver) core.Matcher {
	le := ls.LoadSmallInt()
	if le == 0 {
		return nil
	}
	ret := make(Matcher)
	for i := 0; i < le; i++ {
		k := [2]string{ls.LoadString(), ls.LoadString()}
		r := make([]int, ls.LoadSmallInt())
		for j := range r {
			r[j] = ls.LoadSmallInt()
		}
		ret[k] = r
	}
	return ret
}
Beispiel #21
0
func saveCTests(ls *persist.LoadSaver, ct map[string]*cTest) {
	ls.SaveSmallInt(len(ct))
	for k, v := range ct {
		ls.SaveString(k)
		ls.SaveInts(v.satisfied)
		ls.SaveInts(v.unsatisfied)
		bytematcher.Save(v.bm, ls)
	}
}
Beispiel #22
0
func loadCM(ls *persist.LoadSaver) *ContainerMatcher {
	return &ContainerMatcher{
		startIndexes: ls.LoadInts(),
		conType:      containerType(ls.LoadTinyUInt()),
		nameCTest:    loadCTests(ls),
		parts:        ls.LoadInts(),
		priorities:   priority.Load(ls),
		extension:    ls.LoadString(),
	}
}
Beispiel #23
0
func Save(c core.Matcher, ls *persist.LoadSaver) {
	if c == nil {
		ls.SaveSmallInt(0)
		return
	}
	m := c.(*Matcher)
	ls.SaveSmallInt(len(m.riffs))
	if len(m.riffs) == 0 {
		return
	}
	for k, v := range m.riffs {
		ls.SaveFourCC(k)
		ls.SaveSmallInt(len(v))
		for _, w := range v {
			ls.SaveSmallInt(w)
		}
	}
	m.priorities.Save(ls)
}
Beispiel #24
0
func (b *Base) Save(ls *persist.LoadSaver) {
	ls.SaveString(b.name)
	ls.SaveString(b.details)
	ls.SaveTinyInt(int(b.multi))
	ls.SaveBool(b.zipDefault)
	b.gids.save(ls)
	b.mids.save(ls)
	b.cids.save(ls)
	b.xids.save(ls)
	b.bids.save(ls)
	b.rids.save(ls)
	b.tids.save(ls)
}
Beispiel #25
0
// Save frame to a LoadSaver.
func (w Window) Save(ls *persist.LoadSaver) {
	ls.SaveByte(windowLoader)
	ls.SaveByte(byte(w.OffType))
	ls.SaveInt(w.MinOff)
	ls.SaveInt(w.MaxOff)
	w.Pattern.Save(ls)
}
Beispiel #26
0
// Save persists the pattern.
func (s *RBMHSequence) Save(ls *persist.LoadSaver) {
	ls.SaveByte(rbmhLoader)
	ls.SaveBytes(s.Seq)
	for _, v := range s.Shift {
		ls.SaveSmallInt(v)
	}
}
Beispiel #27
0
func Save(c core.Matcher, ls *persist.LoadSaver) {
	if c == nil {
		ls.SaveBool(false)
		return
	}
	m := c.(Matcher)
	if m.total(-1) == 0 {
		ls.SaveBool(false)
		return
	}
	ls.SaveBool(true)
	ls.SaveTinyUInt(len(m))
	for _, v := range m {
		v.save(ls)
	}
}
Beispiel #28
0
// Save persists a Matcher.
func Save(c core.Matcher, ls *persist.LoadSaver) {
	if c == nil {
		ls.SaveBool(false)
		return
	}
	b := c.(*Matcher)
	ls.SaveBool(true)
	saveKeyFrames(ls, b.keyFrames)
	saveTests(ls, b.tests)
	b.bofFrames.save(ls)
	b.eofFrames.save(ls)
	b.bofSeq.save(ls)
	b.eofSeq.save(ls)
	ls.SaveInt(b.knownBOF)
	ls.SaveInt(b.knownEOF)
	ls.SaveInt(b.maxBOF)
	ls.SaveInt(b.maxEOF)
	b.priorities.Save(ls)
}
Beispiel #29
0
func loadCTests(ls *persist.LoadSaver) map[string]*cTest {
	ret := make(map[string]*cTest)
	l := ls.LoadSmallInt()
	for i := 0; i < l; i++ {
		ret[ls.LoadString()] = &cTest{
			satisfied:   ls.LoadInts(),
			unsatisfied: ls.LoadInts(),
			bm:          bytematcher.Load(ls),
		}
	}
	return ret
}
Beispiel #30
0
func Load(ls *persist.LoadSaver) core.Matcher {
	le := ls.LoadSmallInt()
	if le == 0 {
		return nil
	}
	riffs := make(map[riff.FourCC][]int)
	for i := 0; i < le; i++ {
		k := riff.FourCC(ls.LoadFourCC())
		r := make([]int, ls.LoadSmallInt())
		for j := range r {
			r[j] = ls.LoadSmallInt()
		}
		riffs[k] = r
	}
	return &Matcher{
		riffs:      riffs,
		priorities: priority.Load(ls),
	}
}