1 #pragma once 2 #ifndef JQL_INTERNAL_H 3 #define JQL_INTERNAL_H 4 5 #include "jqp.h" 6 #include "binn.h" 7 #include <math.h> 8 9 10 /** Query object */ 11 struct _JQL { 12 bool dirty; 13 bool matched; 14 JQP_QUERY *qp; 15 JQP_AUX *aux; 16 const char *coll; 17 void *opaque; 18 }; 19 20 /** Placeholder value type */ 21 typedef enum { 22 JQVAL_NULL, // Do not reorder 23 JQVAL_I64, 24 JQVAL_F64, 25 JQVAL_STR, 26 JQVAL_BOOL, 27 JQVAL_RE, 28 JQVAL_JBLNODE, // Do not reorder JQVAL_JBLNODE,JQVAL_BINN must be last 29 JQVAL_BINN, 30 } jqval_type_t; 31 32 /** Placeholder value */ 33 typedef struct { 34 jqval_type_t type; 35 void (*freefn)(void*, void*); 36 void *freefn_op; 37 union { 38 JBL_NODE vnode; 39 binn *vbinn; 40 int64_t vi64; 41 double vf64; 42 const char *vstr; 43 bool vbool; 44 struct re *vre; 45 }; 46 } JQVAL; 47 48 JQVAL *jql_find_placeholder(JQL q, const char *name); 49 50 JQVAL *jql_unit_to_jqval(JQP_AUX *aux, JQPUNIT *unit, iwrc *rcp); 51 52 bool jql_jqval_as_int(JQVAL *jqval, int64_t *out); 53 54 jqval_type_t jql_binn_to_jqval(binn *vbinn, JQVAL *qval); 55 56 void jql_node_to_jqval(JBL_NODE jn, JQVAL *qv); 57 58 int jql_cmp_jqval_pair(const JQVAL *left, const JQVAL *right, iwrc *rcp); 59 60 bool jql_match_jqval_pair(JQP_AUX *aux, JQVAL *left, JQP_OP *jqop, JQVAL *right, iwrc *rcp); 61 62 #endif 63