-
Notifications
You must be signed in to change notification settings - Fork 36
/
cf_transfer_function_type.go
96 lines (81 loc) · 2.11 KB
/
cf_transfer_function_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 (
AnalogRadiansSecondCfTransferFunction CfTransferFunctionType = 1 + iota
AnalogHertzCfTransferFunction
DigitalCfTransferFunction
)
var ErrInvalidCfTransferFunctionType = errors.New("unknown or invalid CfTransferFunctionType value")
type CfTransferFunctionType uint32
func ToCfTransferFunctionType(s string) CfTransferFunctionType {
switch s {
case "ANALOG (RADIANS/SECOND)":
return AnalogRadiansSecondCfTransferFunction
case "ANALOG (HERTZ)":
return AnalogHertzCfTransferFunction
case "DIGITAL":
return DigitalCfTransferFunction
default:
return CfTransferFunctionType(0)
}
}
func (v CfTransferFunctionType) String() string {
switch v {
case AnalogRadiansSecondCfTransferFunction:
return "ANALOG (RADIANS/SECOND)"
case AnalogHertzCfTransferFunction:
return "ANALOG (HERTZ)"
case DigitalCfTransferFunction:
return "DIGITAL"
default:
return ""
}
}
func (v CfTransferFunctionType) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
return xml.Attr{Name: name, Value: v.String()}, nil
}
func (v *CfTransferFunctionType) UnmarshalXMLAttr(attr xml.Attr) error {
switch attr.Value {
case "ANALOG (RADIANS/SECOND)":
*v = AnalogRadiansSecondCfTransferFunction
case "ANALOG (HERTZ)":
*v = AnalogHertzCfTransferFunction
case "DIGITAL":
*v = DigitalCfTransferFunction
default:
return ErrInvalidApproximationType
}
return nil
}
func (v CfTransferFunctionType) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
return e.EncodeElement(v.String(), start)
}
func (v *CfTransferFunctionType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var s string
err := d.DecodeElement(&s, &start)
if err != nil {
return err
}
switch s {
case "ANALOG (RADIANS/SECOND)":
*v = AnalogRadiansSecondCfTransferFunction
case "ANALOG (HERTZ)":
*v = AnalogHertzCfTransferFunction
case "DIGITAL":
*v = DigitalCfTransferFunction
default:
return ErrInvalidApproximationType
}
return nil
}