blob: a2dde608cb7a39850340eba008e796e10a730b26 [file] [log] [blame]
Scott Baker1fe72732019-10-21 10:58:51 -07001package yaml
2
3// Set the writer error and return false.
4func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool {
5 emitter.error = yaml_WRITER_ERROR
6 emitter.problem = problem
7 return false
8}
9
10// Flush the output buffer.
11func yaml_emitter_flush(emitter *yaml_emitter_t) bool {
12 if emitter.write_handler == nil {
13 panic("write handler not set")
14 }
15
16 // Check if the buffer is empty.
17 if emitter.buffer_pos == 0 {
18 return true
19 }
20
21 if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil {
22 return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error())
23 }
24 emitter.buffer_pos = 0
25 return true
26}