Check if the event data is valid.
(emitter *yaml_emitter_t, event *yaml_event_t)
| 1407 | |
| 1408 | // Check if the event data is valid. |
| 1409 | func yaml_emitter_analyze_event(emitter *yaml_emitter_t, event *yaml_event_t) bool { |
| 1410 | |
| 1411 | emitter.anchor_data.anchor = nil |
| 1412 | emitter.tag_data.handle = nil |
| 1413 | emitter.tag_data.suffix = nil |
| 1414 | emitter.scalar_data.value = nil |
| 1415 | |
| 1416 | if len(event.head_comment) > 0 { |
| 1417 | emitter.head_comment = event.head_comment |
| 1418 | } |
| 1419 | if len(event.line_comment) > 0 { |
| 1420 | emitter.line_comment = event.line_comment |
| 1421 | } |
| 1422 | if len(event.foot_comment) > 0 { |
| 1423 | emitter.foot_comment = event.foot_comment |
| 1424 | } |
| 1425 | if len(event.tail_comment) > 0 { |
| 1426 | emitter.tail_comment = event.tail_comment |
| 1427 | } |
| 1428 | |
| 1429 | switch event.typ { |
| 1430 | case yaml_ALIAS_EVENT: |
| 1431 | if !yaml_emitter_analyze_anchor(emitter, event.anchor, true) { |
| 1432 | return false |
| 1433 | } |
| 1434 | |
| 1435 | case yaml_SCALAR_EVENT: |
| 1436 | if len(event.anchor) > 0 { |
| 1437 | if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { |
| 1438 | return false |
| 1439 | } |
| 1440 | } |
| 1441 | if len(event.tag) > 0 && (emitter.canonical || (!event.implicit && !event.quoted_implicit)) { |
| 1442 | if !yaml_emitter_analyze_tag(emitter, event.tag) { |
| 1443 | return false |
| 1444 | } |
| 1445 | } |
| 1446 | if !yaml_emitter_analyze_scalar(emitter, event.value) { |
| 1447 | return false |
| 1448 | } |
| 1449 | |
| 1450 | case yaml_SEQUENCE_START_EVENT: |
| 1451 | if len(event.anchor) > 0 { |
| 1452 | if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { |
| 1453 | return false |
| 1454 | } |
| 1455 | } |
| 1456 | if len(event.tag) > 0 && (emitter.canonical || !event.implicit) { |
| 1457 | if !yaml_emitter_analyze_tag(emitter, event.tag) { |
| 1458 | return false |
| 1459 | } |
| 1460 | } |
| 1461 | |
| 1462 | case yaml_MAPPING_START_EVENT: |
| 1463 | if len(event.anchor) > 0 { |
| 1464 | if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { |
| 1465 | return false |
| 1466 | } |
no test coverage detected