doc buffer
doc len
See DocumentTextFormat for supported formats
returned pointer
returned str len
import tagion.hibon.HiBONJSON; import tagion.hibon.HiBONtoText; import std.format; auto h = new HiBON; h["hai"] = "bon"; const doc = Document(h); // hex char* str_value; size_t str_len; int rt = tagion_document_get_text(&doc.data[0], doc.data.length, DocumentTextFormat.HEX, &str_value, &str_len); assert(rt == ErrorCode.none); auto str = str_value[0..str_len]; assert(str == format("%(%02x%)", doc.serialize)); // json rt = tagion_document_get_text(&doc.data[0], doc.data.length, DocumentTextFormat.JSON, &str_value, &str_len); assert(rt == ErrorCode.none); str = str_value[0..str_len]; assert(str == doc.toJSON.toString); // jsonpretty rt = tagion_document_get_text(&doc.data[0], doc.data.length, DocumentTextFormat.PRETTYJSON, &str_value, &str_len); assert(rt == ErrorCode.none); str = str_value[0..str_len]; assert(str == doc.toPretty); // base64 rt = tagion_document_get_text(&doc.data[0], doc.data.length, DocumentTextFormat.BASE64, &str_value, &str_len); assert(rt == ErrorCode.none); str = str_value[0..str_len]; assert(str == doc.encodeBase64); // none existing format rt = tagion_document_get_text(&doc.data[0], doc.data.length, 100, &str_value, &str_len); assert(rt == ErrorCode.error);
Get document as string