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

Function yaml_emitter_need_more_events

emitterc.go:169–203  ·  view source on GitHub ↗

Check if we need to accumulate more events before emitting. We accumulate extra - 1 event for DOCUMENT-START - 2 events for SEQUENCE-START - 3 events for MAPPING-START

(emitter *yaml_emitter_t)

Source from the content-addressed store, hash-verified

167// - 3 events for MAPPING-START
168//
169func yaml_emitter_need_more_events(emitter *yaml_emitter_t) bool {
170 if emitter.events_head == len(emitter.events) {
171 return true
172 }
173 var accumulate int
174 switch emitter.events[emitter.events_head].typ {
175 case yaml_DOCUMENT_START_EVENT:
176 accumulate = 1
177 break
178 case yaml_SEQUENCE_START_EVENT:
179 accumulate = 2
180 break
181 case yaml_MAPPING_START_EVENT:
182 accumulate = 3
183 break
184 default:
185 return false
186 }
187 if len(emitter.events)-emitter.events_head > accumulate {
188 return false
189 }
190 var level int
191 for i := emitter.events_head; i < len(emitter.events); i++ {
192 switch emitter.events[i].typ {
193 case yaml_STREAM_START_EVENT, yaml_DOCUMENT_START_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT:
194 level++
195 case yaml_STREAM_END_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_END_EVENT, yaml_MAPPING_END_EVENT:
196 level--
197 }
198 if level == 0 {
199 return false
200 }
201 }
202 return true
203}
204
205// Append a directive to the directives stack.
206func yaml_emitter_append_tag_directive(emitter *yaml_emitter_t, value *yaml_tag_directive_t, allow_duplicates bool) bool {

Callers 1

yaml_emitter_emitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected