<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" 
               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
]>
<refentry id="rasqal-section-expression">
<refmeta>
<refentrytitle role="top_of_page" id="rasqal-section-expression.top_of_page">Expressions</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>RASQAL Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>Expressions</refname>
<refpurpose>Query language expressions.</refpurpose>
<!--[<xref linkend="desc" endterm="desc.title"/>]-->
</refnamediv>

<refsynopsisdiv id="rasqal-section-expression.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>
typedef             <link linkend="rasqal-expression">rasqal_expression</link>;
enum                <link linkend="rasqal-op">rasqal_op</link>;
enum                <link linkend="rasqal-compare-flags">rasqal_compare_flags</link>;
enum                <link linkend="rasqal-pattern-flags">rasqal_pattern_flags</link>;
<link linkend="rasqal-expression">rasqal_expression</link>*  <link linkend="rasqal-new-0op-expression">rasqal_new_0op_expression</link>           (<link linkend="rasqal-op">rasqal_op</link> op);
<link linkend="rasqal-expression">rasqal_expression</link>*  <link linkend="rasqal-new-1op-expression">rasqal_new_1op_expression</link>           (<link linkend="rasqal-op">rasqal_op</link> op,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *arg);
<link linkend="rasqal-expression">rasqal_expression</link>*  <link linkend="rasqal-new-2op-expression">rasqal_new_2op_expression</link>           (<link linkend="rasqal-op">rasqal_op</link> op,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *arg1,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *arg2);
<link linkend="rasqal-expression">rasqal_expression</link>*  <link linkend="rasqal-new-3op-expression">rasqal_new_3op_expression</link>           (<link linkend="rasqal-op">rasqal_op</link> op,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *arg1,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *arg2,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *arg3);
<link linkend="rasqal-expression">rasqal_expression</link>*  <link linkend="rasqal-new-cast-expression">rasqal_new_cast_expression</link>          (<link linkend="raptor-uri">raptor_uri</link> *name,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *value);
<link linkend="rasqal-expression">rasqal_expression</link>*  <link linkend="rasqal-new-function-expression">rasqal_new_function_expression</link>      (<link linkend="raptor-uri">raptor_uri</link> *name,
                                                         <link linkend="raptor-sequence">raptor_sequence</link> *args);
<link linkend="rasqal-expression">rasqal_expression</link>*  <link linkend="rasqal-new-literal-expression">rasqal_new_literal_expression</link>       (<link linkend="rasqal-literal">rasqal_literal</link> *literal);
<link linkend="rasqal-expression">rasqal_expression</link>*  <link linkend="rasqal-new-string-op-expression">rasqal_new_string_op_expression</link>     (<link linkend="rasqal-op">rasqal_op</link> op,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *arg1,
                                                         <link linkend="rasqal-literal">rasqal_literal</link> *literal);
<link linkend="rasqal-expression">rasqal_expression</link>*  <link linkend="rasqal-new-expression-from-expression">rasqal_new_expression_from_expression</link>
                                                        (<link linkend="rasqal-expression">rasqal_expression</link> *e);
<link linkend="void">void</link>                <link linkend="rasqal-free-expression">rasqal_free_expression</link>              (<link linkend="rasqal-expression">rasqal_expression</link> *e);
<link linkend="rasqal-literal">rasqal_literal</link>*     <link linkend="rasqal-expression-evaluate">rasqal_expression_evaluate</link>          (<link linkend="rasqal-query">rasqal_query</link> *query,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *e,
                                                         <link linkend="int">int</link> flags);
<link linkend="void">void</link>                <link linkend="rasqal-expression-print">rasqal_expression_print</link>             (<link linkend="rasqal-expression">rasqal_expression</link> *e,
                                                         <link linkend="FILE:CAPS">FILE</link> *fh);
<link linkend="void">void</link>                <link linkend="rasqal-expression-print-op">rasqal_expression_print_op</link>          (<link linkend="rasqal-expression">rasqal_expression</link> *e,
                                                         <link linkend="FILE:CAPS">FILE</link> *fh);
<link linkend="int">int</link>                 (<link linkend="rasqal-expression-visit-fn">*rasqal_expression_visit_fn</link>)       (<link linkend="void">void</link> *user_data,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *e);
<link linkend="int">int</link>                 <link linkend="rasqal-expression-visit">rasqal_expression_visit</link>             (<link linkend="rasqal-expression">rasqal_expression</link> *e,
                                                         <link linkend="rasqal-expression-visit-fn">rasqal_expression_visit_fn</link> fn,
                                                         <link linkend="void">void</link> *user_data);
