parse reads the lines from the specified reader and dispatch them to the specified line parser.
(reader io.Reader, parseLine func(string) error)
| 399 | // parse reads the lines from the specified reader and dispatch them |
| 400 | // to the specified line parser. |
| 401 | func (dec *Decoder) parse(reader io.Reader, parseLine func(string) error) error { |
| 402 | |
| 403 | bufin := bufio.NewReader(reader) |
| 404 | dec.line = 1 |
| 405 | for { |
| 406 | // Reads next line and abort on errors (not EOF) |
| 407 | line, err := bufin.ReadString('\n') |
| 408 | if err != nil && err != io.EOF { |
| 409 | return err |
| 410 | } |
| 411 | // Parses the line |
| 412 | line = strings.Trim(line, blanks) |
| 413 | perr := parseLine(line) |
| 414 | if perr != nil { |
| 415 | return perr |
| 416 | } |
| 417 | // If EOF ends of parsing. |
| 418 | if err == io.EOF { |
| 419 | break |
| 420 | } |
| 421 | dec.line++ |
| 422 | } |
| 423 | return nil |
| 424 | } |
| 425 | |
| 426 | // Parses obj file line, dispatching to specific parsers |
| 427 | func (dec *Decoder) parseObjLine(line string) error { |