-
Notifications
You must be signed in to change notification settings - Fork 0
/
components.go
45 lines (37 loc) · 1.18 KB
/
components.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
package local
import "encoding/xml"
func NewComponents(components ...Component) Components {
return Components{Component: components}
}
func NewComponent(name string, variable ...string) Component {
variables := []Variable{}
for _, v := range variable {
variables = append(variables, NewVariable(v))
}
return Component{
Name: name,
Variables: NewVariables(variables...),
}
}
type ComponentNames struct {
XMLName xml.Name `xml:"Components" json:"-"`
Component []ComponentName `json:"components"`
}
type ComponentName struct {
XMLName xml.Name `xml:"Component" json:"-"`
Name string `json:"name"`
HardwareID string `xml:"HarwareId" json:"hardware_id"`
FixedID int `xml:"FixedId" json:"fixed_id"`
Variables VariableNames `json:"variables"`
}
type Components struct {
XMLName xml.Name `xml:"Components" json:"-"`
Component []Component `json:"components"`
}
type Component struct {
XMLName xml.Name `xml:"Component" json:"-"`
Name string `json:"name"`
HardwareID string `xml:"HarwareId" json:"hardware_id"`
FixedID int `xml:"FixedId" json:"fixed_id"`
Variables Variables `json:"variables"`
}