/
gong_enum.go
106 lines (84 loc) · 2.01 KB
/
gong_enum.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
// generated code - do not edit
package x
// insertion point of enum utility functions
// Utility function for AEnumType
// if enum values are string, it is stored with the value
// if enum values are int, they are stored with the code of the value
func (aenumtype AEnumType) ToString() (res string) {
// migration of former implementation of enum
switch aenumtype {
// insertion code per enum code
case ENUM_VAL1:
res = "ENUM_VAL1"
case ENUM_VAL2:
res = "ENUM_VAL2"
}
return
}
func (aenumtype *AEnumType) FromString(input string) (err error) {
switch input {
// insertion code per enum code
case "ENUM_VAL1":
*aenumtype = ENUM_VAL1
case "ENUM_VAL2":
*aenumtype = ENUM_VAL2
default:
return errUnkownEnum
}
return
}
func (aenumtype *AEnumType) FromCodeString(input string) (err error) {
switch input {
// insertion code per enum code
case "ENUM_VAL1":
*aenumtype = ENUM_VAL1
case "ENUM_VAL2":
*aenumtype = ENUM_VAL2
default:
return errUnkownEnum
}
return
}
func (aenumtype *AEnumType) ToCodeString() (res string) {
switch *aenumtype {
// insertion code per enum code
case ENUM_VAL1:
res = "ENUM_VAL1"
case ENUM_VAL2:
res = "ENUM_VAL2"
}
return
}
func (aenumtype AEnumType) Codes() (res []string) {
res = make([]string, 0)
// insertion code per enum code
res = append(res, "ENUM_VAL1")
res = append(res, "ENUM_VAL2")
return
}
func (aenumtype AEnumType) CodeValues() (res []string) {
res = make([]string, 0)
// insertion code per enum code
res = append(res, "ENUM_VAL1")
res = append(res, "ENUM_VAL2")
return
}
// end of insertion point for enum utility functions
type GongstructEnumStringField interface {
string | AEnumType
Codes() []string
CodeValues() []string
}
type PointerToGongstructEnumStringField interface {
*AEnumType
FromCodeString(input string) (err error)
}
type GongstructEnumIntField interface {
int
Codes() []string
CodeValues() []int
}
type PointerToGongstructEnumIntField interface {
FromCodeString(input string) (err error)
}
// Last line of the template