Query

## Query Query — Query object API, parsing and execution |

## Functions

rasqal_query * | rasqal_new_query ()
void | rasqal_free_query ()
int | rasqal_query_add_data_graph ()
int | rasqal_query_add_data_graphs ()
int | rasqal_query_add_prefix ()
int | rasqal_query_add_variable ()
int | rasqal_query_dataset_contains_named_graph ()
rasqal_query_results * | rasqal_query_execute ()
raptor_sequence * | rasqal_query_get_all_variable_sequence ()
raptor_sequence * | rasqal_query_get_anonymous_variable_sequence ()
rasqal_row * | rasqal_query_get_bindings_row ()
raptor_sequence * | rasqal_query_get_bindings_rows_sequence ()
rasqal_variable * | rasqal_query_get_bindings_variable ()
raptor_sequence * | rasqal_query_get_bindings_variables_sequence ()
raptor_sequence * | rasqal_query_get_bound_variable_sequence ()
rasqal_triple * | rasqal_query_get_construct_triple ()
raptor_sequence * | rasqal_query_get_construct_triples_sequence ()
rasqal_data_graph * | rasqal_query_get_data_graph ()
raptor_sequence * | rasqal_query_get_data_graph_sequence ()
raptor_sequence * | rasqal_query_get_describe_sequence ()
int | rasqal_query_get_distinct ()
int | rasqal_query_get_explain ()
rasqal_expression * | rasqal_query_get_group_condition ()
raptor_sequence * | rasqal_query_get_group_conditions_sequence ()
rasqal_graph_pattern * | rasqal_query_get_graph_pattern ()
raptor_sequence * | rasqal_query_get_graph_pattern_sequence ()
rasqal_expression * | rasqal_query_get_having_condition ()
raptor_sequence * | rasqal_query_get_having_conditions_sequence ()
const char * | rasqal_query_get_label ()
int | rasqal_query_get_limit ()
const char * | rasqal_query_get_name ()
int | rasqal_query_get_offset ()
rasqal_expression * | rasqal_query_get_order_condition ()
raptor_sequence * | rasqal_query_get_order_conditions_sequence ()
rasqal_prefix * | rasqal_query_get_prefix ()
raptor_sequence * | rasqal_query_get_prefix_sequence ()
rasqal_graph_pattern * | rasqal_query_get_query_graph_pattern ()
rasqal_triple * | rasqal_query_get_triple ()
raptor_sequence * | rasqal_query_get_triple_sequence ()
void * | rasqal_query_get_user_data ()
rasqal_variable * | rasqal_query_get_variable ()
rasqal_query_verb | rasqal_query_get_verb ()
int | rasqal_query_get_wildcard ()
int | rasqal_query_has_variable2 ()
int | rasqal_query_has_variable ()
int | rasqal_query_prepare ()
int | rasqal_query_print ()
int | rasqal_query_graph_pattern_visit2 ()
void | rasqal_query_graph_pattern_visit ()
void | rasqal_query_set_distinct ()
void | rasqal_query_set_explain ()
void | rasqal_query_set_limit ()
void | rasqal_query_set_offset ()
void | rasqal_query_set_user_data ()
int | rasqal_query_set_variable2 ()
int | rasqal_query_set_variable ()
int | rasqal_query_set_store_results ()
void | rasqal_query_set_wildcard ()
const char * | rasqal_query_verb_as_string ()
int | rasqal_query_write ()
int | rasqal_query_iostream_write_escaped_counted_string ()
unsigned char * | rasqal_query_escape_counted_string ()
int | rasqal_query_set_feature ()
int | rasqal_query_set_feature_string ()
int | rasqal_query_get_feature ()
const unsigned char * | rasqal_query_get_feature_string ()
rasqal_query_results_type | rasqal_query_get_result_type ()
rasqal_update_operation * | rasqal_query_get_update_operation ()
raptor_sequence * | rasqal_query_get_update_operations_sequence ()

## Types and Values

enum | rasqal_query_verb
typedef | rasqal_query

## Description

This class provides the main interface to the library. A query can be constructed by parsing a string, retrieving it from a URI and/or constructing it via API methods to build the query expression.