</synopsis>
</refsynopsisdiv>









<refsect1 id="rasqal-section-expression.description" role="desc">
<title role="desc.title">Description</title>
<para>
Expressions form an expression tree that can be evaluated using
<link linkend="rasqal-expression-evaluate"><function>rasqal_expression_evaluate()</function></link> over <link linkend="rasqal-op"><type>rasqal_op</type></link> operators, <link linkend="rasqal-literal"><type>rasqal_literal</type></link>
constants and <link linkend="rasqal-variable"><type>rasqal_variable</type></link> values bound in some
<link linkend="rasqal-query-result"><type>rasqal_query_result</type></link>.  The result is a <link linkend="rasqal-literal"><type>rasqal_literal</type></link> value.
</para>
</refsect1>

<refsect1 id="rasqal-section-expression.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="rasqal-expression" role="typedef">
<title>rasqal_expression</title>
<indexterm zone="rasqal-expression"><primary>rasqal_expression</primary></indexterm><programlisting>typedef struct rasqal_expression_s rasqal_expression;
</programlisting>
<para>
expression (arg1), unary op (arg1), binary op (arg1,arg2),
literal or variable</para>
<para>

</para></refsect2>
<refsect2 id="rasqal-op" role="enum">
<title>enum rasqal_op</title>
<indexterm zone="rasqal-op"><primary>rasqal_op</primary></indexterm><programlisting>typedef enum {
  /* internal */
  RASQAL_EXPR_UNKNOWN,
  RASQAL_EXPR_AND,
  RASQAL_EXPR_OR,
  RASQAL_EXPR_EQ,
  RASQAL_EXPR_NEQ,
  RASQAL_EXPR_LT,
  RASQAL_EXPR_GT,
  RASQAL_EXPR_LE,
  RASQAL_EXPR_GE,
  RASQAL_EXPR_UMINUS,
  RASQAL_EXPR_PLUS,
  RASQAL_EXPR_MINUS,
  RASQAL_EXPR_STAR,
  RASQAL_EXPR_SLASH,
  RASQAL_EXPR_REM,
  RASQAL_EXPR_STR_EQ,
  RASQAL_EXPR_STR_NEQ,
  RASQAL_EXPR_STR_MATCH,
  RASQAL_EXPR_STR_NMATCH,
  RASQAL_EXPR_TILDE,
  RASQAL_EXPR_BANG,
  RASQAL_EXPR_LITERAL,
  RASQAL_EXPR_FUNCTION,
  RASQAL_EXPR_BOUND,
  RASQAL_EXPR_STR,
  RASQAL_EXPR_LANG,
  RASQAL_EXPR_DATATYPE,
  RASQAL_EXPR_ISURI,
  RASQAL_EXPR_ISBLANK,
  RASQAL_EXPR_ISLITERAL,
  RASQAL_EXPR_CAST,
  RASQAL_EXPR_ORDER_COND_ASC,
  RASQAL_EXPR_ORDER_COND_DESC,
  RASQAL_EXPR_LANGMATCHES,
  RASQAL_EXPR_REGEX,
  RASQAL_EXPR_GROUP_COND_ASC,
  RASQAL_EXPR_GROUP_COND_DESC,
  RASQAL_EXPR_COUNT,
  RASQAL_EXPR_VARSTAR,
  RASQAL_EXPR_SAMETERM,
  /* internal */
  RASQAL_EXPR_LAST= RASQAL_EXPR_SAMETERM
} rasqal_op;
</programlisting>
<para>
Rasqal expression operators.  A mixture of unary, binary and
tertiary operators (string matches).  Also includes casting and
two ordering operators from ORDER BY in SPARQL.</para>
<para>

