/* * Function is to search from the list for the particular arg * if found then that particulat calback function will be called. * Input: * list_t *list_obj : A reference to the list; * cbk_fun_t match_function : The calback function; * void *arg : The argument to the call back * function as well as matching parameter. * Output: * l_node_t * : A reference to the matched argument in * the list. * * */ l_node_t * search_in_list (list_t *list_obj, cbk_fun_t match_function, void *arg) { l_node_t *ret = NULL; boolean_t var; /* Assign the first link to the temp */ l_node_t *temp = list_obj -> first_node; /* If the list is empty */ if (temp == NULL) { goto out; } /* Assign the function name */ match_function = match_arg_list; while (temp -> next == NULL) { /* If arg matches */ if (match_function (temp -> data, arg) == 1) { ret = temp; goto out; } temp = temp -> next; } if (temp -> next == NULL) { ret = NULL; goto out; } out: return ret; }
IntrinsicExpression::UP maybe_replace(const Function &function, const IIndexEnvironment &env) const override { vespalib::string reduce_dim; if (match_function(function, reduce_dim)) { MatchInputs match_inputs; match_inputs.process(function.param_name(0)); match_inputs.process(function.param_name(1)); if (match_inputs.matched() && (reduce_dim.empty() || (reduce_dim == match_inputs.attribute_dim))) { return IntrinsicBlueprintAdapter::try_create(*proto, env, {match_inputs.attribute, match_inputs.query}); } } return IntrinsicExpression::UP(nullptr); }
GSList * filter_types (GSList *l, GObject *dlg, bool (*match_function)(SPItem *, GtkWidget *)) { GtkWidget *widget = GTK_WIDGET (gtk_object_get_data (GTK_OBJECT (dlg), "types")); GtkWidget *alltypes = GTK_WIDGET (gtk_object_get_data (GTK_OBJECT (widget), "all")); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (alltypes))) return l; GSList *n = NULL; for (GSList *i = l; i != NULL; i = i->next) { if (match_function (SP_ITEM(i->data), widget)) { n = g_slist_prepend (n, i->data); } } return n; }
GSList * filter_onefield (GSList *l, GObject *dlg, const gchar *field, bool (*match_function)(SPItem *, const gchar *, bool), bool exact) { GtkWidget *widget = GTK_WIDGET (gtk_object_get_data (GTK_OBJECT (dlg), field)); const gchar *text = gtk_entry_get_text (GTK_ENTRY(widget)); if (strlen (text) != 0) { GSList *n = NULL; for (GSList *i = l; i != NULL; i = i->next) { if (match_function (SP_ITEM(i->data), text, exact)) { n = g_slist_prepend (n, i->data); } } return n; } else { return l; } return NULL; }