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