-
Notifications
You must be signed in to change notification settings - Fork 19
/
filedb_gen.go
339 lines (300 loc) · 9.78 KB
/
filedb_gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
package sshego
// NOTE: THIS FILE WAS PRODUCED BY THE
// GREENPACK CODE GENERATION TOOL (github.com/glycerine/greenpack)
// DO NOT EDIT
import (
"github.com/glycerine/greenpack/msgp"
)
// DecodeMsg implements msgp.Decodable
// We treat empty fields as if we read a Nil from the wire.
func (z *Filedb) DecodeMsg(dc *msgp.Reader) (err error) {
var sawTopNil bool
if dc.IsNil() {
sawTopNil = true
err = dc.ReadNil()
if err != nil {
return
}
dc.PushAlwaysNil()
}
var field []byte
_ = field
const maxFields0zgensym_995050f2db4fcb57_1 = 1
// -- templateDecodeMsg starts here--
var totalEncodedFields0zgensym_995050f2db4fcb57_1 uint32
totalEncodedFields0zgensym_995050f2db4fcb57_1, err = dc.ReadMapHeader()
if err != nil {
return
}
encodedFieldsLeft0zgensym_995050f2db4fcb57_1 := totalEncodedFields0zgensym_995050f2db4fcb57_1
missingFieldsLeft0zgensym_995050f2db4fcb57_1 := maxFields0zgensym_995050f2db4fcb57_1 - totalEncodedFields0zgensym_995050f2db4fcb57_1
var nextMiss0zgensym_995050f2db4fcb57_1 int32 = -1
var found0zgensym_995050f2db4fcb57_1 [maxFields0zgensym_995050f2db4fcb57_1]bool
var curField0zgensym_995050f2db4fcb57_1 string
doneWithStruct0zgensym_995050f2db4fcb57_1:
// First fill all the encoded fields, then
// treat the remaining, missing fields, as Nil.
for encodedFieldsLeft0zgensym_995050f2db4fcb57_1 > 0 || missingFieldsLeft0zgensym_995050f2db4fcb57_1 > 0 {
//fmt.Printf("encodedFieldsLeft: %v, missingFieldsLeft: %v, found: '%v', fields: '%#v'\n", encodedFieldsLeft0zgensym_995050f2db4fcb57_1, missingFieldsLeft0zgensym_995050f2db4fcb57_1, msgp.ShowFound(found0zgensym_995050f2db4fcb57_1[:]), decodeMsgFieldOrder0zgensym_995050f2db4fcb57_1)
if encodedFieldsLeft0zgensym_995050f2db4fcb57_1 > 0 {
encodedFieldsLeft0zgensym_995050f2db4fcb57_1--
field, err = dc.ReadMapKeyPtr()
if err != nil {
return
}
curField0zgensym_995050f2db4fcb57_1 = msgp.UnsafeString(field)
} else {
//missing fields need handling
if nextMiss0zgensym_995050f2db4fcb57_1 < 0 {
// tell the reader to only give us Nils
// until further notice.
dc.PushAlwaysNil()
nextMiss0zgensym_995050f2db4fcb57_1 = 0
}
for nextMiss0zgensym_995050f2db4fcb57_1 < maxFields0zgensym_995050f2db4fcb57_1 && (found0zgensym_995050f2db4fcb57_1[nextMiss0zgensym_995050f2db4fcb57_1] || decodeMsgFieldSkip0zgensym_995050f2db4fcb57_1[nextMiss0zgensym_995050f2db4fcb57_1]) {
nextMiss0zgensym_995050f2db4fcb57_1++
}
if nextMiss0zgensym_995050f2db4fcb57_1 == maxFields0zgensym_995050f2db4fcb57_1 {
// filled all the empty fields!
break doneWithStruct0zgensym_995050f2db4fcb57_1
}
missingFieldsLeft0zgensym_995050f2db4fcb57_1--
curField0zgensym_995050f2db4fcb57_1 = decodeMsgFieldOrder0zgensym_995050f2db4fcb57_1[nextMiss0zgensym_995050f2db4fcb57_1]
}
//fmt.Printf("switching on curField: '%v'\n", curField0zgensym_995050f2db4fcb57_1)
switch curField0zgensym_995050f2db4fcb57_1 {
// -- templateDecodeMsg ends here --
case "HostDb_zid00_ptr":
found0zgensym_995050f2db4fcb57_1[0] = true
if dc.IsNil() {
err = dc.ReadNil()
if err != nil {
return
}
if z.HostDb != nil {
dc.PushAlwaysNil()
err = z.HostDb.DecodeMsg(dc)
if err != nil {
return
}
dc.PopAlwaysNil()
}
} else {
// not Nil, we have something to read
if z.HostDb == nil {
z.HostDb = new(HostDb)
}
err = z.HostDb.DecodeMsg(dc)
if err != nil {
return
}
}
default:
err = dc.Skip()
if err != nil {
return
}
}
}
if nextMiss0zgensym_995050f2db4fcb57_1 != -1 {
dc.PopAlwaysNil()
}
if sawTopNil {
dc.PopAlwaysNil()
}
if p, ok := interface{}(z).(msgp.PostLoad); ok {
p.PostLoadHook()
}
return
}
// fields of Filedb
var decodeMsgFieldOrder0zgensym_995050f2db4fcb57_1 = []string{"HostDb_zid00_ptr"}
var decodeMsgFieldSkip0zgensym_995050f2db4fcb57_1 = []bool{false}
// fieldsNotEmpty supports omitempty tags
func (z *Filedb) fieldsNotEmpty(isempty []bool) uint32 {
if len(isempty) == 0 {
return 1
}
var fieldsInUse uint32 = 1
isempty[0] = (z.HostDb == nil) // pointer, omitempty
if isempty[0] {
fieldsInUse--
}
return fieldsInUse
}
// EncodeMsg implements msgp.Encodable
func (z *Filedb) EncodeMsg(en *msgp.Writer) (err error) {
if p, ok := interface{}(z).(msgp.PreSave); ok {
p.PreSaveHook()
}
// honor the omitempty tags
var empty_zgensym_995050f2db4fcb57_2 [1]bool
fieldsInUse_zgensym_995050f2db4fcb57_3 := z.fieldsNotEmpty(empty_zgensym_995050f2db4fcb57_2[:])
// map header
err = en.WriteMapHeader(fieldsInUse_zgensym_995050f2db4fcb57_3)
if err != nil {
return err
}
if !empty_zgensym_995050f2db4fcb57_2[0] {
// write "HostDb_zid00_ptr"
err = en.Append(0xb0, 0x48, 0x6f, 0x73, 0x74, 0x44, 0x62, 0x5f, 0x7a, 0x69, 0x64, 0x30, 0x30, 0x5f, 0x70, 0x74, 0x72)
if err != nil {
return err
}
if z.HostDb == nil {
err = en.WriteNil()
if err != nil {
return
}
} else {
err = z.HostDb.EncodeMsg(en)
if err != nil {
return
}
}
}
return
}
// MarshalMsg implements msgp.Marshaler
func (z *Filedb) MarshalMsg(b []byte) (o []byte, err error) {
if p, ok := interface{}(z).(msgp.PreSave); ok {
p.PreSaveHook()
}
o = msgp.Require(b, z.Msgsize())
// honor the omitempty tags
var empty [1]bool
fieldsInUse := z.fieldsNotEmpty(empty[:])
o = msgp.AppendMapHeader(o, fieldsInUse)
if !empty[0] {
// string "HostDb_zid00_ptr"
o = append(o, 0xb0, 0x48, 0x6f, 0x73, 0x74, 0x44, 0x62, 0x5f, 0x7a, 0x69, 0x64, 0x30, 0x30, 0x5f, 0x70, 0x74, 0x72)
if z.HostDb == nil {
o = msgp.AppendNil(o)
} else {
o, err = z.HostDb.MarshalMsg(o)
if err != nil {
return
}
}
}
return
}
// UnmarshalMsg implements msgp.Unmarshaler
func (z *Filedb) UnmarshalMsg(bts []byte) (o []byte, err error) {
return z.UnmarshalMsgWithCfg(bts, nil)
}
func (z *Filedb) UnmarshalMsgWithCfg(bts []byte, cfg *msgp.RuntimeConfig) (o []byte, err error) {
var nbs msgp.NilBitsStack
nbs.Init(cfg)
var sawTopNil bool
if msgp.IsNil(bts) {
sawTopNil = true
bts = nbs.PushAlwaysNil(bts[1:])
}
var field []byte
_ = field
const maxFields4zgensym_995050f2db4fcb57_5 = 1
// -- templateUnmarshalMsg starts here--
var totalEncodedFields4zgensym_995050f2db4fcb57_5 uint32
if !nbs.AlwaysNil {
totalEncodedFields4zgensym_995050f2db4fcb57_5, bts, err = nbs.ReadMapHeaderBytes(bts)
if err != nil {
return
}
}
encodedFieldsLeft4zgensym_995050f2db4fcb57_5 := totalEncodedFields4zgensym_995050f2db4fcb57_5
missingFieldsLeft4zgensym_995050f2db4fcb57_5 := maxFields4zgensym_995050f2db4fcb57_5 - totalEncodedFields4zgensym_995050f2db4fcb57_5
var nextMiss4zgensym_995050f2db4fcb57_5 int32 = -1
var found4zgensym_995050f2db4fcb57_5 [maxFields4zgensym_995050f2db4fcb57_5]bool
var curField4zgensym_995050f2db4fcb57_5 string
doneWithStruct4zgensym_995050f2db4fcb57_5:
// First fill all the encoded fields, then
// treat the remaining, missing fields, as Nil.
for encodedFieldsLeft4zgensym_995050f2db4fcb57_5 > 0 || missingFieldsLeft4zgensym_995050f2db4fcb57_5 > 0 {
//fmt.Printf("encodedFieldsLeft: %v, missingFieldsLeft: %v, found: '%v', fields: '%#v'\n", encodedFieldsLeft4zgensym_995050f2db4fcb57_5, missingFieldsLeft4zgensym_995050f2db4fcb57_5, msgp.ShowFound(found4zgensym_995050f2db4fcb57_5[:]), unmarshalMsgFieldOrder4zgensym_995050f2db4fcb57_5)
if encodedFieldsLeft4zgensym_995050f2db4fcb57_5 > 0 {
encodedFieldsLeft4zgensym_995050f2db4fcb57_5--
field, bts, err = nbs.ReadMapKeyZC(bts)
if err != nil {
return
}
curField4zgensym_995050f2db4fcb57_5 = msgp.UnsafeString(field)
} else {
//missing fields need handling
if nextMiss4zgensym_995050f2db4fcb57_5 < 0 {
// set bts to contain just mnil (0xc0)
bts = nbs.PushAlwaysNil(bts)
nextMiss4zgensym_995050f2db4fcb57_5 = 0
}
for nextMiss4zgensym_995050f2db4fcb57_5 < maxFields4zgensym_995050f2db4fcb57_5 && (found4zgensym_995050f2db4fcb57_5[nextMiss4zgensym_995050f2db4fcb57_5] || unmarshalMsgFieldSkip4zgensym_995050f2db4fcb57_5[nextMiss4zgensym_995050f2db4fcb57_5]) {
nextMiss4zgensym_995050f2db4fcb57_5++
}
if nextMiss4zgensym_995050f2db4fcb57_5 == maxFields4zgensym_995050f2db4fcb57_5 {
// filled all the empty fields!
break doneWithStruct4zgensym_995050f2db4fcb57_5
}
missingFieldsLeft4zgensym_995050f2db4fcb57_5--
curField4zgensym_995050f2db4fcb57_5 = unmarshalMsgFieldOrder4zgensym_995050f2db4fcb57_5[nextMiss4zgensym_995050f2db4fcb57_5]
}
//fmt.Printf("switching on curField: '%v'\n", curField4zgensym_995050f2db4fcb57_5)
switch curField4zgensym_995050f2db4fcb57_5 {
// -- templateUnmarshalMsg ends here --
case "HostDb_zid00_ptr":
found4zgensym_995050f2db4fcb57_5[0] = true
if nbs.AlwaysNil {
if z.HostDb != nil {
z.HostDb.UnmarshalMsg(msgp.OnlyNilSlice)
}
} else {
// not nbs.AlwaysNil
if msgp.IsNil(bts) {
bts = bts[1:]
if nil != z.HostDb {
z.HostDb.UnmarshalMsg(msgp.OnlyNilSlice)
}
} else {
// not nbs.AlwaysNil and not IsNil(bts): have something to read
if z.HostDb == nil {
z.HostDb = new(HostDb)
}
bts, err = z.HostDb.UnmarshalMsg(bts)
if err != nil {
return
}
if err != nil {
return
}
}
}
default:
bts, err = msgp.Skip(bts)
if err != nil {
return
}
}
}
if nextMiss4zgensym_995050f2db4fcb57_5 != -1 {
bts = nbs.PopAlwaysNil()
}
if sawTopNil {
bts = nbs.PopAlwaysNil()
}
o = bts
if p, ok := interface{}(z).(msgp.PostLoad); ok {
p.PostLoadHook()
}
return
}
// fields of Filedb
var unmarshalMsgFieldOrder4zgensym_995050f2db4fcb57_5 = []string{"HostDb_zid00_ptr"}
var unmarshalMsgFieldSkip4zgensym_995050f2db4fcb57_5 = []bool{false}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *Filedb) Msgsize() (s int) {
s = 1 + 17
if z.HostDb == nil {
s += msgp.NilSize
} else {
s += z.HostDb.Msgsize()
}
return
}