-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathsection.go
66 lines (60 loc) · 1.11 KB
/
section.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
package drawing
import (
"github.com/yofu/dxf/format"
)
// Section is interface for DXF sections.
type Section interface {
WriteTo(format.Formatter)
SetHandle(*int)
}
// SectionType represents Section names (code 2)
type SectionType int
// Section name: code 2
const (
HEADER SectionType = iota
CLASSES
TABLES
BLOCKS
ENTITIES
OBJECTS
)
// SectionTypeString converts SectionType to string.
// If SectionType is out of range, it returns empty string.
func SectionTypeString(s SectionType) string {
switch s {
case HEADER:
return "HEADER"
case CLASSES:
return "CLASSES"
case TABLES:
return "TABLES"
case BLOCKS:
return "BLOCKS"
case ENTITIES:
return "ENTITIES"
case OBJECTS:
return "OBJECTS"
default:
return ""
}
}
// SectionTypeValue converts string to SectionType.
// If string is unknown SectionType, it returns -1.
func SectionTypeValue(s string) SectionType {
switch s {
case "HEADER":
return HEADER
case "CLASSES":
return CLASSES
case "TABLES":
return TABLES
case "BLOCKS":
return BLOCKS
case "ENTITIES":
return ENTITIES
case "OBJECTS":
return OBJECTS
default:
return -1
}
}