MCPcopy
hub / github.com/go-yaml/yaml / yaml_emitter_emit_stream_start

Function yaml_emitter_emit_stream_start

emitterc.go:318–356  ·  view source on GitHub ↗

Expect STREAM-START.

(emitter *yaml_emitter_t, event *yaml_event_t)

Source from the content-addressed store, hash-verified

316
317// Expect STREAM-START.
318func yaml_emitter_emit_stream_start(emitter *yaml_emitter_t, event *yaml_event_t) bool {
319 if event.typ != yaml_STREAM_START_EVENT {
320 return yaml_emitter_set_emitter_error(emitter, "expected STREAM-START")
321 }
322 if emitter.encoding == yaml_ANY_ENCODING {
323 emitter.encoding = event.encoding
324 if emitter.encoding == yaml_ANY_ENCODING {
325 emitter.encoding = yaml_UTF8_ENCODING
326 }
327 }
328 if emitter.best_indent < 2 || emitter.best_indent > 9 {
329 emitter.best_indent = 2
330 }
331 if emitter.best_width >= 0 && emitter.best_width <= emitter.best_indent*2 {
332 emitter.best_width = 80
333 }
334 if emitter.best_width < 0 {
335 emitter.best_width = 1<<31 - 1
336 }
337 if emitter.line_break == yaml_ANY_BREAK {
338 emitter.line_break = yaml_LN_BREAK
339 }
340
341 emitter.indent = -1
342 emitter.line = 0
343 emitter.column = 0
344 emitter.whitespace = true
345 emitter.indention = true
346 emitter.space_above = true
347 emitter.foot_indent = -1
348
349 if emitter.encoding != yaml_UTF8_ENCODING {
350 if !yaml_emitter_write_bom(emitter) {
351 return false
352 }
353 }
354 emitter.state = yaml_EMIT_FIRST_DOCUMENT_START_STATE
355 return true
356}
357
358// Expect DOCUMENT-START or STREAM-END.
359func yaml_emitter_emit_document_start(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {

Callers 1

Calls 2

yaml_emitter_write_bomFunction · 0.85

Tested by

no test coverage detected