-
Notifications
You must be signed in to change notification settings - Fork 0
/
attr_stroke_end_cap.go
65 lines (52 loc) · 1.34 KB
/
attr_stroke_end_cap.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
// Copyright (c) 2017 Andrey Gayvoronsky <plandem@gmail.com>
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package vml
import (
"encoding/xml"
)
//StrokeEndCap is direct mapping of ST_StrokeEndCap
type StrokeEndCap byte //enum
var (
toStrokeEndCap map[string]StrokeEndCap
fromStrokeEndCap map[StrokeEndCap]string
)
//List of all possible values for StrokeEndCap
const (
_ StrokeEndCap = iota
StrokeEndCapFlat
StrokeEndCapSquare
StrokeEndCapRound
)
func init() {
fromStrokeEndCap = map[StrokeEndCap]string{
StrokeEndCapFlat: "flat",
StrokeEndCapSquare: "square",
StrokeEndCapRound: "round",
}
toStrokeEndCap = make(map[string]StrokeEndCap, len(fromStrokeEndCap))
for k, v := range fromStrokeEndCap {
toStrokeEndCap[v] = k
}
}
//String returns string presentation of StrokeEndCap
func (t StrokeEndCap) String() string {
return fromStrokeEndCap[t]
}
//MarshalXMLAttr marshal StrokeEndCap
func (t StrokeEndCap) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
attr := xml.Attr{Name: name}
if v, ok := fromStrokeEndCap[t]; ok {
attr.Value = v
} else {
attr = xml.Attr{}
}
return attr, nil
}
//UnmarshalXMLAttr unmarshal StrokeEndCap
func (t *StrokeEndCap) UnmarshalXMLAttr(attr xml.Attr) error {
if v, ok := toStrokeEndCap[attr.Value]; ok {
*t = v
}
return nil
}