/** * This is called for the first few tokens, where we are still searching * for the row set. */ static void initial_push_callback(jsonsl_t jsn, jsonsl_action_t action, struct jsonsl_state_st *state, const jsonsl_char_t *at) { lcbex_vrow_ctx_t *ctx = (lcbex_vrow_ctx_t*)jsn->data; jsonsl_jpr_match_t match; if (ctx->have_error) { return; } if (JSONSL_STATE_IS_CONTAINER(state)) { jsonsl_jpr_match_state(jsn, state, ctx->last_hk.s, ctx->last_hk.len, &match); } buffer_reset(&ctx->last_hk, 0); if (ctx->initialized == 0) { if (state->type != JSONSL_T_OBJECT) { ctx->have_error = 1; return; } if (match != JSONSL_MATCH_POSSIBLE) { ctx->have_error = 1; return; } /* tag the state */ state->data = JOBJ_RESPONSE_ROOT; ctx->initialized = 1; return; } if (state->type == JSONSL_T_LIST && match == JSONSL_MATCH_POSSIBLE) { /* we have a match */ jsn->action_callback_POP = row_pop_callback; jsn->action_callback_PUSH = meta_header_complete_callback; state->data = JOBJ_ROWSET; } (void)action; /* always PUSH */ (void)at; }
/** * This is called for the first few tokens, where we are still searching * for the row set. */ static void initial_push_callback(jsonsl_t jsn, jsonsl_action_t action, struct jsonsl_state_st *state, const jsonsl_char_t *at) { lcbvrow_PARSER *ctx = (lcbvrow_PARSER*)jsn->data; jsonsl_jpr_match_t match = JSONSL_MATCH_UNKNOWN; if (ctx->have_error) { return; } if (JSONSL_STATE_IS_CONTAINER(state)) { jsonsl_jpr_match_state(jsn, state, ctx->last_hk.base, ctx->last_hk.nused, &match); } lcb_string_clear(&ctx->last_hk); if (ctx->initialized == 0) { if (state->type != JSONSL_T_OBJECT) { ctx->have_error = 1; return; } if (match != JSONSL_MATCH_POSSIBLE) { ctx->have_error = 1; return; } /* tag the state */ state->data = JOBJ_RESPONSE_ROOT; ctx->initialized = 1; return; } if (state->type == JSONSL_T_LIST && match == JSONSL_MATCH_POSSIBLE) { /* we have a match, e.g. "rows:[]" */ jsn->action_callback_POP = row_pop_callback; jsn->action_callback_PUSH = meta_header_complete_callback; state->data = JOBJ_ROWSET; } (void)action; /* always PUSH */ (void)at; }