-
Notifications
You must be signed in to change notification settings - Fork 5
/
Protocol3Enum.go
executable file
·72 lines (62 loc) · 1.52 KB
/
Protocol3Enum.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
package models
import(
"encoding/json"
)
/**
* Type definition for Protocol3Enum enum
*/
type Protocol3Enum int
/**
* Value collection for Protocol3Enum enum
*/
const (
Protocol3_KUDP Protocol3Enum = 1 + iota
Protocol3_KTCP
)
func (r Protocol3Enum) MarshalJSON() ([]byte, error) {
s := Protocol3EnumToValue(r)
return json.Marshal(s)
}
func (r *Protocol3Enum) UnmarshalJSON(data []byte) error {
var s string
json.Unmarshal(data, &s)
v := Protocol3EnumFromValue(s)
*r = v
return nil
}
/**
* Converts Protocol3Enum to its string representation
*/
func Protocol3EnumToValue(protocol3Enum Protocol3Enum) string {
switch protocol3Enum {
case Protocol3_KUDP:
return "kUDP"
case Protocol3_KTCP:
return "kTCP"
default:
return "kUDP"
}
}
/**
* Converts Protocol3Enum Array to its string Array representation
*/
func Protocol3EnumArrayToValue(protocol3Enum []Protocol3Enum) []string {
convArray := make([]string,len( protocol3Enum))
for i:=0; i<len(protocol3Enum);i++ {
convArray[i] = Protocol3EnumToValue(protocol3Enum[i])
}
return convArray
}
/**
* Converts given value to its enum representation
*/
func Protocol3EnumFromValue(value string) Protocol3Enum {
switch value {
case "kUDP":
return Protocol3_KUDP
case "kTCP":
return Protocol3_KTCP
default:
return Protocol3_KUDP
}
}