Compare commits
11 Commits
main
...
dev-amery-
Author | SHA1 | Date |
---|---|---|
Alejandro Mery | cbd3f705f5 | 1 year ago |
Alejandro Mery | c9f206c9aa | 1 year ago |
Alejandro Mery | 9912146d21 | 1 year ago |
Alejandro Mery | 71ab4a58c1 | 1 year ago |
Alejandro Mery | 8e838c3566 | 1 year ago |
Alejandro Mery | ff0c7d1b9f | 1 year ago |
Alejandro Mery | fabd192e3d | 1 year ago |
Alejandro Mery | 37f3efebfb | 1 year ago |
Alejandro Mery | 506fff8725 | 1 year ago |
Alejandro Mery | d75b2dbc78 | 1 year ago |
Alejandro Mery | 46ba96d6b4 | 1 year ago |
8 changed files with 135 additions and 34 deletions
@ -0,0 +1,7 @@
|
||||
{ |
||||
"cSpell.words": [ |
||||
"asciigoat", |
||||
"Subname", |
||||
"unescapes" |
||||
] |
||||
} |
@ -0,0 +1,49 @@
|
||||
package ini |
||||
|
||||
import ( |
||||
"bytes" |
||||
"io" |
||||
"strings" |
||||
|
||||
"asciigoat.org/core" |
||||
"asciigoat.org/ini/parser" |
||||
) |
||||
|
||||
// Decoder ...
|
||||
type Decoder struct { |
||||
io.Closer |
||||
|
||||
p *parser.Parser |
||||
} |
||||
|
||||
// Decode ...
|
||||
func (dec *Decoder) Decode() error { |
||||
defer dec.Close() |
||||
|
||||
return dec.p.Run() |
||||
} |
||||
|
||||
// NewDecoder creates a Decoder over the provided [io.Reader]
|
||||
func NewDecoder(r io.Reader) *Decoder { |
||||
rc := core.NewReadCloser(r) |
||||
switch { |
||||
case rc == nil: |
||||
return nil |
||||
default: |
||||
dec := &Decoder{ |
||||
p: parser.NewParser(rc), |
||||
Closer: rc, |
||||
} |
||||
return dec |
||||
} |
||||
} |
||||
|
||||
// NewDecoderBytes creates a Decoder over a provided bytes array
|
||||
func NewDecoderBytes(b []byte) *Decoder { |
||||
return NewDecoder(bytes.NewReader(b)) |
||||
} |
||||
|
||||
// NewDecoderString creates a Decoder over a provided string of data
|
||||
func NewDecoderString(s string) *Decoder { |
||||
return NewDecoder(strings.NewReader(s)) |
||||
} |
Loading…
Reference in new issue