The query structures can be read via methods to return the query verb `rasqal_query_get_verb()`, the rasqal_data_graph RDF data sources with `rasqal_query_get_data_graph()` etc., the rasqal_graph_pattern tree with `rasqal_query_get_query_graph_pattern()`, the sequence of order conditions with `rasqal_query_get_order_condition()` etc., the rasqal_variable selected to return with `rasqal_query_get_bound_variable_sequence()` or `rasqal_query_get_all_variable_sequence()`, and so on.

To process a query string, the `rasqal_query_prepare()` method parses the query string in some query language and initialises the rasqal_query structures.

The query can be evaluated with the internal query engine against some source of matches using `rasqal_query_execute()` to give an rasqal_query_results. There are multiple forms of results that can include variable bindings, a boolean or an RDF graph that can be tested for with methods on rasqal_query_results and then retrieved.

## Functions

### rasqal_new_query ()

    rasqal_query *
    rasqal_new_query (rasqal_world *world,
                      const char *name,
                      const char *uri);

#### Returns

### rasqal_free_query ()

    void
    rasqal_free_query (rasqal_query *query);

### rasqal_query_add_data_graph ()

    int
    rasqal_query_add_data_graph (rasqal_query *query,
                                 rasqal_data_graph *data_graph);

#### Returns

### rasqal_query_add_data_graphs ()

    int
    rasqal_query_add_data_graphs (rasqal_query *query,
                                  raptor_sequence *data_graphs);

#### Returns

### rasqal_query_add_prefix ()

    int
    rasqal_query_add_prefix (rasqal_query *query,
                             rasqal_prefix *prefix);

#### Returns

### rasqal_query_add_variable ()

    int
    rasqal_query_add_variable (rasqal_query *query,
                               rasqal_variable *var);

#### Returns

### rasqal_query_dataset_contains_named_graph ()

    int
    rasqal_query_dataset_contains_named_graph
                                   (rasqal_query *query,
                                    raptor_uri *graph_uri);

#### Returns

### rasqal_query_execute ()

    rasqal_query_results *
    rasqal_query_execute (rasqal_query *query);

#### Returns

### rasqal_query_get_all_variable_sequence ()

    raptor_sequence *
    rasqal_query_get_all_variable_sequence
                                   (rasqal_query *query);

#### Returns

### rasqal_query_get_anonymous_variable_sequence ()

    raptor_sequence *
    rasqal_query_get_anonymous_variable_sequence
                                   (rasqal_query *query);

#### Returns

### rasqal_query_get_bindings_row ()

    rasqal_row *
    rasqal_query_get_bindings_row (rasqal_query *query,
                                   int idx);

#### Returns

### rasqal_query_get_bindings_rows_sequence ()

    raptor_sequence *
    rasqal_query_get_bindings_rows_sequence
                                   (rasqal_query *query);

#### Returns

### rasqal_query_get_bindings_variable ()

    rasqal_variable *
    rasqal_query_get_bindings_variable (rasqal_query *query,
                                        int idx);

#### Returns

### rasqal_query_get_bindings_variables_sequence ()

    raptor_sequence *
    rasqal_query_get_bindings_variables_sequence
                                   (rasqal_query *query);

#### Returns

### rasqal_query_get_bound_variable_sequence ()

    raptor_sequence *
    rasqal_query_get_bound_variable_sequence
                                   (rasqal_query *query);

#### Returns

### rasqal_query_get_construct_triple ()

    rasqal_triple *
    rasqal_query_get_construct_triple (rasqal_query *query,
                                       int idx);

#### Returns

### rasqal_query_get_construct_triples_sequence ()

    raptor_sequence *
    rasqal_query_get_construct_triples_sequence
                                   (rasqal_query *query);

#### Returns

### rasqal_query_get_data_graph ()

    rasqal_data_graph *
    rasqal_query_get_data_graph (rasqal_query *query,
                                 int idx);

#### Returns

### rasqal_query_get_data_graph_sequence ()

    raptor_sequence *
    rasqal_query_get_data_graph_sequence (rasqal_query *query);

#### Returns

### rasqal_query_get_describe_sequence ()

    raptor_sequence *
    rasqal_query_get_describe_sequence (rasqal_query *query);

#### Returns

### rasqal_query_get_distinct ()

    int
    rasqal_query_get_distinct (rasqal_query *query);

#### Returns

### rasqal_query_get_explain ()

    int
    rasqal_query_get_explain (rasqal_query *query);

#### Returns

### rasqal_query_get_group_condition ()

    rasqal_expression *
    rasqal_query_get_group_condition (rasqal_query *query,
                                      int idx);

