scalar(p1, p2, p3, p4, p5, p6)
public
static VALUE scalar(
VALUE self,
VALUE value,
VALUE anchor,
VALUE tag,
VALUE plain,
VALUE quoted,
VALUE style
) {
yaml_emitter_t * emitter;
yaml_event_t event;
rb_encoding *encoding;
TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
Check_Type(value, T_STRING);
encoding = rb_utf8_encoding();
value = rb_str_export_to_enc(value, encoding);
if(!NIL_P(anchor)) {
Check_Type(anchor, T_STRING);
anchor = rb_str_export_to_enc(anchor, encoding);
}
if(!NIL_P(tag)) {
Check_Type(tag, T_STRING);
tag = rb_str_export_to_enc(tag, encoding);
}
yaml_scalar_event_initialize(
&event,
(yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)),
(yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)),
(yaml_char_t*)StringValuePtr(value),
(int)RSTRING_LEN(value),
plain ? 1 : 0,
quoted ? 1 : 0,
(yaml_scalar_style_t)NUM2INT(style)
);
emit(emitter, &event);
return self;
}