-
Notifications
You must be signed in to change notification settings - Fork 36
/
restricted_status_type.go
96 lines (81 loc) · 1.86 KB
/
restricted_status_type.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
package stationxml
/*
* WARNING: CODE GENERATED AUTOMATICALLY.
*
* Use "go generate" to update these files.
*
* THIS FILE SHOULD NOT BE EDITED BY HAND.
*
*/
import (
"encoding/xml"
"errors"
)
const (
OpenRestrictedStatus RestrictedStatusType = 1 + iota
ClosedRestrictedStatus
PartialRestrictedStatus
)
var ErrInvalidRestrictedStatusType = errors.New("unknown or invalid RestrictedStatusType value")
type RestrictedStatusType uint32
func ToRestrictedStatusType(s string) RestrictedStatusType {
switch s {
case "open":
return OpenRestrictedStatus
case "closed":
return ClosedRestrictedStatus
case "partial":
return PartialRestrictedStatus
default:
return RestrictedStatusType(0)
}
}
func (v RestrictedStatusType) String() string {
switch v {
case OpenRestrictedStatus:
return "open"
case ClosedRestrictedStatus:
return "closed"
case PartialRestrictedStatus:
return "partial"
default:
return ""
}
}
func (v RestrictedStatusType) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
return xml.Attr{Name: name, Value: v.String()}, nil
}
func (v *RestrictedStatusType) UnmarshalXMLAttr(attr xml.Attr) error {
switch attr.Value {
case "open":
*v = OpenRestrictedStatus
case "closed":
*v = ClosedRestrictedStatus
case "partial":
*v = PartialRestrictedStatus
default:
return ErrInvalidApproximationType
}
return nil
}
func (v RestrictedStatusType) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeElement(v.String(), start)
}
func (v *RestrictedStatusType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var s string
err := d.DecodeElement(&s, &start)
if err != nil {
return err
}
switch s {
case "open":
*v = OpenRestrictedStatus
case "closed":
*v = ClosedRestrictedStatus
case "partial":
*v = PartialRestrictedStatus
default:
return ErrInvalidApproximationType
}
return nil
}