tagion_hibon_add_hibon

Add hibon to hibon instance

extern (C)
int
tagion_hibon_add_hibon
(,
const char* key
,
const size_t key_len
,)

Parameters

instance const(HiBONT*)

pointer to the hibon instance

key char*

pointer to the key

key_len size_t

length of the key

sub_instance const(HiBONT*)

pointer to the sub hibon instance that needs to be inserted

Return Value

Type: int

ErrorCode

Examples

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

// add it to a new hibon instance as a subhibon;
HiBONT h;
rt = tagion_hibon_create(&h);
assert(rt == ErrorCode.none, "Could not create hibon");
string _key = "sub_doc_key";
rt = tagion_hibon_add_hibon(&h, &_key[0], _key.length, &sub_h);
assert(rt == ErrorCode.none);
HiBON result = cast(HiBON) h.hibon;
assert(result[_key].get!HiBON == string_hibon, "The read subhibon was not the same");