Ejemplo n.º 1
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)
	}
}
Ejemplo n.º 2
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)
	}
}
Ejemplo n.º 3
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)
}
Ejemplo n.º 4
0
func Save(c core.Matcher, ls *persist.LoadSaver) {
	if c == nil {
		ls.SaveSmallInt(0)
		return
	}
	ls.SaveSmallInt(int(*c.(*Matcher)))
}
Ejemplo n.º 5
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)
	}
}
Ejemplo n.º 6
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)
	}
}
Ejemplo n.º 7
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)
	}
}
Ejemplo n.º 8
0
func (i *Identifier) Save(ls *persist.LoadSaver) {
	ls.SaveByte(core.Pronom)
	ls.SaveSmallInt(len(i.infos))
	for k, v := range i.infos {
		ls.SaveString(k)
		ls.SaveString(v.name)
		ls.SaveString(v.version)
		ls.SaveString(v.mimeType)
	}
	i.Base.Save(ls)
}
Ejemplo n.º 9
0
func (i *Identifier) Save(ls *persist.LoadSaver) {
	ls.SaveByte(core.MIMEInfo)
	ls.SaveSmallInt(len(i.infos))
	for k, v := range i.infos {
		ls.SaveString(k)
		ls.SaveString(v.comment)
		ls.SaveBool(v.text)
		ls.SaveInts(v.globWeights)
		ls.SaveInts(v.magicWeights)
	}
	i.Base.Save(ls)
}
Ejemplo n.º 10
0
func saveTests(ls *persist.LoadSaver, tts []*testTree) {
	ls.SaveSmallInt(len(tts))
	for _, tt := range tts {
		ls.SaveSmallInt(len(tt.complete))
		for _, kfid := range tt.complete {
			ls.SaveSmallInt(kfid[0])
			ls.SaveSmallInt(kfid[1])
		}
		ls.SaveSmallInt(len(tt.incomplete))
		for _, fu := range tt.incomplete {
			ls.SaveSmallInt(fu.kf[0])
			ls.SaveSmallInt(fu.kf[1])
			ls.SaveBool(fu.l)
			ls.SaveBool(fu.r)
		}
		ls.SaveInt(tt.maxLeftDistance)
		ls.SaveInt(tt.maxRightDistance)
		saveTestNodes(ls, tt.left)
		saveTestNodes(ls, tt.right)
	}
}
Ejemplo n.º 11
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)
		}
	}
}
Ejemplo n.º 12
0
func saveKeyFrames(ls *persist.LoadSaver, kfs [][]keyFrame) {
	ls.SaveSmallInt(len(kfs))
	for _, v := range kfs {
		ls.SaveSmallInt(len(v))
		for _, kf := range v {
			ls.SaveByte(byte(kf.typ))
			ls.SaveInt(int(kf.seg.pMin))
			ls.SaveInt(int(kf.seg.pMax))
			ls.SaveSmallInt(kf.seg.lMin)
			ls.SaveSmallInt(kf.seg.lMax)
			ls.SaveInt(int(kf.key.pMin))
			ls.SaveInt(int(kf.key.pMax))
			ls.SaveSmallInt(kf.key.lMin)
			ls.SaveSmallInt(kf.key.lMax)
		}
	}

}
Ejemplo n.º 13
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)
}
Ejemplo n.º 14
0
func Save(c core.Matcher, ls *persist.LoadSaver) {
	if c == nil {
		ls.SaveBool(false)
		return
	}
	m := c.(*Matcher)
	ls.SaveBool(true)
	ls.SaveSmallInt(len(m.extensions))
	for k, v := range m.extensions {
		ls.SaveString(k)
		ls.SaveSmallInt(len(v))
		for _, w := range v {
			ls.SaveSmallInt(int(w))
		}
	}
	ls.SaveStrings(m.globs)
	ls.SaveSmallInt(len(m.globIdx))
	for _, v := range m.globIdx {
		ls.SaveInts(v)
	}
}
Ejemplo n.º 15
0
func (ss *seqSet) save(ls *persist.LoadSaver) {
	ls.SaveSmallInt(len(ss.set))
	for _, v := range ss.set {
		ls.SaveBigInts(v.MaxOffsets)
		ls.SaveSmallInt(len(v.Choices))
		for _, w := range v.Choices {
			ls.SaveSmallInt(len(w))
			for _, x := range w {
				ls.SaveBytes(x)
			}
		}
	}
	ls.SaveInts(ss.testTreeIndex)
}
Ejemplo n.º 16
0
func (s *Set) Save(ls *persist.LoadSaver) {
	ls.SaveInts(s.idx)
	ls.SaveSmallInt(len(s.lists))
	for _, v := range s.lists {
		ls.SaveSmallInt(len(v))
		for _, w := range v {
			ls.SaveInts(w)
		}
	}
	ls.SaveSmallInt(len(s.maxOffsets))
	for _, v := range s.maxOffsets {
		ls.SaveInt(v[0])
		ls.SaveInt(v[1])
	}
}