Compare commits
11 Commits
main
...
dev-amery-
Author | SHA1 | Date |
---|---|---|
|
cbd3f705f5 | 2 years ago |
|
c9f206c9aa | 2 years ago |
|
9912146d21 | 2 years ago |
|
71ab4a58c1 | 2 years ago |
|
8e838c3566 | 2 years ago |
|
ff0c7d1b9f | 2 years ago |
|
fabd192e3d | 2 years ago |
|
37f3efebfb | 2 years ago |
|
506fff8725 | 2 years ago |
|
d75b2dbc78 | 2 years ago |
|
46ba96d6b4 | 2 years 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