48 lines
741 B
Go
48 lines
741 B
Go
package netsplit
|
|
|
|
import (
|
|
`encoding/xml`
|
|
`errors`
|
|
`io`
|
|
`strings`
|
|
)
|
|
|
|
func (i *IANABool) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error) {
|
|
|
|
var tok xml.Token
|
|
|
|
for {
|
|
if tok, err = d.Token(); err != nil {
|
|
if errors.Is(err, io.EOF) {
|
|
err = nil
|
|
break
|
|
}
|
|
return
|
|
}
|
|
switch t := tok.(type) {
|
|
case xml.CharData:
|
|
switch strings.TrimSpace(string(t)) {
|
|
case ianaTrue:
|
|
i.Evaluated = new(bool)
|
|
*i.Evaluated = true
|
|
case ianaFalse:
|
|
i.Evaluated = new(bool)
|
|
*i.Evaluated = false
|
|
case ianaNA:
|
|
i.Applicable = new(bool)
|
|
*i.Applicable = false
|
|
/*
|
|
default:
|
|
fmt.Printf("Unknown bool: %s\n", tok)
|
|
*/
|
|
}
|
|
/*
|
|
default:
|
|
spew.Dump(t)
|
|
*/
|
|
}
|
|
}
|
|
|
|
return
|
|
}
|