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

Method CodecEncodeSelf

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

Source from the content-addressed store, hash-verified

7221
7222func (codecgenK) codecSelferViaCodecgen() {}
7223func (x *codecgenK) CodecEncodeSelf(e *Encoder) {
7224 var h codecSelfer19780
7225 z, r := GenHelper().Encoder(e)
7226 _, _, _ = h, z, r
7227 if z.EncBasicHandle().CheckCircularRef {
7228 z.EncEncode(x)
7229 return
7230 }
7231 if x == nil {
7232 r.EncodeNil()
7233 } else {
7234 yy2arr2 := z.EncBasicHandle().StructToArray
7235 _ = yy2arr2
7236 const yyr2 bool = false // struct tag has 'toArray'
7237 if yyr2 || yy2arr2 {
7238 z.EncWriteArrayStart(2)
7239 z.EncWriteArrayElem()
7240 r.EncodeInt(int64(x.X))
7241 z.EncWriteArrayElem()
7242 r.EncodeString(string(x.Y))
7243 z.EncWriteArrayEnd()
7244 } else {
7245 z.EncWriteMapStart(2)
7246 if z.EncBasicHandle().Canonical {
7247 z.EncWriteMapElemKey()
7248 if z.IsJSONHandle() {
7249 z.EncWr().WriteStr("\"X\"")
7250 } else {
7251 r.EncodeString(`X`)
7252 }
7253 z.EncWriteMapElemValue()
7254 r.EncodeInt(int64(x.X))
7255 z.EncWriteMapElemKey()
7256 if z.IsJSONHandle() {
7257 z.EncWr().WriteStr("\"Y\"")
7258 } else {
7259 r.EncodeString(`Y`)
7260 }
7261 z.EncWriteMapElemValue()
7262 r.EncodeString(string(x.Y))
7263 } else {
7264 z.EncWriteMapElemKey()
7265 if z.IsJSONHandle() {
7266 z.EncWr().WriteStr("\"X\"")
7267 } else {
7268 r.EncodeString(`X`)
7269 }
7270 z.EncWriteMapElemValue()
7271 r.EncodeInt(int64(x.X))
7272 z.EncWriteMapElemKey()
7273 if z.IsJSONHandle() {
7274 z.EncWr().WriteStr("\"Y\"")
7275 } else {
7276 r.EncodeString(`Y`)
7277 }
7278 z.EncWriteMapElemValue()
7279 r.EncodeString(string(x.Y))
7280 }

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