tagion_hibon_get_document

Convert a hibon to a document

extern (C)
int
tagion_hibon_get_document
(,
uint8_t** buf
,
size_t* buf_len
)

Parameters

instance const(HiBONT*)

HiBONT instance

buf uint8_t**

the returned buf ptr

buf_len size_t*

length of the buf

Return Value

Type: int

ErrorCode

Examples

todoc

HiBONT h;
int rt = tagion_hibon_create(&h);
assert(rt == ErrorCode.none, "could not create hibon");
string key = "some_key";
string value = "some_value";
rt = tagion_hibon_add_string(&h, &key[0], key.length, &value[0], value.length);

HiBON string_hibon = cast(HiBON) h.hibon;
const doc = Document(string_hibon);

uint8_t* buf;
size_t buf_len;

rt = tagion_hibon_get_document(&h, &buf, &buf_len);
assert(rt == ErrorCode.none);
auto read_data = cast(immutable) buf[0..buf_len];
assert(doc == Document(read_data));