</para><variablelist role="enum">
<varlistentry id="RASQAL-EXPR-UNKNOWN:CAPS" role="constant">
<term><literal>RASQAL_EXPR_UNKNOWN</literal></term>
<listitem><simpara> Internal
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-AND:CAPS" role="constant">
<term><literal>RASQAL_EXPR_AND</literal></term>
<listitem><simpara> Expression for AND(A, B)
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-OR:CAPS" role="constant">
<term><literal>RASQAL_EXPR_OR</literal></term>
<listitem><simpara> Expression for OR(A, B)
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-EQ:CAPS" role="constant">
<term><literal>RASQAL_EXPR_EQ</literal></term>
<listitem><simpara> Expression for A equals B
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-NEQ:CAPS" role="constant">
<term><literal>RASQAL_EXPR_NEQ</literal></term>
<listitem><simpara> Expression for A not equals B.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-LT:CAPS" role="constant">
<term><literal>RASQAL_EXPR_LT</literal></term>
<listitem><simpara> Expression for A less than B.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-GT:CAPS" role="constant">
<term><literal>RASQAL_EXPR_GT</literal></term>
<listitem><simpara> Expression for A greather than B.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-LE:CAPS" role="constant">
<term><literal>RASQAL_EXPR_LE</literal></term>
<listitem><simpara> Expression for A less than or equal to B.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-GE:CAPS" role="constant">
<term><literal>RASQAL_EXPR_GE</literal></term>
<listitem><simpara> Expression for A greater than or equal to B.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-UMINUS:CAPS" role="constant">
<term><literal>RASQAL_EXPR_UMINUS</literal></term>
<listitem><simpara> Expression for -A.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-PLUS:CAPS" role="constant">
<term><literal>RASQAL_EXPR_PLUS</literal></term>
<listitem><simpara> Expression for +A.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-MINUS:CAPS" role="constant">
<term><literal>RASQAL_EXPR_MINUS</literal></term>
<listitem><simpara> Expression for A-B.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-STAR:CAPS" role="constant">
<term><literal>RASQAL_EXPR_STAR</literal></term>
<listitem><simpara> Expression for A*B.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-SLASH:CAPS" role="constant">
<term><literal>RASQAL_EXPR_SLASH</literal></term>
<listitem><simpara> Expression for A/B.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-REM:CAPS" role="constant">
<term><literal>RASQAL_EXPR_REM</literal></term>
<listitem><simpara> Expression for A/B remainder.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-STR-EQ:CAPS" role="constant">
<term><literal>RASQAL_EXPR_STR_EQ</literal></term>
<listitem><simpara> Expression for A string equals B.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-STR-NEQ:CAPS" role="constant">
<term><literal>RASQAL_EXPR_STR_NEQ</literal></term>
<listitem><simpara> Expression for A string not-equals B.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-STR-MATCH:CAPS" role="constant">
<term><literal>RASQAL_EXPR_STR_MATCH</literal></term>
<listitem><simpara> Expression for string A matches literal regex B with flags.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-STR-NMATCH:CAPS" role="constant">
<term><literal>RASQAL_EXPR_STR_NMATCH</literal></term>
<listitem><simpara> Expression for string A not-matches literal regex B with flags.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-TILDE:CAPS" role="constant">
<term><literal>RASQAL_EXPR_TILDE</literal></term>
<listitem><simpara> Expression for binary not A.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-BANG:CAPS" role="constant">
<term><literal>RASQAL_EXPR_BANG</literal></term>
<listitem><simpara> Expression for logical not A.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-LITERAL:CAPS" role="constant">
<term><literal>RASQAL_EXPR_LITERAL</literal></term>
<listitem><simpara> Expression for a <link linkend="rasqal-literal"><type>rasqal_literal</type></link>.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-FUNCTION:CAPS" role="constant">
<term><literal>RASQAL_EXPR_FUNCTION</literal></term>
<listitem><simpara> Expression for a function A with arguments (B...).
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-BOUND:CAPS" role="constant">
<term><literal>RASQAL_EXPR_BOUND</literal></term>
<listitem><simpara> Expression for SPARQL ISBOUND(A).
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-STR:CAPS" role="constant">
<term><literal>RASQAL_EXPR_STR</literal></term>
<listitem><simpara> Expression for SPARQL STR(A).
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-LANG:CAPS" role="constant">
<term><literal>RASQAL_EXPR_LANG</literal></term>
<listitem><simpara> Expression for SPARQL LANG(A).
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-DATATYPE:CAPS" role="constant">
<term><literal>RASQAL_EXPR_DATATYPE</literal></term>
<listitem><simpara> Expression for SPARQL DATATYPE(A).
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-ISURI:CAPS" role="constant">
<term><literal>RASQAL_EXPR_ISURI</literal></term>
<listitem><simpara> Expression for SPARQL ISURI(A).
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-ISBLANK:CAPS" role="constant">
<term><literal>RASQAL_EXPR_ISBLANK</literal></term>
<listitem><simpara> Expression for SPARQL ISBLANK(A).
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-ISLITERAL:CAPS" role="constant">
<term><literal>RASQAL_EXPR_ISLITERAL</literal></term>
<listitem><simpara> Expression for SPARQL ISLITERAL(A).
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-CAST:CAPS" role="constant">
<term><literal>RASQAL_EXPR_CAST</literal></term>
<listitem><simpara> Expression for cast literal A to type B.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-ORDER-COND-ASC:CAPS" role="constant">
<term><literal>RASQAL_EXPR_ORDER_COND_ASC</literal></term>
<listitem><simpara> Expression for SPARQL order condition ascending.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-ORDER-COND-DESC:CAPS" role="constant">
<term><literal>RASQAL_EXPR_ORDER_COND_DESC</literal></term>
<listitem><simpara> Expression for SPARQL order condition descending.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-LANGMATCHES:CAPS" role="constant">
<term><literal>RASQAL_EXPR_LANGMATCHES</literal></term>
<listitem><simpara> Expression for SPARQL LANGMATCHES(A, B).
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-REGEX:CAPS" role="constant">
<term><literal>RASQAL_EXPR_REGEX</literal></term>
<listitem><simpara> Expression for string A matches expression regex B with flags.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-GROUP-COND-ASC:CAPS" role="constant">
<term><literal>RASQAL_EXPR_GROUP_COND_ASC</literal></term>
<listitem><simpara> Expression for LAQRS group condition ascending.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-GROUP-COND-DESC:CAPS" role="constant">
<term><literal>RASQAL_EXPR_GROUP_COND_DESC</literal></term>
<listitem><simpara> Expression for LAQRS group condition descending.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-COUNT:CAPS" role="constant">
<term><literal>RASQAL_EXPR_COUNT</literal></term>
<listitem><simpara> Expression for LAQRS select <link linkend="COUNT:CAPS"><function>COUNT()</function></link>
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-VARSTAR:CAPS" role="constant">
<term><literal>RASQAL_EXPR_VARSTAR</literal></term>
<listitem><simpara> Expression for LAQRS select Variable *
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-SAMETERM:CAPS" role="constant">
<term><literal>RASQAL_EXPR_SAMETERM</literal></term>
<listitem><simpara> Expression for SPARQL sameTerm
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-EXPR-LAST:CAPS" role="constant">
<term><literal>RASQAL_EXPR_LAST</literal></term>
<listitem><simpara> Internal
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="rasqal-compare-flags" role="enum">
<title>enum rasqal_compare_flags</title>
<indexterm zone="rasqal-compare-flags"><primary>rasqal_compare_flags</primary></indexterm><programlisting>typedef enum {
  RASQAL_COMPARE_NOCASE = 1,
  RASQAL_COMPARE_XQUERY = 2,
  RASQAL_COMPARE_RDF    = 4,
  RASQAL_COMPARE_URI    = 8
} rasqal_compare_flags;
</programlisting>
<para>
Flags for <link linkend="rasqal-expression-evaluate"><function>rasqal_expression_evaluate()</function></link> or <link linkend="rasqal-literal-compare"><function>rasqal_literal_compare()</function></link>.</para>
<para>

