Finsihed xml model & small bugfixes

This commit is contained in:
Simon Martens
2025-03-05 18:56:34 +01:00
parent e19fd47c17
commit e839bbebe8
46 changed files with 8928 additions and 136 deletions

View File

@@ -1,5 +1,7 @@
package xmlmodels
import "encoding/json"
type PersonDef struct {
Index int `xml:"index,attr"`
Name string `xml:"name,attr"`
@@ -9,14 +11,62 @@ type PersonDef struct {
Comment string `xml:"komm,attr"`
}
func (p PersonDef) Keys() []any {
return []any{p.Index}
}
func (p PersonDef) Type() string {
return PERSONREF
}
func (p PersonDef) String() string {
data, err := json.Marshal(p)
if err != nil {
return "Cant marshal to json, PersonDef: " + err.Error()
}
return string(data)
}
type LocationDef struct {
Index int `xml:"index,attr"`
Name string `xml:"name,attr"`
Ref string `xml:"ref,attr"`
}
func (l LocationDef) Keys() []any {
return []any{l.Index}
}
func (l LocationDef) Type() string {
return LOCATIONREF
}
func (l LocationDef) String() string {
data, err := json.Marshal(l)
if err != nil {
return "Cant marshal to json, LocationDef: " + err.Error()
}
return string(data)
}
type AppDef struct {
Index int `xml:"index,attr"`
Name string `xml:"name,attr"`
Category string `xml:"category,attr"`
}
func (a AppDef) Keys() []any {
return []any{a.Index}
}
func (a AppDef) Type() string {
return APPREF
}
func (a AppDef) String() string {
data, err := json.Marshal(a)
if err != nil {
return "Cant marshal to json, AppDef: " + err.Error()
}
return string(data)
}