tagion_hibon_add_index_hibon

Add hibon to hibon instance by index

extern (C)
int
tagion_hibon_add_index_hibon
(,
const size_t index
,)

Parameters

instance const(HiBONT*)

pointer to the hibon instance

index size_t

The index to pute the hibon add

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");
const 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");
const _key = 1;
rt = tagion_hibon_add_index_hibon(&h, _key, &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");