#### Returns

### rasqal_query_get_group_conditions_sequence ()

    raptor_sequence *
    rasqal_query_get_group_conditions_sequence
                                   (rasqal_query *query);

#### Returns

### rasqal_query_get_graph_pattern ()

    rasqal_graph_pattern *
    rasqal_query_get_graph_pattern (rasqal_query *query,
                                    int idx);

#### Returns

### rasqal_query_get_graph_pattern_sequence ()

    raptor_sequence *
    rasqal_query_get_graph_pattern_sequence
                                   (rasqal_query *query);

#### Returns

### rasqal_query_get_having_condition ()

    rasqal_expression *
    rasqal_query_get_having_condition (rasqal_query *query,
                                       int idx);

#### Returns

### rasqal_query_get_having_conditions_sequence ()

    raptor_sequence *
    rasqal_query_get_having_conditions_sequence
                                   (rasqal_query *query);

#### Returns

### rasqal_query_get_label ()

    const char *
    rasqal_query_get_label (rasqal_query *query);

#### Returns

### rasqal_query_get_limit ()

    int
    rasqal_query_get_limit (rasqal_query *query);

#### Returns

### rasqal_query_get_name ()

    const char *
    rasqal_query_get_name (rasqal_query *query);

#### Returns

### rasqal_query_get_offset ()

    int
    rasqal_query_get_offset (rasqal_query *query);

#### Returns

### rasqal_query_get_order_condition ()

    rasqal_expression *
    rasqal_query_get_order_condition (rasqal_query *query,
                                      int idx);

#### Returns

### rasqal_query_get_order_conditions_sequence ()

    raptor_sequence *
    rasqal_query_get_order_conditions_sequence
                                   (rasqal_query *query);

#### Returns

### rasqal_query_get_prefix ()

    rasqal_prefix *
    rasqal_query_get_prefix (rasqal_query *query,
                             int idx);

#### Returns

### rasqal_query_get_prefix_sequence ()

    raptor_sequence *
    rasqal_query_get_prefix_sequence (rasqal_query *query);

#### Returns

### rasqal_query_get_query_graph_pattern ()

    rasqal_graph_pattern *
    rasqal_query_get_query_graph_pattern (rasqal_query *query);

#### Returns

### rasqal_query_get_triple ()

    rasqal_triple *
    rasqal_query_get_triple (rasqal_query *query,
                             int idx);

#### Returns

### rasqal_query_get_triple_sequence ()

    raptor_sequence *
    rasqal_query_get_triple_sequence (rasqal_query *query);

#### Returns

### rasqal_query_get_user_data ()

    void *
    rasqal_query_get_user_data (rasqal_query *query);

#### Returns

### rasqal_query_get_variable ()

    rasqal_variable *
    rasqal_query_get_variable (rasqal_query *query,
                               int idx);

#### Returns

### rasqal_query_get_verb ()

    rasqal_query_verb
    rasqal_query_get_verb (rasqal_query *query);

#### Returns

### rasqal_query_get_wildcard ()

    int
    rasqal_query_get_wildcard (rasqal_query *query);

#### Returns

### rasqal_query_has_variable2 ()

    int
    rasqal_query_has_variable2 (rasqal_query *query,
                                rasqal_variable_type type,
                                const char *name);

#### Returns

### rasqal_query_has_variable ()

    int
    rasqal_query_has_variable (rasqal_query *query,
                               const char *name);

`rasqal_query_has_variable` is deprecated and should not be used in newly-written code.

#### Returns

### rasqal_query_prepare ()

    int
    rasqal_query_prepare (rasqal_query *query,
                          const char *query_string,
                          raptor_uri *base_uri);

#### Returns

### rasqal_query_print ()

    int
    rasqal_query_print (rasqal_query *query,
                        FILE *fh);

#### Returns

### rasqal_query_graph_pattern_visit2 ()

    int
    rasqal_query_graph_pattern_visit2 (rasqal_query *query,
                                       rasqal_graph_pattern_visit_fn visit_fn,
                                       void *data);

#### Returns

### rasqal_query_graph_pattern_visit ()

    void
    rasqal_query_graph_pattern_visit (rasqal_query *query,
                                      rasqal_graph_pattern_visit_fn visit_fn,
                                      void *data);

`rasqal_query_graph_pattern_visit` is deprecated and should not be used in newly-written code.