</para><variablelist role="enum">
<varlistentry id="RASQAL-COMPARE-NOCASE:CAPS" role="constant">
<term><literal>RASQAL_COMPARE_NOCASE</literal></term>
<listitem><simpara> String comparisons are case independent.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-COMPARE-XQUERY:CAPS" role="constant">
<term><literal>RASQAL_COMPARE_XQUERY</literal></term>
<listitem><simpara> XQuery comparsion rules apply.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-COMPARE-RDF:CAPS" role="constant">
<term><literal>RASQAL_COMPARE_RDF</literal></term>
<listitem><simpara>    RDF Term comparsion rules apply.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-COMPARE-URI:CAPS" role="constant">
<term><literal>RASQAL_COMPARE_URI</literal></term>
<listitem><simpara>    Allow comparison of URIs
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="rasqal-pattern-flags" role="enum">
<title>enum rasqal_pattern_flags</title>
<indexterm zone="rasqal-pattern-flags"><primary>rasqal_pattern_flags</primary></indexterm><programlisting>typedef enum {
  RASQAL_PATTERN_FLAGS_OPTIONAL=1,

  RASQAL_PATTERN_FLAGS_LAST=RASQAL_PATTERN_FLAGS_OPTIONAL
} rasqal_pattern_flags;
</programlisting>
<para>
Flags for <link linkend="rasqal-graph-pattern"><type>rasqal_graph_pattern</type></link>.</para>
<para>

