forked from Open-CMSIS-Pack/vidx2pidx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvidx.go
57 lines (46 loc) · 1.14 KB
/
vidx.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
package main
import (
"encoding/xml"
)
var Vidx = new(VidxXML)
//
// This file maintain a list of all available vendors
// and their pidx file.
//
// A small change to the original vidx file is the "Timestamp"
// field to determine when the last time tha vendor pidx file
// was modified
//
type VidxXML struct {
XMLName xml.Name `xml:"index"`
Timestamp string `xml:"timestamp"`
Vindex struct {
XMLName xml.Name `xml:"vindex"`
VendorPidxs []VendorPidx `xml:"pidx"`
} `xml:"vindex"`
Pindex struct {
XMLName xml.Name `xml:"pindex"`
Pdscs []Pdsc `xml:"pdsc"`
} `xml:"pindex"`
}
type VendorPidx struct {
XMLName xml.Name `xml:"pidx"`
Vendor string `xml:"vendor,attr"`
URL string `xml:"url,attr"`
Timestamp string `xml:"timestamp,attr"`
}
func (v *VidxXML) Init(vidxFileName string) error {
return ReadXML(vidxFileName, v)
}
func (v *VidxXML) ListPidx() []VendorPidx {
return v.Vindex.VendorPidxs
}
func (v *VidxXML) ListPdsc() []Pdsc {
return v.Pindex.Pdscs
}
func (v *VidxXML) PidxLength() int {
return len(v.Vindex.VendorPidxs)
}
func (v *VidxXML) PdscLength() int {
return len(v.Pindex.Pdscs)
}