Lines Matching refs:stream

33 func (stream *Stream) Pool() StreamPool {
34 return stream.cfg
38 func (stream *Stream) Reset(out io.Writer) {
39 stream.out = out
40 stream.buf = stream.buf[:0]
44 func (stream *Stream) Available() int {
45 return cap(stream.buf) - len(stream.buf)
49 func (stream *Stream) Buffered() int {
50 return len(stream.buf)
54 func (stream *Stream) Buffer() []byte {
55 return stream.buf
59 func (stream *Stream) SetBuffer(buf []byte) {
60 stream.buf = buf
67 func (stream *Stream) Write(p []byte) (nn int, err error) {
68 stream.buf = append(stream.buf, p...)
69 if stream.out != nil {
70 nn, err = stream.out.Write(stream.buf)
71 stream.buf = stream.buf[nn:]
78 func (stream *Stream) writeByte(c byte) {
79 stream.buf = append(stream.buf, c)
82 func (stream *Stream) writeTwoBytes(c1 byte, c2 byte) {
83 stream.buf = append(stream.buf, c1, c2)
86 func (stream *Stream) writeThreeBytes(c1 byte, c2 byte, c3 byte) {
87 stream.buf = append(stream.buf, c1, c2, c3)
90 func (stream *Stream) writeFourBytes(c1 byte, c2 byte, c3 byte, c4 byte) {
91 stream.buf = append(stream.buf, c1, c2, c3, c4)
94 func (stream *Stream) writeFiveBytes(c1 byte, c2 byte, c3 byte, c4 byte, c5 byte) {
95 stream.buf = append(stream.buf, c1, c2, c3, c4, c5)
99 func (stream *Stream) Flush() error {
100 if stream.out == nil {
103 if stream.Error != nil {
104 return stream.Error
106 _, err := stream.out.Write(stream.buf)
108 if stream.Error == nil {
109 stream.Error = err
113 stream.buf = stream.buf[:0]
118 func (stream *Stream) WriteRaw(s string) {
119 stream.buf = append(stream.buf, s...)
123 func (stream *Stream) WriteNil() {
124 stream.writeFourBytes('n', 'u', 'l', 'l')
128 func (stream *Stream) WriteTrue() {
129 stream.writeFourBytes('t', 'r', 'u', 'e')
133 func (stream *Stream) WriteFalse() {
134 stream.writeFiveBytes('f', 'a', 'l', 's', 'e')
138 func (stream *Stream) WriteBool(val bool) {
140 stream.WriteTrue()
142 stream.WriteFalse()
147 func (stream *Stream) WriteObjectStart() {
148 stream.indention += stream.cfg.indentionStep
149 stream.writeByte('{')
150 stream.writeIndention(0)
154 func (stream *Stream) WriteObjectField(field string) {
155 stream.WriteString(field)
156 if stream.indention > 0 {
157 stream.writeTwoBytes(':', ' ')
159 stream.writeByte(':')
164 func (stream *Stream) WriteObjectEnd() {
165 stream.writeIndention(stream.cfg.indentionStep)
166 stream.indention -= stream.cfg.indentionStep
167 stream.writeByte('}')
171 func (stream *Stream) WriteEmptyObject() {
172 stream.writeByte('{')
173 stream.writeByte('}')
177 func (stream *Stream) WriteMore() {
178 stream.writeByte(',')
179 stream.writeIndention(0)
183 func (stream *Stream) WriteArrayStart() {
184 stream.indention += stream.cfg.indentionStep
185 stream.writeByte('[')
186 stream.writeIndention(0)
190 func (stream *Stream) WriteEmptyArray() {
191 stream.writeTwoBytes('[', ']')
195 func (stream *Stream) WriteArrayEnd() {
196 stream.writeIndention(stream.cfg.indentionStep)
197 stream.indention -= stream.cfg.indentionStep
198 stream.writeByte(']')
201 func (stream *Stream) writeIndention(delta int) {
202 if stream.indention == 0 {
205 stream.writeByte('\n')
206 toWrite := stream.indention - delta
208 stream.buf = append(stream.buf, ' ')