</para><variablelist role="enum">
<varlistentry id="RASQAL-PATTERN-FLAGS-OPTIONAL:CAPS" role="constant">
<term><literal>RASQAL_PATTERN_FLAGS_OPTIONAL</literal></term>
<listitem><simpara> True when the graph pattern is an optional match.
</simpara></listitem>
</varlistentry>
<varlistentry id="RASQAL-PATTERN-FLAGS-LAST:CAPS" role="constant">
<term><literal>RASQAL_PATTERN_FLAGS_LAST</literal></term>
<listitem><simpara> Internal
</simpara></listitem>
</varlistentry>
</variablelist></refsect2>
<refsect2 id="rasqal-new-0op-expression" role="function">
<title>rasqal_new_0op_expression ()</title>
<indexterm zone="rasqal-new-0op-expression"><primary>rasqal_new_0op_expression</primary></indexterm><programlisting><link linkend="rasqal-expression">rasqal_expression</link>*  rasqal_new_0op_expression           (<link linkend="rasqal-op">rasqal_op</link> op);</programlisting>
<para>
Constructor - create a new 0-operand (constant) expression.
</para>
<para>
The operators are:
<parameter>RASQAL_EXPR_VARSTAR</parameter>
</para>
<para>
The only operator here is the '*' in COUNT(*) as used by LAQRS.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>op</parameter>&nbsp;:</term>
<listitem><simpara> Expression operator
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new <link linkend="rasqal-expression"><type>rasqal_expression</type></link> object or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="rasqal-new-1op-expression" role="function">
<title>rasqal_new_1op_expression ()</title>
<indexterm zone="rasqal-new-1op-expression"><primary>rasqal_new_1op_expression</primary></indexterm><programlisting><link linkend="rasqal-expression">rasqal_expression</link>*  rasqal_new_1op_expression           (<link linkend="rasqal-op">rasqal_op</link> op,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *arg);</programlisting>
<para>
Constructor - create a new 1-operand expression.
Takes ownership of the operand expression.
</para>
<para>
The operators are:
<parameter>RASQAL_EXPR_TILDE</parameter> <parameter>RASQAL_EXPR_BANG</parameter> <parameter>RASQAL_EXPR_UMINUS</parameter>
<parameter>RASQAL_EXPR_BOUND</parameter> <parameter>RASQAL_EXPR_STR</parameter> <parameter>RASQAL_EXPR_LANG</parameter>
<parameter>RASQAL_EXPR_LANGMATCHES</parameter>
<parameter>RASQAL_EXPR_DATATYPE</parameter> <parameter>RASQAL_EXPR_ISURI</parameter> <parameter>RASQAL_EXPR_ISBLANK</parameter>
<parameter>RASQAL_EXPR_ISLITERAL</parameter> <parameter>RASQAL_EXPR_ORDER_COND_ASC</parameter>
<parameter>RASQAL_EXPR_ORDER_COND_DESC</parameter> <parameter>RASQAL_EXPR_GROUP_COND_ASC</parameter>
<parameter>RASQAL_EXPR_GROUP_COND_DESC</parameter> <parameter>RASQAL_EXPR_COUNT</parameter>
</para>
<para>
<parameter>RASQAL_EXPR_BANG</parameter> and <parameter>RASQAL_EXPR_UMINUS</parameter> are used by RDQL and
SPARQL.  <parameter>RASQAL_EXPR_TILDE</parameter> by RDQL only.  The rest by SPARQL
only.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>op</parameter>&nbsp;:</term>
<listitem><simpara> Expression operator
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>arg</parameter>&nbsp;:</term>
<listitem><simpara> Operand 1 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new <link linkend="rasqal-expression"><type>rasqal_expression</type></link> object or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="rasqal-new-2op-expression" role="function">
<title>rasqal_new_2op_expression ()</title>
<indexterm zone="rasqal-new-2op-expression"><primary>rasqal_new_2op_expression</primary></indexterm><programlisting><link linkend="rasqal-expression">rasqal_expression</link>*  rasqal_new_2op_expression           (<link linkend="rasqal-op">rasqal_op</link> op,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *arg1,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *arg2);</programlisting>
<para>
Constructor - create a new 2-operand expression.
Takes ownership of the operand expressions.
</para>
<para>
The operators are:
<parameter>RASQAL_EXPR_AND</parameter> <parameter>RASQAL_EXPR_OR</parameter> <parameter>RASQAL_EXPR_EQ</parameter>
<parameter>RASQAL_EXPR_NEQ</parameter> <parameter>RASQAL_EXPR_LT</parameter> <parameter>RASQAL_EXPR_GT</parameter> <parameter>RASQAL_EXPR_LE</parameter>
<parameter>RASQAL_EXPR_GE</parameter> <parameter>RASQAL_EXPR_PLUS</parameter> <parameter>RASQAL_EXPR_MINUS</parameter>
<parameter>RASQAL_EXPR_STAR</parameter> <parameter>RASQAL_EXPR_SLASH</parameter> <parameter>RASQAL_EXPR_REM</parameter>
<parameter>RASQAL_EXPR_STR_EQ</parameter> <parameter>RASQAL_EXPR_STR_NEQ</parameter>
</para>
<para>
<parameter>RASQAL_EXPR_REM</parameter> <parameter>RASQAL_EXPR_STR_EQ</parameter> and <parameter>RASQAL_EXPR_STR_NEQ</parameter> are
not used by SPARQL. <parameter>RASQAL_EXPR_REM</parameter> is used by RDQL.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>op</parameter>&nbsp;:</term>
<listitem><simpara> Expression operator
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>arg1</parameter>&nbsp;:</term>
<listitem><simpara> Operand 1 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>arg2</parameter>&nbsp;:</term>
<listitem><simpara> Operand 2
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new <link linkend="rasqal-expression"><type>rasqal_expression</type></link> object or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="rasqal-new-3op-expression" role="function">
<title>rasqal_new_3op_expression ()</title>
<indexterm zone="rasqal-new-3op-expression"><primary>rasqal_new_3op_expression</primary></indexterm><programlisting><link linkend="rasqal-expression">rasqal_expression</link>*  rasqal_new_3op_expression           (<link linkend="rasqal-op">rasqal_op</link> op,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *arg1,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *arg2,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *arg3);</programlisting>
<para>
Constructor - create a new 3-operand expression.
Takes ownership of the operands.
</para>
<para>
The only operator is:
<parameter>RASQAL_EXPR_REGEX</parameter></para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>op</parameter>&nbsp;:</term>
<listitem><simpara> Expression operator
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>arg1</parameter>&nbsp;:</term>
<listitem><simpara> Operand 1 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>arg2</parameter>&nbsp;:</term>
<listitem><simpara> Operand 2
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>arg3</parameter>&nbsp;:</term>
<listitem><simpara> Operand 3 (may be NULL)
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new <link linkend="rasqal-expression"><type>rasqal_expression</type></link> object or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="rasqal-new-cast-expression" role="function">
<title>rasqal_new_cast_expression ()</title>
<indexterm zone="rasqal-new-cast-expression"><primary>rasqal_new_cast_expression</primary></indexterm><programlisting><link linkend="rasqal-expression">rasqal_expression</link>*  rasqal_new_cast_expression          (<link linkend="raptor-uri">raptor_uri</link> *name,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *value);</programlisting>
<para>
Constructor - create a new expression for casting and expression to a datatype.
Takes ownership of the datatype uri and expression value.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>name</parameter>&nbsp;:</term>
<listitem><simpara> cast datatype URI
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>value</parameter>&nbsp;:</term>
<listitem><simpara> expression value to cast to <parameter>datatype</parameter> type
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new <link linkend="rasqal-expression"><type>rasqal_expression</type></link> object or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="rasqal-new-function-expression" role="function">
<title>rasqal_new_function_expression ()</title>
<indexterm zone="rasqal-new-function-expression"><primary>rasqal_new_function_expression</primary></indexterm><programlisting><link linkend="rasqal-expression">rasqal_expression</link>*  rasqal_new_function_expression      (<link linkend="raptor-uri">raptor_uri</link> *name,
                                                         <link linkend="raptor-sequence">raptor_sequence</link> *args);</programlisting>
