mirror of https://bitbucket.org/ausocean/av.git
stream/mts/meta/meta.go: updated meta.NewWith so that it just uses meta.New, and now ti can add an abitrary number of things to the map. It also overwrites keys that have been repeated
This commit is contained in:
parent
2b7ab27763
commit
57d1dba2fb
|
@ -76,18 +76,18 @@ func New() *Data {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewWith(key, data string) *Data {
|
// NewWith creates a meta.Data and fills map with initial data given. If there
|
||||||
meta := &Data{
|
// is repeated key, then the latter overwrites the prior.
|
||||||
data: make(map[string]string),
|
func NewWith(data [][2]string) *Data {
|
||||||
enc: []byte{
|
m := New()
|
||||||
0x00, // Reserved byte
|
m.order = make([]string, 0, len(data))
|
||||||
(majVer << 4) | minVer, // MS and LS versions
|
for _, d := range data {
|
||||||
0x00, // Data len byte1
|
if _, exists := m.data[d[0]]; !exists {
|
||||||
0x00, // Data len byte2
|
m.order = append(m.order, d[0])
|
||||||
},
|
}
|
||||||
|
m.data[d[0]] = d[1]
|
||||||
}
|
}
|
||||||
meta.Add(key, data)
|
return m
|
||||||
return meta
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add adds metadata with key and val.
|
// Add adds metadata with key and val.
|
||||||
|
|
Loading…
Reference in New Issue