Utilities

Utilities — General purpose utilities provided by the library

Stability Level

Stable, unless otherwise indicated

Synopsis

#include <tracker-sparql.h>

char*               tracker_sparql_escape_string        (const char *literal);
char*               tracker_sparql_escape_uri_printf    (const char *format,
                                                         ...);
char*               tracker_sparql_escape_uri_vprintf   (const char *format,
                                                         va_list args);

Description

The libtracker-sparql utilities help in the creation of proper SPARQL queries.

Details

tracker_sparql_escape_string ()

char*               tracker_sparql_escape_string        (const char *literal);

Escapes a string so that it can be used in a SPARQL query.

literal :

a string to escape

Returns :

a newly-allocated string with the escaped version of literal. The returned string should be freed with g_free() when no longer needed.

tracker_sparql_escape_uri_printf ()

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

Calls tracker_sparql_escape_uri_vprintf() with the Varargs supplied.

format :

a standard printf() format string, but notice string precision pitfalls

... :

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.

tracker_sparql_escape_uri_vprintf ()

char*               tracker_sparql_escape_uri_vprintf   (const char *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().

format :

a standard printf() format string, but notice string precision pitfalls

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.