<para>
Constructor - create a new expression for a function with expression arguments.
Takes ownership of the function uri and arguments.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>name</parameter>&nbsp;:</term>
<listitem><simpara> function name
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>args</parameter>&nbsp;:</term>
<listitem><simpara> sequence of <link linkend="rasqal-expression"><type>rasqal_expression</type></link> function arguments
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new <link linkend="rasqal-expression"><type>rasqal_expression</type></link> object or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="rasqal-new-literal-expression" role="function">
<title>rasqal_new_literal_expression ()</title>
<indexterm zone="rasqal-new-literal-expression"><primary>rasqal_new_literal_expression</primary></indexterm><programlisting><link linkend="rasqal-expression">rasqal_expression</link>*  rasqal_new_literal_expression       (<link linkend="rasqal-literal">rasqal_literal</link> *literal);</programlisting>
<para>
Constructor - create a new expression for a <link linkend="rasqal-literal"><type>rasqal_literal</type></link>
Takes ownership of the operand literal.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>literal</parameter>&nbsp;:</term>
<listitem><simpara> Literal operand 1
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new <link linkend="rasqal-expression"><type>rasqal_expression</type></link> object or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="rasqal-new-string-op-expression" role="function">
<title>rasqal_new_string_op_expression ()</title>
<indexterm zone="rasqal-new-string-op-expression"><primary>rasqal_new_string_op_expression</primary></indexterm><programlisting><link linkend="rasqal-expression">rasqal_expression</link>*  rasqal_new_string_op_expression     (<link linkend="rasqal-op">rasqal_op</link> op,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *arg1,
                                                         <link linkend="rasqal-literal">rasqal_literal</link> *literal);</programlisting>
