-
Notifications
You must be signed in to change notification settings - Fork 36
/
approximation_type.go
78 lines (63 loc) · 1.43 KB
/
approximation_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
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 (
MaclaurinApproximation ApproximationType = 1 + iota
)
var ErrInvalidApproximationType = errors.New("unknown or invalid ApproximationType value")
type ApproximationType uint32
func ToApproximationType(s string) ApproximationType {
switch s {
case "MACLAURIN":
return MaclaurinApproximation
default:
return ApproximationType(0)
}
}
func (v ApproximationType) String() string {
switch v {
case MaclaurinApproximation:
return "MACLAURIN"
default:
return ""
}
}
func (v ApproximationType) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
return xml.Attr{Name: name, Value: v.String()}, nil
}
func (v *ApproximationType) UnmarshalXMLAttr(attr xml.Attr) error {
switch attr.Value {
case "MACLAURIN":
*v = MaclaurinApproximation
default:
return ErrInvalidApproximationType
}
return nil
}
func (v ApproximationType) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeElement(v.String(), start)
}
func (v *ApproximationType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var s string
err := d.DecodeElement(&s, &start)
if err != nil {
return err
}
switch s {
case "MACLAURIN":
*v = MaclaurinApproximation
default:
return ErrInvalidApproximationType
}
return nil
}