forked from ixmilia/dxf-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtables.go
58 lines (53 loc) · 1.31 KB
/
tables.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
package dxf
import "errors"
func readTables(drawing *Drawing, np CodePair, reader codePairReader) (nextPair CodePair, error error) {
nextPair = np
for error == nil && !nextPair.isEndSection() {
if !nextPair.isStartTable() {
error = errors.New("expected 0/TABLE")
return
}
nextPair, error = reader.readCodePair()
if error != nil {
return
}
// swallow until 2/<table-type>
for error == nil && nextPair.Code != 2 {
nextPair, error = reader.readCodePair()
}
if error != nil {
return
}
tableType := nextPair.Value.(StringCodePairValue).Value
nextPair, error = reader.readCodePair()
if error != nil {
return
}
nextPair, error = readSpecificTable(drawing, nextPair, reader, tableType)
// swallow until 0/ENDTAB
for error == nil && !nextPair.isEndTable() {
nextPair, error = reader.readCodePair()
}
if error != nil {
return
}
// swallow the actual 0/ENDTAB
nextPair, error = reader.readCodePair()
}
return
}
func writeTablesSection(drawing *Drawing, writer codePairWriter, version AcadVersion) (err error) {
pairs := getTablePairs(drawing, version)
err = writeSectionStart(writer, "TABLES")
if err != nil {
return err
}
for _, pair := range pairs {
err = writer.writeCodePair(pair)
if err != nil {
return err
}
}
err = writeSectionEnd(writer)
return
}