-
Notifications
You must be signed in to change notification settings - Fork 36
/
type.go
168 lines (153 loc) · 2.69 KB
/
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
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 (
Triggered Type = 1 + iota
Continuous
Health
Geophysical
Weather
Flag
Synthesized
Input
Experimental
Maintenance
Beam
)
var ErrInvalidType = errors.New("unknown or invalid Type value")
type Type uint32
func ToType(s string) Type {
switch s {
case "TRIGGERED":
return Triggered
case "CONTINUOUS":
return Continuous
case "HEALTH":
return Health
case "GEOPHYSICAL":
return Geophysical
case "WEATHER":
return Weather
case "FLAG":
return Flag
case "SYNTHESIZED":
return Synthesized
case "INPUT":
return Input
case "EXPERIMENTAL":
return Experimental
case "MAINTENANCE":
return Maintenance
case "BEAM":
return Beam
default:
return Type(0)
}
}
func (v Type) String() string {
switch v {
case Triggered:
return "TRIGGERED"
case Continuous:
return "CONTINUOUS"
case Health:
return "HEALTH"
case Geophysical:
return "GEOPHYSICAL"
case Weather:
return "WEATHER"
case Flag:
return "FLAG"
case Synthesized:
return "SYNTHESIZED"
case Input:
return "INPUT"
case Experimental:
return "EXPERIMENTAL"
case Maintenance:
return "MAINTENANCE"
case Beam:
return "BEAM"
default:
return ""
}
}
func (v Type) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
return xml.Attr{Name: name, Value: v.String()}, nil
}
func (v *Type) UnmarshalXMLAttr(attr xml.Attr) error {
switch attr.Value {
case "TRIGGERED":
*v = Triggered
case "CONTINUOUS":
*v = Continuous
case "HEALTH":
*v = Health
case "GEOPHYSICAL":
*v = Geophysical
case "WEATHER":
*v = Weather
case "FLAG":
*v = Flag
case "SYNTHESIZED":
*v = Synthesized
case "INPUT":
*v = Input
case "EXPERIMENTAL":
*v = Experimental
case "MAINTENANCE":
*v = Maintenance
case "BEAM":
*v = Beam
default:
return ErrInvalidApproximationType
}
return nil
}
func (v Type) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeElement(v.String(), start)
}
func (v *Type) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var s string
err := d.DecodeElement(&s, &start)
if err != nil {
return err
}
switch s {
case "TRIGGERED":
*v = Triggered
case "CONTINUOUS":
*v = Continuous
case "HEALTH":
*v = Health
case "GEOPHYSICAL":
*v = Geophysical
case "WEATHER":
*v = Weather
case "FLAG":
*v = Flag
case "SYNTHESIZED":
*v = Synthesized
case "INPUT":
*v = Input
case "EXPERIMENTAL":
*v = Experimental
case "MAINTENANCE":
*v = Maintenance
case "BEAM":
*v = Beam
default:
return ErrInvalidApproximationType
}
return nil
}