### rasqal_query_set_distinct ()

    void
    rasqal_query_set_distinct (rasqal_query *query,
                               int distinct_mode);

### rasqal_query_set_explain ()

    void
    rasqal_query_set_explain (rasqal_query *query,
                              int is_explain);

### rasqal_query_set_limit ()

    void
    rasqal_query_set_limit (rasqal_query *query,
                            int limit);

### rasqal_query_set_offset ()

    void
    rasqal_query_set_offset (rasqal_query *query,
                             int offset);

### rasqal_query_set_user_data ()

    void
    rasqal_query_set_user_data (rasqal_query *query,
                                void *user_data);

### rasqal_query_set_variable2 ()

    int
    rasqal_query_set_variable2 (rasqal_query *query,
                                rasqal_variable_type type,
                                const char *name,
                                rasqal_literal *value);

#### Returns

### rasqal_query_set_variable ()

    int
    rasqal_query_set_variable (rasqal_query *query,
                               const char *name,
                               rasqal_literal *value);

`rasqal_query_set_variable` is deprecated and should not be used in newly-written code.

#### Returns

### rasqal_query_set_store_results ()

    int
    rasqal_query_set_store_results (rasqal_query *query,
                                    int store_results);

#### Returns

### rasqal_query_set_wildcard ()

    void
    rasqal_query_set_wildcard (rasqal_query *query,
                               int wildcard);

### rasqal_query_verb_as_string ()

    const char *
    rasqal_query_verb_as_string (rasqal_query_verb verb);

#### Returns

### rasqal_query_write ()

    int
    rasqal_query_write (raptor_iostream *iostr,
                        rasqal_query *query,
                        raptor_uri *format_uri,
                        raptor_uri *base_uri);

#### Returns

### rasqal_query_iostream_write_escaped_counted_string ()

    int
    rasqal_query_iostream_write_escaped_counted_string
                                   (rasqal_query *query,
                                    raptor_iostream *iostr,
                                    const unsigned char *string,
                                    size_t len);

#### Returns

### rasqal_query_escape_counted_string ()

    unsigned char *
    rasqal_query_escape_counted_string (rasqal_query *query,
                                        const char *string,
                                        size_t len,
                                        size_t *output_len_p);

#### Returns

### rasqal_query_set_feature ()

    int
    rasqal_query_set_feature (rasqal_query *query,
                              rasqal_feature feature,
                              int value);

#### Returns

### rasqal_query_set_feature_string ()

    int
    rasqal_query_set_feature_string (rasqal_query *query,
                                     rasqal_feature feature,
                                     const char *value);

#### Returns

### rasqal_query_get_feature ()

    int
    rasqal_query_get_feature (rasqal_query *query,
                              rasqal_feature feature);

#### Returns

### rasqal_query_get_feature_string ()

    const unsigned char *
    rasqal_query_get_feature_string (rasqal_query *query,
                                     rasqal_feature feature);

#### Returns

### rasqal_query_get_result_type ()

    rasqal_query_results_type
    rasqal_query_get_result_type (rasqal_query *query);

#### Returns

### rasqal_query_get_update_operation ()

    rasqal_update_operation *
    rasqal_query_get_update_operation (rasqal_query *query,
                                       int idx);

#### Returns

### rasqal_query_get_update_operations_sequence ()

    raptor_sequence *
    rasqal_query_get_update_operations_sequence
                                   (rasqal_query *query);

#### Returns

## Types and Values

### enum rasqal_query_verb

Query main operation verbs describing the major type of query being performed.

#### Members

RASQAL_QUERY_VERB_UNKNOWN | Internal |
RASQAL_QUERY_VERB_SELECT | SPARQL query select verb. |
RASQAL_QUERY_VERB_CONSTRUCT | SPARQL query construct verb. |
RASQAL_QUERY_VERB_DESCRIBE | SPARQL query describe verb. |
RASQAL_QUERY_VERB_ASK | SPARQL query ask verb. |
RASQAL_QUERY_VERB_DELETE | LAQRS query delete verb. |
RASQAL_QUERY_VERB_INSERT | LAQRS query insert verb. |
RASQAL_QUERY_VERB_UPDATE | SPARQL 1.1 (draft) update operation |
RASQAL_QUERY_VERB_LAST | Internal |

### rasqal_query

    rasqal_graph_query* query;

Rasqal query class.