## section-triple section-triple |

## Functions

rasqal_triple * | rasqal_new_triple ()
rasqal_triple * | rasqal_new_triple_from_triple ()
void | rasqal_free_triple ()
rasqal_literal * | rasqal_triple_get_origin ()
int | rasqal_triple_print ()
void | rasqal_triple_set_origin ()

## Types and Values

| rasqal_triple
enum | rasqal_triple_parts

## Description

## Functions

### rasqal_new_triple ()

    rasqal_triple *
    rasqal_new_triple (rasqal_literal *subject,
                       rasqal_literal *predicate,
                       rasqal_literal *object);

Constructor - create a new rasqal_triple triple or triple pattern. Takes ownership of the literals passed in.

The triple origin can be set with `rasqal_triple_set_origin()`.

#### Parameters

subject | Triple subject. |
predicate | Triple predicate. |
object | Triple object. |

#### Returns

a new rasqal_triple or NULL on failure.

### rasqal_new_triple_from_triple ()

    rasqal_triple *
    rasqal_new_triple_from_triple (rasqal_triple *t);

Copy constructor - create a new rasqal_triple from an existing one.

#### Parameters

t | Triple to copy. |

#### Returns

a new rasqal_triple or NULL on failure.

### rasqal_free_triple ()

    void
    rasqal_free_triple (rasqal_triple *t);

Destructor - destroy a rasqal_triple object.

#### Parameters

t | rasqal_triple object. |

### rasqal_triple_get_origin ()

    rasqal_literal *
    rasqal_triple_get_origin (rasqal_triple *t);

Get the origin field of a rasqal_triple.

#### Parameters

t | The triple object. |

#### Returns

The triple origin or NULL.

### rasqal_triple_print ()

    int
    rasqal_triple_print (rasqal_triple *t,
                         FILE *fh);

Print a Rasqal triple in a debug format.

The print debug format may change in any release.

#### Parameters

t | rasqal_triple object. |
fh | The FILE* handle to print to. |

#### Returns

non-0 on failure

### rasqal_triple_set_origin ()

    void
    rasqal_triple_set_origin (rasqal_triple *t,
                              rasqal_literal *l);

Set the origin field of a rasqal_triple.

#### Parameters

t | The triple object. |
l | The rasqal_literal object to set as origin. |

## Types and Values

### rasqal_triple

    typedef struct {
      rasqal_literal* subject;
      rasqal_literal* predicate;
      rasqal_literal* object;
      rasqal_literal* origin;
      unsigned int flags;
    } rasqal_triple;

A triple pattern or RDF triple.

This is used as a triple pattern in queries and an RDF triple when generating RDF triples such as with SPARQL CONSTRUCT.

#### Members

rasqal_literal *`subject`; | Triple subject. |
rasqal_literal *`predicate`; | Triple predicate. |
rasqal_literal *`object`; | Triple object. |
rasqal_literal *`origin`; | Triple origin. |
unsigned int `flags`; | Or of enum rasqal_triple_flags bits. |

### enum rasqal_triple_parts

Flags for parts of a triple.

#### Members

RASQAL_TRIPLE_NONE | no parts |
RASQAL_TRIPLE_SUBJECT | Subject present in a triple. |
RASQAL_TRIPLE_PREDICATE | Predicate present in a triple. |
RASQAL_TRIPLE_OBJECT | Object present in a triple. |
RASQAL_TRIPLE_ORIGIN | Origin/graph present in a triple. |
RASQAL_TRIPLE_GRAPH | Alias for RASQAL_TRIPLE_ORIGIN |
RASQAL_TRIPLE_SPO | Subject, Predicate and Object present in a triple. |
RASQAL_TRIPLE_SPOG | Subject, Predicate, Object, Graph present in a triple. |