-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathArgument.go
89 lines (79 loc) · 1.66 KB
/
Argument.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
package UPnP
import scpd "github.com/micmonay/UPnP/SCPD"
// Argument arguement
type Argument struct {
argSCPD *scpd.Argument
scpd *scpd.SCPD
sv *scpd.StateVariable
}
// GetName return name
func (a *Argument) GetName() string {
return a.argSCPD.Name
}
// GetDirection return in or out
func (a *Argument) GetDirection() string {
return a.argSCPD.Direction
}
func (a *Argument) getStateVariable() *scpd.StateVariable {
if a.sv != nil {
return a.sv
}
for _, sv := range a.scpd.StateVariables {
if sv.Name == a.argSCPD.RelatedStateVariable {
a.sv = sv
}
}
return a.sv
}
// GetType return type for argument
func (a *Argument) GetType() string {
sv := a.getStateVariable()
if sv == nil {
return ""
}
return sv.DataType
}
// GetAllowedValues return value possible
func (a *Argument) GetAllowedValues() []string {
sv := a.getStateVariable()
strs := []string{}
if sv == nil {
return strs
}
for _, str := range sv.AllowedValues {
strs = append(strs, str.Value)
}
return strs
}
// GetDefault return default string or ""
func (a *Argument) GetDefault() string {
sv := a.getStateVariable()
if sv == nil {
return ""
}
return sv.Default
}
// GetMaximum return maximum or ""
func (a *Argument) GetMaximum() string {
sv := a.getStateVariable()
if sv == nil {
return ""
}
return sv.AllowedValueRanges.Maximum
}
// GetMinimum return minimum or ""
func (a *Argument) GetMinimum() string {
sv := a.getStateVariable()
if sv == nil {
return ""
}
return sv.AllowedValueRanges.Minimum
}
// GetStep return step or ""
func (a *Argument) GetStep() string {
sv := a.getStateVariable()
if sv == nil {
return ""
}
return sv.AllowedValueRanges.Step
}