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

Function yaml_emitter_emit_flow_mapping_key

emitterc.go:615–688  ·  view source on GitHub ↗

Expect a flow key node.

(emitter *yaml_emitter_t, event *yaml_event_t, first, trail bool)

Source from the content-addressed store, hash-verified

613
614// Expect a flow key node.
615func yaml_emitter_emit_flow_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first, trail bool) bool {
616 if first {
617 if !yaml_emitter_write_indicator(emitter, []byte{'{'}, true, true, false) {
618 return false
619 }
620 if !yaml_emitter_increase_indent(emitter, true, false) {
621 return false
622 }
623 emitter.flow_level++
624 }
625
626 if event.typ == yaml_MAPPING_END_EVENT {
627 if (emitter.canonical || len(emitter.head_comment)+len(emitter.foot_comment)+len(emitter.tail_comment) > 0) && !first && !trail {
628 if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {
629 return false
630 }
631 }
632 if !yaml_emitter_process_head_comment(emitter) {
633 return false
634 }
635 emitter.flow_level--
636 emitter.indent = emitter.indents[len(emitter.indents)-1]
637 emitter.indents = emitter.indents[:len(emitter.indents)-1]
638 if emitter.canonical && !first {
639 if !yaml_emitter_write_indent(emitter) {
640 return false
641 }
642 }
643 if !yaml_emitter_write_indicator(emitter, []byte{'}'}, false, false, false) {
644 return false
645 }
646 if !yaml_emitter_process_line_comment(emitter) {
647 return false
648 }
649 if !yaml_emitter_process_foot_comment(emitter) {
650 return false
651 }
652 emitter.state = emitter.states[len(emitter.states)-1]
653 emitter.states = emitter.states[:len(emitter.states)-1]
654 return true
655 }
656
657 if !first && !trail {
658 if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) {
659 return false
660 }
661 }
662
663 if !yaml_emitter_process_head_comment(emitter) {
664 return false
665 }
666
667 if emitter.column == 0 {
668 if !yaml_emitter_write_indent(emitter) {
669 return false
670 }
671 }
672

Callers 1

Tested by

no test coverage detected