-
Notifications
You must be signed in to change notification settings - Fork 3
/
ifdataextension.go
90 lines (74 loc) · 2.87 KB
/
ifdataextension.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
90
package a2l
import (
"fmt"
"strings"
)
func (t *IfDataType) MapChildNodes(node any) {
switch node.(type) {
case *GenericParameterType:
if t.Blob == nil {
t.Blob = make([]*GenericParameterType, 0)
}
t.Blob = append(t.Blob, node.(*GenericParameterType))
default:
panic("not implemented yet...")
}
}
func (t *IfDataType) MarshalA2L(indentLevel int, indentString string, sort bool) (result string) {
tmpResult := []string{indentContent(fmt.Sprintf("/begin IF_DATA %s", t.Name.A2LString()), indentLevel, indentString)}
if t.Blob != nil {
for _, blob := range t.Blob {
tmpResult = append(tmpResult, blob.MarshalA2L(indentLevel+1, indentString, sort))
}
}
tmpResult = append(tmpResult, indentContent("/end IF_DATA", indentLevel, indentString))
return strings.Join(tmpResult, "\n")
}
func (t *GenericParameterType) MapChildNodes(node any) {
switch node.(type) {
case *GenericNodeType:
t.Oneof = &GenericParameterType_Generic{Generic: node.(*GenericNodeType)}
default:
panic("not implemented yet...")
}
}
func (t *GenericParameterType) MarshalA2L(indentLevel int, indentString string, sort bool) (result string) {
switch t.Oneof.(type) {
case *GenericParameterType_Tag:
result = indentContent(t.Oneof.(*GenericParameterType_Tag).Tag.A2LString(), indentLevel, indentString)
case *GenericParameterType_String_:
result = indentContent(t.Oneof.(*GenericParameterType_String_).String_.A2LString(), indentLevel, indentString)
case *GenericParameterType_Long:
result = indentContent(t.Oneof.(*GenericParameterType_Long).Long.A2LString(), indentLevel, indentString)
case *GenericParameterType_Float:
result = indentContent(t.Oneof.(*GenericParameterType_Float).Float.A2LString(), indentLevel, indentString)
case *GenericParameterType_Generic:
result = t.Oneof.(*GenericParameterType_Generic).Generic.MarshalA2L(indentLevel, indentString, sort)
case *GenericParameterType_Identifier:
result = indentContent(t.Oneof.(*GenericParameterType_Identifier).Identifier.A2LString(), indentLevel, indentString)
default:
panic("not implemented yet...")
}
return result
}
func (t *GenericNodeType) MapChildNodes(node any) {
switch node.(type) {
case *GenericParameterType:
if t.Element == nil {
t.Element = make([]*GenericParameterType, 0)
}
t.Element = append(t.Element, node.(*GenericParameterType))
default:
panic("not implemented yet...")
}
}
func (t *GenericNodeType) MarshalA2L(indentLevel int, indentString string, sort bool) (result string) {
tmpResult := []string{indentContent(fmt.Sprintf("/begin %s", t.Name.A2LString()), indentLevel, indentString)}
if t.Element != nil {
for _, element := range t.Element {
tmpResult = append(tmpResult, element.MarshalA2L(indentLevel+1, indentString, sort))
}
}
tmpResult = append(tmpResult, indentContent(fmt.Sprintf("/end %s", t.Name.A2LString()), indentLevel, indentString))
return strings.Join(tmpResult, "\n")
}