예제 #1
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)
}
예제 #2
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)
}
예제 #3
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)
}
예제 #4
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)
	}
}
예제 #5
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)
	}
}
예제 #6
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)
	}
}