Utility Functions: Tracker SPARQL Library Reference Manual

## Utility Functions Utility Functions — miscellaneous functionality |

## Stability Level

Stable, unless otherwise indicated

## Functions

gchar * | tracker_sparql_get_uuid_urn ()
gchar * | tracker_sparql_escape_string ()
gchar * | tracker_sparql_escape_uri ()
gchar * | tracker_sparql_escape_uri_printf ()
gchar * | tracker_sparql_escape_uri_vprintf ()
GFile * | tracker_sparql_get_ontology_nepomuk ()

## Includes

    #include <tracker-sparql.h>

## Description

Collection of Tracker utility functions.

## Functions

### tracker_sparql_get_uuid_urn ()

    gchar *
    tracker_sparql_get_uuid_urn (void);

Creates a fresh UUID-based URN.

#### Returns

A newly generated UUID URN.

[transfer full]

### tracker_sparql_escape_string ()

    gchar *
    tracker_sparql_escape_string (const gchar *literal);

Escapes `literal` so it is suitable for insertion in SPARQL queries as string literals. Manual construction of query strings based user input is best avoided at all cost, use of TrackerSparqlStatement is recommended instead.

#### Parameters

literal | a string to escape |

#### Returns

the escaped string.

[transfer full]

### tracker_sparql_escape_uri ()

    gchar *
    tracker_sparql_escape_uri (const gchar *uri);

Calls `tracker_sparql_escape_uri_printf()`.

#### Parameters

uri | a string to be escaped, following the tracker sparql rules |

#### Returns

a newly-allocated string holding the result. The returned string should be freed with `g_free()` when no longer needed.

[transfer full]

### tracker_sparql_escape_uri_printf ()

    gchar *
    tracker_sparql_escape_uri_printf (const gchar *format,
                                      ...);

Calls `tracker_sparql_escape_uri_vprintf()` with the @... supplied.

#### Parameters

format | a standard `printf()` format string, but notice string precision pitfalls documented in `g_strdup_printf()` |
... | the parameters to insert into the format string |

#### Returns

a newly-allocated string holding the result.The returned string should be freed with `g_free()` when no longer needed.

[transfer full]

### tracker_sparql_escape_uri_vprintf ()

    gchar *
    tracker_sparql_escape_uri_vprintf (const gchar *format,
                                       va_list args);

Similar to the standard C `vsprintf()` function but safer, since it calculates the maximum space required and allocates memory to hold the result.

The result is escaped using `g_uri_escape_string()`.

#### Parameters

format | a standard `printf()` format string, but notice string precision pitfalls documented in `g_strdup_printf()` |
args | the list of parameters to insert into the format string |

#### Returns

a newly-allocated string holding the result. The returned string should be freed with `g_free()` when no longer needed.

[transfer full]

### tracker_sparql_get_ontology_nepomuk ()

    GFile *
    tracker_sparql_get_ontology_nepomuk (void);

Returns a path to the built-in Nepomuk ontologies.

#### Returns

a GFile instance.

[transfer full]