/
readonlymode_enumer.go
90 lines (73 loc) · 2.37 KB
/
readonlymode_enumer.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
// Code generated by "enumer -type ReadOnlyMode -trimprefix ReadOnly -transform=lower"; DO NOT EDIT.
package modbus
import (
"fmt"
"strings"
)
const _ReadOnlyModeName = "falsedenytrue"
var _ReadOnlyModeIndex = [...]uint8{0, 5, 9, 13}
const _ReadOnlyModeLowerName = "falsedenytrue"
func (i ReadOnlyMode) String() string {
if i < 0 || i >= ReadOnlyMode(len(_ReadOnlyModeIndex)-1) {
return fmt.Sprintf("ReadOnlyMode(%d)", i)
}
return _ReadOnlyModeName[_ReadOnlyModeIndex[i]:_ReadOnlyModeIndex[i+1]]
}
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _ReadOnlyModeNoOp() {
var x [1]struct{}
_ = x[ReadOnlyFalse-(0)]
_ = x[ReadOnlyDeny-(1)]
_ = x[ReadOnlyTrue-(2)]
}
var _ReadOnlyModeValues = []ReadOnlyMode{ReadOnlyFalse, ReadOnlyDeny, ReadOnlyTrue}
var _ReadOnlyModeNameToValueMap = map[string]ReadOnlyMode{
_ReadOnlyModeName[0:5]: ReadOnlyFalse,
_ReadOnlyModeLowerName[0:5]: ReadOnlyFalse,
_ReadOnlyModeName[5:9]: ReadOnlyDeny,
_ReadOnlyModeLowerName[5:9]: ReadOnlyDeny,
_ReadOnlyModeName[9:13]: ReadOnlyTrue,
_ReadOnlyModeLowerName[9:13]: ReadOnlyTrue,
}
var _ReadOnlyModeNames = []string{
_ReadOnlyModeName[0:5],
_ReadOnlyModeName[5:9],
_ReadOnlyModeName[9:13],
}
// ReadOnlyModeString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func ReadOnlyModeString(s string) (ReadOnlyMode, error) {
if val, ok := _ReadOnlyModeNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _ReadOnlyModeNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
switch s {
case "", "0":
return ReadOnlyFalse, nil
case "1":
return ReadOnlyTrue, nil
}
return 0, fmt.Errorf("%s does not belong to ReadOnlyMode values", s)
}
// ReadOnlyModeValues returns all values of the enum
func ReadOnlyModeValues() []ReadOnlyMode {
return _ReadOnlyModeValues
}
// ReadOnlyModeStrings returns a slice of all String values of the enum
func ReadOnlyModeStrings() []string {
strs := make([]string, len(_ReadOnlyModeNames))
copy(strs, _ReadOnlyModeNames)
return strs
}
// IsAReadOnlyMode returns "true" if the value is listed in the enum definition. "false" otherwise
func (i ReadOnlyMode) IsAReadOnlyMode() bool {
for _, v := range _ReadOnlyModeValues {
if i == v {
return true
}
}
return false
}