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

Function yaml_emitter_emit_block_mapping_key

emitterc.go:765–800  ·  view source on GitHub ↗

Expect a block key node.

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

Source from the content-addressed store, hash-verified

763
764// Expect a block key node.
765func yaml_emitter_emit_block_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool {
766 if first {
767 if !yaml_emitter_increase_indent(emitter, false, false) {
768 return false
769 }
770 }
771 if !yaml_emitter_process_head_comment(emitter) {
772 return false
773 }
774 if event.typ == yaml_MAPPING_END_EVENT {
775 emitter.indent = emitter.indents[len(emitter.indents)-1]
776 emitter.indents = emitter.indents[:len(emitter.indents)-1]
777 emitter.state = emitter.states[len(emitter.states)-1]
778 emitter.states = emitter.states[:len(emitter.states)-1]
779 return true
780 }
781 if !yaml_emitter_write_indent(emitter) {
782 return false
783 }
784 if len(emitter.line_comment) > 0 {
785 // [Go] A line comment was provided for the key. That's unusual as the
786 // scanner associates line comments with the value. Either way,
787 // save the line comment and render it appropriately later.
788 emitter.key_line_comment = emitter.line_comment
789 emitter.line_comment = nil
790 }
791 if yaml_emitter_check_simple_key(emitter) {
792 emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE)
793 return yaml_emitter_emit_node(emitter, event, false, false, true, true)
794 }
795 if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, true) {
796 return false
797 }
798 emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_VALUE_STATE)
799 return yaml_emitter_emit_node(emitter, event, false, false, true, false)
800}
801
802// Expect a block value node.
803func yaml_emitter_emit_block_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool {

Callers 1

Tested by

no test coverage detected