<para>
Constructor - create a new expression with one expression and one string operand.
Takes ownership of the operands.
</para>
<para>
The operators are:
<parameter>RASQAL_EXPR_STR_MATCH</parameter> (RDQL, SPARQL) and
<parameter>RASQAL_EXPR_STR_NMATCH</parameter> (RDQL)</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>op</parameter>&nbsp;:</term>
<listitem><simpara> Expression operator
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>arg1</parameter>&nbsp;:</term>
<listitem><simpara> Operand 1 
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>literal</parameter>&nbsp;:</term>
<listitem><simpara> Literal operand 2
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new <link linkend="rasqal-expression"><type>rasqal_expression</type></link> object or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="rasqal-new-expression-from-expression" role="function">
<title>rasqal_new_expression_from_expression ()</title>
<indexterm zone="rasqal-new-expression-from-expression"><primary>rasqal_new_expression_from_expression</primary></indexterm><programlisting><link linkend="rasqal-expression">rasqal_expression</link>*  rasqal_new_expression_from_expression
                                                        (<link linkend="rasqal-expression">rasqal_expression</link> *e);</programlisting>
<para>
Copy Constructor - create a new <link linkend="rasqal-expression"><type>rasqal_expression</type></link> object from an existing rasqal_expression object.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>e</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="rasqal-expression"><type>rasqal_expression</type></link> object to copy
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new <link linkend="rasqal-expression"><type>rasqal_expression</type></link> object or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="rasqal-free-expression" role="function">
<title>rasqal_free_expression ()</title>
<indexterm zone="rasqal-free-expression"><primary>rasqal_free_expression</primary></indexterm><programlisting><link linkend="void">void</link>                rasqal_free_expression              (<link linkend="rasqal-expression">rasqal_expression</link> *e);</programlisting>
<para>
Destructor - destroy a <link linkend="rasqal-expression"><type>rasqal_expression</type></link> object.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>e</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="rasqal-expression"><type>rasqal_expression</type></link> object
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="rasqal-expression-evaluate" role="function">
<title>rasqal_expression_evaluate ()</title>
<indexterm zone="rasqal-expression-evaluate"><primary>rasqal_expression_evaluate</primary></indexterm><programlisting><link linkend="rasqal-literal">rasqal_literal</link>*     rasqal_expression_evaluate          (<link linkend="rasqal-query">rasqal_query</link> *query,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *e,
                                                         <link linkend="int">int</link> flags);</programlisting>
