-
Notifications
You must be signed in to change notification settings - Fork 3
/
sharedextension.go
59 lines (44 loc) · 1.06 KB
/
sharedextension.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
package a2l
import "fmt"
type A2LStringer interface {
A2LString() string
}
func (n *IntType) A2LString() string {
var format string
if n.Base == 10 {
format = fmt.Sprintf("%%0%vd", n.Size)
} else {
format = fmt.Sprintf("0x%%0%vX", n.Size)
}
return fmt.Sprintf(format, n.Value)
}
func (n *FloatType) A2LString() string {
return fmt.Sprintf("%v", n.Value)
}
func (n *LongType) A2LString() string {
var format string
if n.Base == 10 {
format = fmt.Sprintf("%%0%vd", n.Size)
} else {
format = fmt.Sprintf("0x%%0%vX", n.Size)
}
return fmt.Sprintf(format, n.Value)
}
func (n *StringType) A2LString() string {
return fmt.Sprintf("\"%v\"", n.Value)
}
func (n *IdentType) A2LString() string {
return fmt.Sprintf("%v", n.Value)
}
func (n *TagType) A2LString() string {
return fmt.Sprintf("\"%v\"", n.Value)
}
func (n *DataTypeType) A2LString() string {
return fmt.Sprintf("%v", n.Value)
}
func (n *IndexOrderType) A2LString() string {
return fmt.Sprintf("%v", n.Value)
}
func (n *AddrTypeType) A2LString() string {
return fmt.Sprintf("%v", n.Value)
}