1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-30 23:23:49 +02:00

document public symbols

This commit is contained in:
Tao Wen
2017-07-09 16:09:23 +08:00
parent 46574e7d09
commit f0487718f6
22 changed files with 227 additions and 176 deletions

View File

@ -4,7 +4,7 @@ import (
"io"
)
// Stream is a writer like object, with JSON specific write functions.
// Stream is a io.Writer like object, with JSON specific write functions.
// Error is not returned as return value, but stored as Error member on this stream instance.
type Stream struct {
cfg *frozenConfig
@ -19,9 +19,9 @@ type Stream struct {
// cfg can be jsoniter.ConfigDefault.
// out can be nil if write to internal buffer.
// bufSize is the initial size for the internal buffer in bytes.
func NewStream(cfg *frozenConfig, out io.Writer, bufSize int) *Stream {
func NewStream(cfg API, out io.Writer, bufSize int) *Stream {
return &Stream{
cfg: cfg,
cfg: cfg.(*frozenConfig),
out: out,
buf: make([]byte, bufSize),
n: 0,
@ -30,6 +30,11 @@ func NewStream(cfg *frozenConfig, out io.Writer, bufSize int) *Stream {
}
}
// Pool returns a pool can provide more stream with same configuration
func (stream *Stream) Pool() StreamPool {
return stream.cfg
}
// Reset reuse this stream instance by assign a new writer
func (stream *Stream) Reset(out io.Writer) {
stream.out = out
@ -196,7 +201,6 @@ func (stream *Stream) growAtLeast(minimal int) {
stream.buf = newBuf
}
// WriteRaw write string out without quotes, just like []byte
func (stream *Stream) WriteRaw(s string) {
stream.ensure(len(s))