<para>
Evaluate a <link linkend="rasqal-expression"><type>rasqal_expression</type></link> tree to give a <link linkend="rasqal-literal"><type>rasqal_literal</type></link> result
or error.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="rasqal-query"><type>rasqal_query</type></link> this expression belongs to
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>e</parameter>&nbsp;:</term>
<listitem><simpara> The expression to evaluate.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>flags</parameter>&nbsp;:</term>
<listitem><simpara> Flags for <link linkend="rasqal-literal-compare"><function>rasqal_literal_compare()</function></link> and RASQAL_COMPARE_NOCASE for string matches.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a <link linkend="rasqal-literal"><type>rasqal_literal</type></link> value or NULL on failure.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="rasqal-expression-print" role="function">
<title>rasqal_expression_print ()</title>
<indexterm zone="rasqal-expression-print"><primary>rasqal_expression_print</primary></indexterm><programlisting><link linkend="void">void</link>                rasqal_expression_print             (<link linkend="rasqal-expression">rasqal_expression</link> *e,
                                                         <link linkend="FILE:CAPS">FILE</link> *fh);</programlisting>
<para>
Print a Rasqal expression in a debug format.
</para>
<para>
The print debug format may change in any release.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>e</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="rasqal-expression"><type>rasqal_expression</type></link> object.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>fh</parameter>&nbsp;:</term>
<listitem><simpara> The <link linkend="FILE:CAPS"><type>FILE</type></link>* handle to print to.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="rasqal-expression-print-op" role="function">
<title>rasqal_expression_print_op ()</title>
<indexterm zone="rasqal-expression-print-op"><primary>rasqal_expression_print_op</primary></indexterm><programlisting><link linkend="void">void</link>                rasqal_expression_print_op          (<link linkend="rasqal-expression">rasqal_expression</link> *e,
                                                         <link linkend="FILE:CAPS">FILE</link> *fh);</programlisting>
<para>
Print a rasqal expression operator in a debug format.
</para>
<para>
The print debug format may change in any release.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>e</parameter>&nbsp;:</term>
<listitem><simpara> the <link linkend="rasqal-expression"><type>rasqal_expression</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>fh</parameter>&nbsp;:</term>
<listitem><simpara> the <link linkend="FILE:CAPS"><type>FILE</type></link>* handle to print to
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="rasqal-expression-visit-fn" role="function">
<title>rasqal_expression_visit_fn ()</title>
<indexterm zone="rasqal-expression-visit-fn"><primary>rasqal_expression_visit_fn</primary></indexterm><programlisting><link linkend="int">int</link>                 (*rasqal_expression_visit_fn)       (<link linkend="void">void</link> *user_data,
                                                         <link linkend="rasqal-expression">rasqal_expression</link> *e);</programlisting>
<para>
User function to visit an expression and operate on it with
<link linkend="rasqal-expression-visit"><function>rasqal_expression_visit()</function></link></para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>user_data</parameter>&nbsp;:</term>
<listitem><simpara> user data passed in with <link linkend="rasqal-expression-visit"><function>rasqal_expression_visit()</function></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>e</parameter>&nbsp;:</term>
<listitem><simpara> current expression
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> 0 to truncate the visit
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="rasqal-expression-visit" role="function">
<title>rasqal_expression_visit ()</title>
<indexterm zone="rasqal-expression-visit"><primary>rasqal_expression_visit</primary></indexterm><programlisting><link linkend="int">int</link>                 rasqal_expression_visit             (<link linkend="rasqal-expression">rasqal_expression</link> *e,
                                                         <link linkend="rasqal-expression-visit-fn">rasqal_expression_visit_fn</link> fn,
                                                         <link linkend="void">void</link> *user_data);</programlisting>
<para>
Visit a user function over a <link linkend="rasqal-expression"><type>rasqal_expression</type></link>
</para>
<para>
If the user function <parameter>fn</parameter> returns 0, the visit is truncated.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>e</parameter>&nbsp;:</term>
<listitem><simpara>  <link linkend="rasqal-expression"><type>rasqal_expression</type></link> to visit
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>fn</parameter>&nbsp;:</term>
<listitem><simpara> visit function
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>user_data</parameter>&nbsp;:</term>
<listitem><simpara> user data to pass to visit function
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> 0 if the visit was truncated.
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>




</refentry>
