void lcbvrow_reset(lcbvrow_PARSER* ctx) { /** * We create a copy, and set its relevant fields. All other * fields are zeroed implicitly. Then we copy the object back. */ jsonsl_reset(ctx->jsn); jsonsl_reset(ctx->jsn_rdetails); lcb_string_clear(&ctx->current_buf); lcb_string_clear(&ctx->meta_buf); lcb_string_clear(&ctx->last_hk); /* Initially all callbacks are enabled so that we can search for the * rows array. */ ctx->jsn->action_callback_POP = initial_pop_callback; ctx->jsn->action_callback_PUSH = initial_push_callback; ctx->jsn->error_callback = parse_error_callback; ctx->jsn->max_callback_level = 4; ctx->jsn->data = ctx; jsonsl_enable_all_callbacks(ctx->jsn); ctx->have_error = 0; ctx->initialized = 0; ctx->meta_complete = 0; ctx->rowcount = 0; ctx->min_pos = 0; ctx->keep_pos = 0; ctx->header_len = 0; ctx->last_row_endpos = 0; }
void lcbvrow_parse_row(lcbvrow_PARSER *vp, lcbvrow_ROW *vr) { miniparse_ctx ctx = { NULL }; ctx.datum = vr; ctx.root = vr->row.iov_base; jsonsl_reset(vp->jsn_rdetails); jsonsl_enable_all_callbacks(vp->jsn_rdetails); vp->jsn_rdetails->max_callback_level = 3; vp->jsn_rdetails->action_callback_POP = miniparse_callback; vp->jsn_rdetails->data = &ctx; jsonsl_feed(vp->jsn_rdetails, vr->row.iov_base, vr->row.iov_len); }
void lcbex_vrow_reset(lcbex_vrow_ctx_t* ctx) { /** * We create a copy, and set its relevant fields. All other * fields are zeroed implicitly. Then we copy the object back. */ lcbex_vrow_ctx_t ctx_copy = { 0 }; jsonsl_reset(ctx->jsn); buffer_reset(&ctx->current_buf, 0); buffer_reset(&ctx->meta_buf, 0); buffer_reset(&ctx->last_hk, 0); /** * Initially all callbacks are enabled so that we can search for the * rows array. */ ctx->jsn->action_callback_POP = initial_pop_callback; ctx->jsn->action_callback_PUSH = initial_push_callback; ctx->jsn->error_callback = parse_error_callback; ctx->jsn->max_callback_level = 4; ctx->jsn->data = ctx; jsonsl_enable_all_callbacks(ctx->jsn); ctx_copy.jsn = ctx->jsn; ctx_copy.user_cookie = ctx->user_cookie; ctx_copy.callback = ctx->callback; ctx_copy.jpr = ctx->jpr; ctx_copy.current_buf = ctx->current_buf; ctx_copy.meta_buf = ctx->meta_buf; ctx_copy.last_hk = ctx->last_hk; *ctx = ctx_copy; }