Lines Matching refs:bn
25 binn_create(&(*jblp)->bn, BINN_OBJECT, 0, 0); in jbl_create_empty_object()
34 binn_create(&(*jblp)->bn, BINN_LIST, 0, 0); in jbl_create_empty_array()
39 binn_set_user_data(&jbl->bn, user_data, user_data_free_fn); in jbl_set_user_data()
43 return jbl->bn.user_data; in jbl_get_user_data()
48 if (((t != JBV_OBJECT) && (t != JBV_ARRAY)) || !jbl->bn.writable) { in jbl_set_int64()
51 binn *bv = &jbl->bn; in jbl_set_int64()
72 if (((t != JBV_OBJECT) && (t != JBV_ARRAY)) || !jbl->bn.writable) { in jbl_set_f64()
75 binn *bv = &jbl->bn; in jbl_set_f64()
96 if (((t != JBV_OBJECT) && (t != JBV_ARRAY)) || !jbl->bn.writable) { in jbl_set_string()
99 binn *bv = &jbl->bn; in jbl_set_string()
194 if (((t != JBV_OBJECT) && (t != JBV_ARRAY)) || !jbl->bn.writable) { in jbl_set_bool()
197 binn *bv = &jbl->bn; in jbl_set_bool()
218 if (((t != JBV_OBJECT) && (t != JBV_ARRAY)) || !jbl->bn.writable) { in jbl_set_null()
221 binn *bv = &jbl->bn; in jbl_set_null()
262 if (((t != JBV_OBJECT) && (t != JBV_ARRAY)) || !jbl->bn.writable) { in jbl_set_nested()
265 binn *bv = &jbl->bn; in jbl_set_nested()
268 if (!binn_object_set_value(bv, key, &v->bn)) { in jbl_set_nested()
276 if (!binn_list_add_value(bv, &v->bn)) { in jbl_set_nested()
297 jbl->bn.header = BINN_MAGIC; in jbl_from_buf_keep()
298 jbl->bn.type = type; in jbl_from_buf_keep()
299 jbl->bn.ptr = buf; in jbl_from_buf_keep()
300 jbl->bn.size = size; in jbl_from_buf_keep()
301 jbl->bn.count = count; in jbl_from_buf_keep()
302 jbl->bn.freefn = keep_on_destroy ? 0 : free; in jbl_from_buf_keep()
312 binn *bn = binn_copy(&src->bn); in jbl_clone() local
313 if (!bn) { in jbl_clone()
317 bn->allocated = 0; in jbl_clone()
318 memcpy(&t->bn, bn, sizeof(*bn)); in jbl_clone()
319 free(bn); in jbl_clone()
350 if (src->bn.writable && src->bn.dirty) { in jbl_clone_into_pool()
351 if (!binn_save_header(&src->bn)) { in jbl_clone_into_pool()
355 JBL jbl = iwpool_alloc(sizeof(*jbl) + src->bn.size, pool); in jbl_clone_into_pool()
360 memcpy(&jbl->bn, &src->bn, sizeof(jbl->bn)); in jbl_clone_into_pool()
361 jbl->bn.ptr = (char*) jbl + sizeof(*jbl); in jbl_clone_into_pool()
362 memcpy(jbl->bn.ptr, src->bn.ptr, src->bn.size); in jbl_clone_into_pool()
363 jbl->bn.freefn = 0; in jbl_clone_into_pool()
377 jbl->bn.header = BINN_MAGIC; in jbl_from_buf_keep_onstack()
378 jbl->bn.type = type; in jbl_from_buf_keep_onstack()
379 jbl->bn.ptr = buf; in jbl_from_buf_keep_onstack()
380 jbl->bn.size = size; in jbl_from_buf_keep_onstack()
381 jbl->bn.count = count; in jbl_from_buf_keep_onstack()
391 jbl->bn.header = BINN_MAGIC; in jbl_from_buf_keep_onstack2()
392 jbl->bn.type = type; in jbl_from_buf_keep_onstack2()
393 jbl->bn.ptr = buf; in jbl_from_buf_keep_onstack2()
394 jbl->bn.size = size; in jbl_from_buf_keep_onstack2()
395 jbl->bn.count = count; in jbl_from_buf_keep_onstack2()
402 binn_free(&jbl->bn); in jbl_destroy()
417 int btype = jbl->bn.type; in jbl_iterator_init()
423 if (!binn_iter_init(biter, &jbl->bn, btype)) { in jbl_iterator_init()
444 return binn_list_next(biter, &holder->bn); in jbl_iterator_next()
446 return binn_read_next_pair2(iter->type, biter, klen, pkey, &holder->bn); in jbl_iterator_next()
485 return _jbl_binn_type(jbl->bn.type); in jbl_type()
491 return (size_t) jbl->bn.count; in jbl_count()
495 return (size_t) jbl->bn.size; in jbl_size()
601 static iwrc _jbl_as_json(binn *bn, jbl_json_printer pt, void *op, int lvl, jbl_print_flags_t pf) { in _jbl_as_json() argument
616 switch (bn->type) { in _jbl_as_json()
619 if (!binn_iter_init(&iter, bn, bn->type)) { in _jbl_as_json()
624 if (bn->count && pretty) { in _jbl_as_json()
633 if (i < bn->count - 1) { in _jbl_as_json()
640 if (bn->count && pretty) { in _jbl_as_json()
648 if (!binn_iter_init(&iter, bn, bn->type)) { in _jbl_as_json()
653 if (bn->count && pretty) { in _jbl_as_json()
656 if (bn->type == BINN_OBJECT) { in _jbl_as_json()
670 if (i < bn->count - 1) { in _jbl_as_json()
693 if (i < bn->count - 1) { in _jbl_as_json()
701 if (bn->count && pretty) { in _jbl_as_json()
708 rc = _jbl_write_string(bn->ptr, -1, pt, op, pf); in _jbl_as_json()
711 llv = bn->vuint8; in _jbl_as_json()
714 llv = bn->vuint16; in _jbl_as_json()
717 llv = bn->vuint32; in _jbl_as_json()
720 llv = bn->vint8; // NOLINT(bugprone-signed-char-misuse) in _jbl_as_json()
723 llv = bn->vint16; in _jbl_as_json()
726 llv = bn->vint32; in _jbl_as_json()
729 llv = bn->vint64; in _jbl_as_json()
732 llv = (int64_t) bn->vuint64; in _jbl_as_json()
738 dv = bn->vfloat; in _jbl_as_json()
741 dv = bn->vdouble; in _jbl_as_json()
753 PT(bn->vbool ? "true" : "false", -1, 0, 1); in _jbl_as_json()
773 return _jbl_as_json(&jbl->bn, pt, op, 0, pf); in jbl_as_json()
851 switch (jbl->bn.type) { in jbl_get_i64()
853 return jbl->bn.vuint8; in jbl_get_i64()
855 return jbl->bn.vuint16; in jbl_get_i64()
857 return jbl->bn.vuint32; in jbl_get_i64()
859 return jbl->bn.vuint64; in jbl_get_i64()
861 return jbl->bn.vint8; in jbl_get_i64()
863 return jbl->bn.vint16; in jbl_get_i64()
865 return jbl->bn.vint32; in jbl_get_i64()
867 return jbl->bn.vint64; in jbl_get_i64()
869 return jbl->bn.vbool; in jbl_get_i64()
871 return (int64_t) jbl->bn.vfloat; in jbl_get_i64()
873 return (int64_t) jbl->bn.vdouble; in jbl_get_i64()
885 switch (jbl->bn.type) { in jbl_get_f64()
887 return jbl->bn.vdouble; in jbl_get_f64()
889 return jbl->bn.vfloat; in jbl_get_f64()
891 return jbl->bn.vuint8; in jbl_get_f64()
893 return jbl->bn.vuint16; in jbl_get_f64()
895 return jbl->bn.vuint32; in jbl_get_f64()
897 return jbl->bn.vuint64; in jbl_get_f64()
899 return jbl->bn.vint8; in jbl_get_f64()
901 return jbl->bn.vint16; in jbl_get_f64()
903 return jbl->bn.vint32; in jbl_get_f64()
905 return jbl->bn.vint64; in jbl_get_f64()
907 return jbl->bn.vbool; in jbl_get_f64()
914 assert(jbl && jbl->bn.type == BINN_STRING); in jbl_get_str()
915 if (jbl->bn.type != BINN_STRING) { in jbl_get_str()
918 return jbl->bn.ptr; in jbl_get_str()
923 assert(jbl && buf && jbl->bn.type == BINN_STRING); in jbl_copy_strn()
924 if (jbl->bn.type != BINN_STRING) { in jbl_copy_strn()
927 size_t slen = strlen(jbl->bn.ptr); in jbl_copy_strn()
929 memcpy(buf, jbl->bn.ptr, ret); in jbl_copy_strn()
934 if (jbl->bn.type != BINN_OBJECT) { in jbl_object_get_type()
938 if (!binn_object_get_value(&jbl->bn, key, &bv)) { in jbl_object_get_type()
946 if (jbl->bn.type != BINN_OBJECT) { in jbl_object_get_i64()
950 if (!binn_object_get_int64(&jbl->bn, key, &v)) { in jbl_object_get_i64()
959 if (jbl->bn.type != BINN_OBJECT) { in jbl_object_get_f64()
962 if (!binn_object_get_double(&jbl->bn, key, out)) { in jbl_object_get_f64()
970 if (jbl->bn.type != BINN_OBJECT) { in jbl_object_get_bool()
974 if (!binn_object_get_bool(&jbl->bn, key, &v)) { in jbl_object_get_bool()
983 if (jbl->bn.type != BINN_OBJECT) { in jbl_object_get_str()
986 if (!binn_object_get_str(&jbl->bn, key, (char**) out)) { in jbl_object_get_str()
993 if (jbl->bn.type != BINN_OBJECT) { in jbl_object_get_fill_jbl()
996 binn_free(&out->bn); in jbl_object_get_fill_jbl()
997 if (!binn_object_get_value(&jbl->bn, key, &out->bn)) { in jbl_object_get_fill_jbl()
1005 if (jbl->bn.writable && jbl->bn.dirty) { in jbl_as_buf()
1006 if (!binn_save_header(&jbl->bn)) { in jbl_as_buf()
1010 *buf = jbl->bn.ptr; in jbl_as_buf()
1011 *size = (size_t) jbl->bn.size; in jbl_as_buf()
1116 binn *bn = vctx->bn; in _jbl_visit() local
1126 if (!BINN_IS_CONTAINER_TYPE(bn->type)) { in _jbl_visit()
1129 if (!binn_iter_init(&it, bn, bn->type)) { in _jbl_visit()
1298 memcpy(&jbl->bn, bv, sizeof(*bv)); in _jbl_get_visitor2()
1316 memcpy(&jbl->bn, bv, sizeof(*bv)); in _jbl_get_visitor()
1327 .bn = &jbl->bn, in _jbl_at()
1338 .bn = &jbl->bn, in jbl_at2()
1991 const binn *bn, in _jbl_node_from_binn_impl() argument
2000 switch (bn->type) { in _jbl_node_from_binn_impl()
2003 rc = _jbl_create_node(ctx, bn, parent, key, klidx, &parent, clone_strings); in _jbl_node_from_binn_impl()
2008 if (!binn_iter_init(&iter, (binn*) bn, bn->type)) { in _jbl_node_from_binn_impl()
2011 if (bn->type == BINN_OBJECT) { in _jbl_node_from_binn_impl()
2016 } else if (bn->type == BINN_MAP) { in _jbl_node_from_binn_impl()
2024 rc = _jbl_create_node(ctx, bn, parent, key, klidx, &parent, clone_strings); in _jbl_node_from_binn_impl()
2029 if (!binn_iter_init(&iter, (binn*) bn, bn->type)) { in _jbl_node_from_binn_impl()
2038 rc = _jbl_create_node(ctx, bn, parent, key, klidx, 0, clone_strings); in _jbl_node_from_binn_impl()
2046 iwrc _jbl_node_from_binn(const binn *bn, JBL_NODE *node, bool clone_strings, IWPOOL *pool) { in _jbl_node_from_binn() argument
2050 iwrc rc = _jbl_node_from_binn_impl(&ctx, bn, 0, 0, -1, clone_strings); in _jbl_node_from_binn()
2478 return _jbl_binn_from_node(&jbl->bn, node); in _jbl_from_node()
2517 binn *bn; in _jbl_patch() local
2519 iwrc rc = _jbl_node_from_binn(&jbl->bn, &root, false, pool); in _jbl_patch()
2526 bn = &bv; in _jbl_patch()
2528 bn = 0; in _jbl_patch()
2530 binn_free(&jbl->bn); in _jbl_patch()
2531 if (bn) { in _jbl_patch()
2532 if (bn->writable && bn->dirty) { in _jbl_patch()
2533 binn_save_header(bn); in _jbl_patch()
2535 memcpy(&jbl->bn, bn, sizeof(jbl->bn)); in _jbl_patch()
2536 jbl->bn.allocated = 0; in _jbl_patch()
2538 memset(&jbl->bn, 0, sizeof(jbl->bn)); in _jbl_patch()
2605 return _jbl_node_from_binn(&jbl->bn, node, clone_strings, pool); in jbl_to_node()
2619 IWPOOL *pool = iwpool_create(jbl->bn.size); in jbl_patch()
2733 binn_free(&jbl->bn); in jbl_fill_from_node()
2734 memcpy(&jbl->bn, &bv, sizeof(jbl->bn)); in jbl_fill_from_node()
2735 jbl->bn.allocated = 0; in jbl_fill_from_node()
2831 IWPOOL *pool = iwpool_create(jbl->bn.size * 2); in jbl_merge_patch()
2835 iwrc rc = _jbl_node_from_binn(&jbl->bn, &target, false, pool); in jbl_merge_patch()
2843 binn_free(&jbl->bn); in jbl_merge_patch()
2844 memcpy(&jbl->bn, &bv, sizeof(jbl->bn)); in jbl_merge_patch()
2845 jbl->bn.allocated = 0; in jbl_merge_patch()