MCPcopy
hub / github.com/ugorji/go / CodecEncodeSelf

Method CodecEncodeSelf

codec/values_codecgen_generated_test.go:185–246  ·  view source on GitHub ↗
(e *Encoder)

Source from the content-addressed store, hash-verified

183
184func (stringUint64T) codecSelferViaCodecgen() {}
185func (x *stringUint64T) CodecEncodeSelf(e *Encoder) {
186 var h codecSelfer19780
187 z, r := GenHelper().Encoder(e)
188 _, _, _ = h, z, r
189 if z.EncBasicHandle().CheckCircularRef {
190 z.EncEncode(x)
191 return
192 }
193 if x == nil {
194 r.EncodeNil()
195 } else {
196 yy2arr2 := z.EncBasicHandle().StructToArray
197 _ = yy2arr2
198 const yyr2 bool = false // struct tag has 'toArray'
199 if yyr2 || yy2arr2 {
200 z.EncWriteArrayStart(2)
201 z.EncWriteArrayElem()
202 r.EncodeString(string(x.S))
203 z.EncWriteArrayElem()
204 r.EncodeUint(uint64(x.U))
205 z.EncWriteArrayEnd()
206 } else {
207 z.EncWriteMapStart(2)
208 if z.EncBasicHandle().Canonical {
209 z.EncWriteMapElemKey()
210 if z.IsJSONHandle() {
211 z.EncWr().WriteStr("\"S\"")
212 } else {
213 r.EncodeString(`S`)
214 }
215 z.EncWriteMapElemValue()
216 r.EncodeString(string(x.S))
217 z.EncWriteMapElemKey()
218 if z.IsJSONHandle() {
219 z.EncWr().WriteStr("\"U\"")
220 } else {
221 r.EncodeString(`U`)
222 }
223 z.EncWriteMapElemValue()
224 r.EncodeUint(uint64(x.U))
225 } else {
226 z.EncWriteMapElemKey()
227 if z.IsJSONHandle() {
228 z.EncWr().WriteStr("\"S\"")
229 } else {
230 r.EncodeString(`S`)
231 }
232 z.EncWriteMapElemValue()
233 r.EncodeString(string(x.S))
234 z.EncWriteMapElemKey()
235 if z.IsJSONHandle() {
236 z.EncWr().WriteStr("\"U\"")
237 } else {
238 r.EncodeString(`U`)
239 }
240 z.EncWriteMapElemValue()
241 r.EncodeUint(uint64(x.U))
242 }

Callers

nothing calls this directly

Calls 15

GenHelperFunction · 0.85
EncoderMethod · 0.80
EncBasicHandleMethod · 0.80
EncEncodeMethod · 0.80
EncWriteArrayStartMethod · 0.80
EncWriteArrayElemMethod · 0.80
EncWriteArrayEndMethod · 0.80
EncWriteMapStartMethod · 0.80
EncWriteMapElemKeyMethod · 0.80
WriteStrMethod · 0.80
EncWrMethod · 0.80
EncWriteMapElemValueMethod · 0.80

Tested by

no test coverage detected