forked from ebhomengo/niki
1
0
Fork 0
niki/vendor/gopkg.in/yaml.v2/encode.go

709 lines
9.9 KiB
Go
Raw Normal View History

2024-05-14 13:07:09 +00:00
package yaml
import (
"encoding"
"fmt"
"io"
"reflect"
"regexp"
"sort"
"strconv"
"strings"
"time"
"unicode/utf8"
)
// jsonNumber is the interface of the encoding/json.Number datatype.
2024-05-14 13:07:09 +00:00
// Repeating the interface here avoids a dependency on encoding/json, and also
2024-05-14 13:07:09 +00:00
// supports other libraries like jsoniter, which use a similar datatype with
2024-05-14 13:07:09 +00:00
// the same interface. Detecting this interface is useful when dealing with
2024-05-14 13:07:09 +00:00
// structures containing json.Number, which is a string under the hood. The
2024-05-14 13:07:09 +00:00
// encoder should prefer the use of Int64(), Float64() and string(), in that
2024-05-14 13:07:09 +00:00
// order, when encoding this type.
2024-05-14 13:07:09 +00:00
type jsonNumber interface {
Float64() (float64, error)
2024-05-14 13:07:09 +00:00
Int64() (int64, error)
2024-05-14 13:07:09 +00:00
String() string
}
type encoder struct {
emitter yaml_emitter_t
event yaml_event_t
out []byte
flow bool
2024-05-14 13:07:09 +00:00
// doneInit holds whether the initial stream_start_event has been
2024-05-14 13:07:09 +00:00
// emitted.
2024-05-14 13:07:09 +00:00
doneInit bool
}
func newEncoder() *encoder {
2024-05-14 13:07:09 +00:00
e := &encoder{}
2024-05-14 13:07:09 +00:00
yaml_emitter_initialize(&e.emitter)
2024-05-14 13:07:09 +00:00
yaml_emitter_set_output_string(&e.emitter, &e.out)
2024-05-14 13:07:09 +00:00
yaml_emitter_set_unicode(&e.emitter, true)
2024-05-14 13:07:09 +00:00
return e
2024-05-14 13:07:09 +00:00
}
func newEncoderWithWriter(w io.Writer) *encoder {
2024-05-14 13:07:09 +00:00
e := &encoder{}
2024-05-14 13:07:09 +00:00
yaml_emitter_initialize(&e.emitter)
2024-05-14 13:07:09 +00:00
yaml_emitter_set_output_writer(&e.emitter, w)
2024-05-14 13:07:09 +00:00
yaml_emitter_set_unicode(&e.emitter, true)
2024-05-14 13:07:09 +00:00
return e
2024-05-14 13:07:09 +00:00
}
func (e *encoder) init() {
2024-05-14 13:07:09 +00:00
if e.doneInit {
2024-05-14 13:07:09 +00:00
return
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
yaml_stream_start_event_initialize(&e.event, yaml_UTF8_ENCODING)
2024-05-14 13:07:09 +00:00
e.emit()
2024-05-14 13:07:09 +00:00
e.doneInit = true
2024-05-14 13:07:09 +00:00
}
func (e *encoder) finish() {
2024-05-14 13:07:09 +00:00
e.emitter.open_ended = false
2024-05-14 13:07:09 +00:00
yaml_stream_end_event_initialize(&e.event)
2024-05-14 13:07:09 +00:00
e.emit()
2024-05-14 13:07:09 +00:00
}
func (e *encoder) destroy() {
2024-05-14 13:07:09 +00:00
yaml_emitter_delete(&e.emitter)
2024-05-14 13:07:09 +00:00
}
func (e *encoder) emit() {
2024-05-14 13:07:09 +00:00
// This will internally delete the e.event value.
2024-05-14 13:07:09 +00:00
e.must(yaml_emitter_emit(&e.emitter, &e.event))
2024-05-14 13:07:09 +00:00
}
func (e *encoder) must(ok bool) {
2024-05-14 13:07:09 +00:00
if !ok {
2024-05-14 13:07:09 +00:00
msg := e.emitter.problem
2024-05-14 13:07:09 +00:00
if msg == "" {
2024-05-14 13:07:09 +00:00
msg = "unknown problem generating YAML content"
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
failf("%s", msg)
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
}
func (e *encoder) marshalDoc(tag string, in reflect.Value) {
2024-05-14 13:07:09 +00:00
e.init()
2024-05-14 13:07:09 +00:00
yaml_document_start_event_initialize(&e.event, nil, nil, true)
2024-05-14 13:07:09 +00:00
e.emit()
2024-05-14 13:07:09 +00:00
e.marshal(tag, in)
2024-05-14 13:07:09 +00:00
yaml_document_end_event_initialize(&e.event, true)
2024-05-14 13:07:09 +00:00
e.emit()
2024-05-14 13:07:09 +00:00
}
func (e *encoder) marshal(tag string, in reflect.Value) {
2024-05-14 13:07:09 +00:00
if !in.IsValid() || in.Kind() == reflect.Ptr && in.IsNil() {
2024-05-14 13:07:09 +00:00
e.nilv()
2024-05-14 13:07:09 +00:00
return
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
iface := in.Interface()
2024-05-14 13:07:09 +00:00
switch m := iface.(type) {
2024-05-14 13:07:09 +00:00
case jsonNumber:
2024-05-14 13:07:09 +00:00
integer, err := m.Int64()
2024-05-14 13:07:09 +00:00
if err == nil {
2024-05-14 13:07:09 +00:00
// In this case the json.Number is a valid int64
2024-05-14 13:07:09 +00:00
in = reflect.ValueOf(integer)
2024-05-14 13:07:09 +00:00
break
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
float, err := m.Float64()
2024-05-14 13:07:09 +00:00
if err == nil {
2024-05-14 13:07:09 +00:00
// In this case the json.Number is a valid float64
2024-05-14 13:07:09 +00:00
in = reflect.ValueOf(float)
2024-05-14 13:07:09 +00:00
break
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
// fallback case - no number could be obtained
2024-05-14 13:07:09 +00:00
in = reflect.ValueOf(m.String())
2024-05-14 13:07:09 +00:00
case time.Time, *time.Time:
2024-05-14 13:07:09 +00:00
// Although time.Time implements TextMarshaler,
2024-05-14 13:07:09 +00:00
// we don't want to treat it as a string for YAML
2024-05-14 13:07:09 +00:00
// purposes because YAML has special support for
2024-05-14 13:07:09 +00:00
// timestamps.
2024-05-14 13:07:09 +00:00
case Marshaler:
2024-05-14 13:07:09 +00:00
v, err := m.MarshalYAML()
2024-05-14 13:07:09 +00:00
if err != nil {
2024-05-14 13:07:09 +00:00
fail(err)
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
if v == nil {
2024-05-14 13:07:09 +00:00
e.nilv()
2024-05-14 13:07:09 +00:00
return
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
in = reflect.ValueOf(v)
2024-05-14 13:07:09 +00:00
case encoding.TextMarshaler:
2024-05-14 13:07:09 +00:00
text, err := m.MarshalText()
2024-05-14 13:07:09 +00:00
if err != nil {
2024-05-14 13:07:09 +00:00
fail(err)
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
in = reflect.ValueOf(string(text))
2024-05-14 13:07:09 +00:00
case nil:
2024-05-14 13:07:09 +00:00
e.nilv()
2024-05-14 13:07:09 +00:00
return
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
switch in.Kind() {
2024-05-14 13:07:09 +00:00
case reflect.Interface:
2024-05-14 13:07:09 +00:00
e.marshal(tag, in.Elem())
2024-05-14 13:07:09 +00:00
case reflect.Map:
2024-05-14 13:07:09 +00:00
e.mapv(tag, in)
2024-05-14 13:07:09 +00:00
case reflect.Ptr:
2024-05-14 13:07:09 +00:00
if in.Type() == ptrTimeType {
2024-05-14 13:07:09 +00:00
e.timev(tag, in.Elem())
2024-05-14 13:07:09 +00:00
} else {
2024-05-14 13:07:09 +00:00
e.marshal(tag, in.Elem())
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
case reflect.Struct:
2024-05-14 13:07:09 +00:00
if in.Type() == timeType {
2024-05-14 13:07:09 +00:00
e.timev(tag, in)
2024-05-14 13:07:09 +00:00
} else {
2024-05-14 13:07:09 +00:00
e.structv(tag, in)
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
case reflect.Slice, reflect.Array:
2024-05-14 13:07:09 +00:00
if in.Type().Elem() == mapItemType {
2024-05-14 13:07:09 +00:00
e.itemsv(tag, in)
2024-05-14 13:07:09 +00:00
} else {
2024-05-14 13:07:09 +00:00
e.slicev(tag, in)
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
case reflect.String:
2024-05-14 13:07:09 +00:00
e.stringv(tag, in)
2024-05-14 13:07:09 +00:00
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
2024-05-14 13:07:09 +00:00
if in.Type() == durationType {
2024-05-14 13:07:09 +00:00
e.stringv(tag, reflect.ValueOf(iface.(time.Duration).String()))
2024-05-14 13:07:09 +00:00
} else {
2024-05-14 13:07:09 +00:00
e.intv(tag, in)
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
2024-05-14 13:07:09 +00:00
e.uintv(tag, in)
2024-05-14 13:07:09 +00:00
case reflect.Float32, reflect.Float64:
2024-05-14 13:07:09 +00:00
e.floatv(tag, in)
2024-05-14 13:07:09 +00:00
case reflect.Bool:
2024-05-14 13:07:09 +00:00
e.boolv(tag, in)
2024-05-14 13:07:09 +00:00
default:
2024-05-14 13:07:09 +00:00
panic("cannot marshal type: " + in.Type().String())
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
}
func (e *encoder) mapv(tag string, in reflect.Value) {
2024-05-14 13:07:09 +00:00
e.mappingv(tag, func() {
2024-05-14 13:07:09 +00:00
keys := keyList(in.MapKeys())
2024-05-14 13:07:09 +00:00
sort.Sort(keys)
2024-05-14 13:07:09 +00:00
for _, k := range keys {
2024-05-14 13:07:09 +00:00
e.marshal("", k)
2024-05-14 13:07:09 +00:00
e.marshal("", in.MapIndex(k))
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
})
2024-05-14 13:07:09 +00:00
}
func (e *encoder) itemsv(tag string, in reflect.Value) {
2024-05-14 13:07:09 +00:00
e.mappingv(tag, func() {
2024-05-14 13:07:09 +00:00
slice := in.Convert(reflect.TypeOf([]MapItem{})).Interface().([]MapItem)
2024-05-14 13:07:09 +00:00
for _, item := range slice {
2024-05-14 13:07:09 +00:00
e.marshal("", reflect.ValueOf(item.Key))
2024-05-14 13:07:09 +00:00
e.marshal("", reflect.ValueOf(item.Value))
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
})
2024-05-14 13:07:09 +00:00
}
func (e *encoder) structv(tag string, in reflect.Value) {
2024-05-14 13:07:09 +00:00
sinfo, err := getStructInfo(in.Type())
2024-05-14 13:07:09 +00:00
if err != nil {
2024-05-14 13:07:09 +00:00
panic(err)
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
e.mappingv(tag, func() {
2024-05-14 13:07:09 +00:00
for _, info := range sinfo.FieldsList {
2024-05-14 13:07:09 +00:00
var value reflect.Value
2024-05-14 13:07:09 +00:00
if info.Inline == nil {
2024-05-14 13:07:09 +00:00
value = in.Field(info.Num)
2024-05-14 13:07:09 +00:00
} else {
2024-05-14 13:07:09 +00:00
value = in.FieldByIndex(info.Inline)
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
if info.OmitEmpty && isZero(value) {
2024-05-14 13:07:09 +00:00
continue
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
e.marshal("", reflect.ValueOf(info.Key))
2024-05-14 13:07:09 +00:00
e.flow = info.Flow
2024-05-14 13:07:09 +00:00
e.marshal("", value)
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
if sinfo.InlineMap >= 0 {
2024-05-14 13:07:09 +00:00
m := in.Field(sinfo.InlineMap)
2024-05-14 13:07:09 +00:00
if m.Len() > 0 {
2024-05-14 13:07:09 +00:00
e.flow = false
2024-05-14 13:07:09 +00:00
keys := keyList(m.MapKeys())
2024-05-14 13:07:09 +00:00
sort.Sort(keys)
2024-05-14 13:07:09 +00:00
for _, k := range keys {
2024-05-14 13:07:09 +00:00
if _, found := sinfo.FieldsMap[k.String()]; found {
2024-05-14 13:07:09 +00:00
panic(fmt.Sprintf("Can't have key %q in inlined map; conflicts with struct field", k.String()))
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
e.marshal("", k)
2024-05-14 13:07:09 +00:00
e.flow = false
2024-05-14 13:07:09 +00:00
e.marshal("", m.MapIndex(k))
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
})
2024-05-14 13:07:09 +00:00
}
func (e *encoder) mappingv(tag string, f func()) {
2024-05-14 13:07:09 +00:00
implicit := tag == ""
2024-05-14 13:07:09 +00:00
style := yaml_BLOCK_MAPPING_STYLE
2024-05-14 13:07:09 +00:00
if e.flow {
2024-05-14 13:07:09 +00:00
e.flow = false
2024-05-14 13:07:09 +00:00
style = yaml_FLOW_MAPPING_STYLE
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
yaml_mapping_start_event_initialize(&e.event, nil, []byte(tag), implicit, style)
2024-05-14 13:07:09 +00:00
e.emit()
2024-05-14 13:07:09 +00:00
f()
2024-05-14 13:07:09 +00:00
yaml_mapping_end_event_initialize(&e.event)
2024-05-14 13:07:09 +00:00
e.emit()
2024-05-14 13:07:09 +00:00
}
func (e *encoder) slicev(tag string, in reflect.Value) {
2024-05-14 13:07:09 +00:00
implicit := tag == ""
2024-05-14 13:07:09 +00:00
style := yaml_BLOCK_SEQUENCE_STYLE
2024-05-14 13:07:09 +00:00
if e.flow {
2024-05-14 13:07:09 +00:00
e.flow = false
2024-05-14 13:07:09 +00:00
style = yaml_FLOW_SEQUENCE_STYLE
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
e.must(yaml_sequence_start_event_initialize(&e.event, nil, []byte(tag), implicit, style))
2024-05-14 13:07:09 +00:00
e.emit()
2024-05-14 13:07:09 +00:00
n := in.Len()
2024-05-14 13:07:09 +00:00
for i := 0; i < n; i++ {
2024-05-14 13:07:09 +00:00
e.marshal("", in.Index(i))
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
e.must(yaml_sequence_end_event_initialize(&e.event))
2024-05-14 13:07:09 +00:00
e.emit()
2024-05-14 13:07:09 +00:00
}
// isBase60 returns whether s is in base 60 notation as defined in YAML 1.1.
2024-05-14 13:07:09 +00:00
//
2024-05-14 13:07:09 +00:00
// The base 60 float notation in YAML 1.1 is a terrible idea and is unsupported
2024-05-14 13:07:09 +00:00
// in YAML 1.2 and by this package, but these should be marshalled quoted for
2024-05-14 13:07:09 +00:00
// the time being for compatibility with other parsers.
2024-05-14 13:07:09 +00:00
func isBase60Float(s string) (result bool) {
2024-05-14 13:07:09 +00:00
// Fast path.
2024-05-14 13:07:09 +00:00
if s == "" {
2024-05-14 13:07:09 +00:00
return false
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
c := s[0]
2024-05-14 13:07:09 +00:00
if !(c == '+' || c == '-' || c >= '0' && c <= '9') || strings.IndexByte(s, ':') < 0 {
2024-05-14 13:07:09 +00:00
return false
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
// Do the full match.
2024-05-14 13:07:09 +00:00
return base60float.MatchString(s)
2024-05-14 13:07:09 +00:00
}
// From http://yaml.org/type/float.html, except the regular expression there
2024-05-14 13:07:09 +00:00
// is bogus. In practice parsers do not enforce the "\.[0-9_]*" suffix.
2024-05-14 13:07:09 +00:00
var base60float = regexp.MustCompile(`^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+(?:\.[0-9_]*)?$`)
func (e *encoder) stringv(tag string, in reflect.Value) {
2024-05-14 13:07:09 +00:00
var style yaml_scalar_style_t
2024-05-14 13:07:09 +00:00
s := in.String()
2024-05-14 13:07:09 +00:00
canUsePlain := true
2024-05-14 13:07:09 +00:00
switch {
2024-05-14 13:07:09 +00:00
case !utf8.ValidString(s):
2024-05-14 13:07:09 +00:00
if tag == yaml_BINARY_TAG {
2024-05-14 13:07:09 +00:00
failf("explicitly tagged !!binary data must be base64-encoded")
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
if tag != "" {
2024-05-14 13:07:09 +00:00
failf("cannot marshal invalid UTF-8 data as %s", shortTag(tag))
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
// It can't be encoded directly as YAML so use a binary tag
2024-05-14 13:07:09 +00:00
// and encode it as base64.
2024-05-14 13:07:09 +00:00
tag = yaml_BINARY_TAG
2024-05-14 13:07:09 +00:00
s = encodeBase64(s)
2024-05-14 13:07:09 +00:00
case tag == "":
2024-05-14 13:07:09 +00:00
// Check to see if it would resolve to a specific
2024-05-14 13:07:09 +00:00
// tag when encoded unquoted. If it doesn't,
2024-05-14 13:07:09 +00:00
// there's no need to quote it.
2024-05-14 13:07:09 +00:00
rtag, _ := resolve("", s)
2024-05-14 13:07:09 +00:00
canUsePlain = rtag == yaml_STR_TAG && !isBase60Float(s)
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
// Note: it's possible for user code to emit invalid YAML
2024-05-14 13:07:09 +00:00
// if they explicitly specify a tag and a string containing
2024-05-14 13:07:09 +00:00
// text that's incompatible with that tag.
2024-05-14 13:07:09 +00:00
switch {
2024-05-14 13:07:09 +00:00
case strings.Contains(s, "\n"):
2024-05-14 13:07:09 +00:00
style = yaml_LITERAL_SCALAR_STYLE
2024-05-14 13:07:09 +00:00
case canUsePlain:
2024-05-14 13:07:09 +00:00
style = yaml_PLAIN_SCALAR_STYLE
2024-05-14 13:07:09 +00:00
default:
2024-05-14 13:07:09 +00:00
style = yaml_DOUBLE_QUOTED_SCALAR_STYLE
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
e.emitScalar(s, "", tag, style)
2024-05-14 13:07:09 +00:00
}
func (e *encoder) boolv(tag string, in reflect.Value) {
2024-05-14 13:07:09 +00:00
var s string
2024-05-14 13:07:09 +00:00
if in.Bool() {
2024-05-14 13:07:09 +00:00
s = "true"
2024-05-14 13:07:09 +00:00
} else {
2024-05-14 13:07:09 +00:00
s = "false"
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE)
2024-05-14 13:07:09 +00:00
}
func (e *encoder) intv(tag string, in reflect.Value) {
2024-05-14 13:07:09 +00:00
s := strconv.FormatInt(in.Int(), 10)
2024-05-14 13:07:09 +00:00
e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE)
2024-05-14 13:07:09 +00:00
}
func (e *encoder) uintv(tag string, in reflect.Value) {
2024-05-14 13:07:09 +00:00
s := strconv.FormatUint(in.Uint(), 10)
2024-05-14 13:07:09 +00:00
e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE)
2024-05-14 13:07:09 +00:00
}
func (e *encoder) timev(tag string, in reflect.Value) {
2024-05-14 13:07:09 +00:00
t := in.Interface().(time.Time)
2024-05-14 13:07:09 +00:00
s := t.Format(time.RFC3339Nano)
2024-05-14 13:07:09 +00:00
e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE)
2024-05-14 13:07:09 +00:00
}
func (e *encoder) floatv(tag string, in reflect.Value) {
2024-05-14 13:07:09 +00:00
// Issue #352: When formatting, use the precision of the underlying value
2024-05-14 13:07:09 +00:00
precision := 64
2024-05-14 13:07:09 +00:00
if in.Kind() == reflect.Float32 {
2024-05-14 13:07:09 +00:00
precision = 32
2024-05-14 13:07:09 +00:00
}
s := strconv.FormatFloat(in.Float(), 'g', -1, precision)
2024-05-14 13:07:09 +00:00
switch s {
2024-05-14 13:07:09 +00:00
case "+Inf":
2024-05-14 13:07:09 +00:00
s = ".inf"
2024-05-14 13:07:09 +00:00
case "-Inf":
2024-05-14 13:07:09 +00:00
s = "-.inf"
2024-05-14 13:07:09 +00:00
case "NaN":
2024-05-14 13:07:09 +00:00
s = ".nan"
2024-05-14 13:07:09 +00:00
}
2024-05-14 13:07:09 +00:00
e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE)
2024-05-14 13:07:09 +00:00
}
func (e *encoder) nilv() {
2024-05-14 13:07:09 +00:00
e.emitScalar("null", "", "", yaml_PLAIN_SCALAR_STYLE)
2024-05-14 13:07:09 +00:00
}
func (e *encoder) emitScalar(value, anchor, tag string, style yaml_scalar_style_t) {
2024-05-14 13:07:09 +00:00
implicit := tag == ""
2024-05-14 13:07:09 +00:00
e.must(yaml_scalar_event_initialize(&e.event, []byte(anchor), []byte(tag), []byte(value), implicit, implicit, style))
2024-05-14 13:07:09 +00:00
e.emit()
2024-05-14 13:07:09 +00:00
}