Expect DOCUMENT-START or STREAM-END.
(emitter *yaml_emitter_t, event *yaml_event_t, first bool)
| 357 | |
| 358 | // Expect DOCUMENT-START or STREAM-END. |
| 359 | func yaml_emitter_emit_document_start(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { |
| 360 | |
| 361 | if event.typ == yaml_DOCUMENT_START_EVENT { |
| 362 | |
| 363 | if event.version_directive != nil { |
| 364 | if !yaml_emitter_analyze_version_directive(emitter, event.version_directive) { |
| 365 | return false |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | for i := 0; i < len(event.tag_directives); i++ { |
| 370 | tag_directive := &event.tag_directives[i] |
| 371 | if !yaml_emitter_analyze_tag_directive(emitter, tag_directive) { |
| 372 | return false |
| 373 | } |
| 374 | if !yaml_emitter_append_tag_directive(emitter, tag_directive, false) { |
| 375 | return false |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | for i := 0; i < len(default_tag_directives); i++ { |
| 380 | tag_directive := &default_tag_directives[i] |
| 381 | if !yaml_emitter_append_tag_directive(emitter, tag_directive, true) { |
| 382 | return false |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | implicit := event.implicit |
| 387 | if !first || emitter.canonical { |
| 388 | implicit = false |
| 389 | } |
| 390 | |
| 391 | if emitter.open_ended && (event.version_directive != nil || len(event.tag_directives) > 0) { |
| 392 | if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { |
| 393 | return false |
| 394 | } |
| 395 | if !yaml_emitter_write_indent(emitter) { |
| 396 | return false |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | if event.version_directive != nil { |
| 401 | implicit = false |
| 402 | if !yaml_emitter_write_indicator(emitter, []byte("%YAML"), true, false, false) { |
| 403 | return false |
| 404 | } |
| 405 | if !yaml_emitter_write_indicator(emitter, []byte("1.1"), true, false, false) { |
| 406 | return false |
| 407 | } |
| 408 | if !yaml_emitter_write_indent(emitter) { |
| 409 | return false |
| 410 | } |
| 411 | } |
| 412 | |
| 413 | if len(event.tag_directives) > 0 { |
| 414 | implicit = false |
| 415 | for i := 0; i < len(event.tag_directives); i++ { |
| 416 | tag_directive := &event.tag_directives[i] |
no test coverage detected