MCPcopy Create free account
hub / github.com/XmirrorSecurity/OpenSCA-cli / DecodeElement

Method DecodeElement

opensca/sca/java/xml/read.go:147–157  ·  view source on GitHub ↗

DecodeElement works like Unmarshal except that it takes a pointer to the start XML element to decode into v. It is useful when a client reads some raw XML tokens itself but also wants to defer to Unmarshal for some elements.

(v any, start *StartElement)

Source from the content-addressed store, hash-verified

145// It is useful when a client reads some raw XML tokens itself
146// but also wants to defer to Unmarshal for some elements.
147func (d *Decoder) DecodeElement(v any, start *StartElement) error {
148 val := reflect.ValueOf(v)
149 if val.Kind() != reflect.Pointer {
150 return errors.New("non-pointer passed to Unmarshal")
151 }
152
153 if val.IsNil() {
154 return errors.New("nil pointer passed to Unmarshal")
155 }
156 return d.unmarshal(val.Elem(), start, 0)
157}
158
159// An UnmarshalError represents an error in the unmarshaling process.
160type UnmarshalError string

Callers 1

DecodeMethod · 0.95

Calls 1

unmarshalMethod · 0.95

Tested by

no test coverage detected