Public Types | Public Member Functions

QSparqlQuery Class Reference

The QSparqlQuery class provides a means of executing and manipulating SPARQL statements. More...

List of all members.

Public Types

enum  StatementType {
  SelectStatement, AskStatement, ConstructStatement, DescribeStatement,
  InsertStatement, DeleteStatement
}

Public Member Functions

 QSparqlQuery (const QString &query=QString(), StatementType type=SelectStatement)
 QSparqlQuery (const QSparqlQuery &other)
QSparqlQueryoperator= (const QSparqlQuery &other)
 ~QSparqlQuery ()
StatementType type () const
void setType (StatementType type)
QString query () const
void setQuery (const QString &query)
void bindValue (const QString &placeholder, const QVariant &val)
void bindValue (const QSparqlBinding &binding)
void bindValues (const QSparqlResultRow &bindings)
QVariant boundValue (const QString &placeholder) const
QMap< QString, QSparqlBindingboundValues () const
void unbindValues ()
QString preparedQueryText () const

Detailed Description

The QSparqlQuery class provides a means of executing and manipulating SPARQL statements.

QSparqlQuery encapsulates the functionality involved in creating SPARQL queries which are executed on a QSparqlConnection.

It can also be used to execute commands specific to an RDF store which are not standard SPARQL.

To execute the QSparqlQuery, pass it to QSparqlConnection::exec().

QSparqlQuery supports binding of parameter values to placeholders; ?: and $: are used as placeholder markers.

You can retrieve the values of all the fields in a single variable (a map) using boundValues().

Approaches to Binding Values

QSparqlQuery supports replacing placeholders (marked with ?: or $:) with strings.

    QSparqlQuery nameQuery("select ?ng ?nf "
    "{ ?:contact_uri nco:nameGiven ?ng ; nco:nameFamily ?nf . } ");
    nameQuery.bindValue("contact_uri", QUrl(uri));

When replacing strings, the quotes surrounding strings are inserted automatically. Quotes (" and ') inside the strings are escaped.

See also:
QSparqlConnection, QSparqlQueryModel, QSparqlResult, QSparqlResultRow, QSparqlBinding, QVariant

Member Enumeration Documentation

This enum contains a list of SPARQL statement (or clause) types the driver can create.

Enumerator:
SelectStatement 

A SPARQL SELECT statement

AskStatement 

A SPARQL ASK statement

ConstructStatement 

A SPARQL CONSTRUCT statement

DescribeStatement 

A SPARQL DESCRIBE statement

InsertStatement 

A SPARQL INSERT statement

DeleteStatement 

A SPARQL DELETE statement


Constructor & Destructor Documentation

QSparqlQuery::QSparqlQuery ( const QString &  query = QString(),
StatementType  type = SelectStatement 
) [explicit]

Constructs a QSparqlQuery object which uses the QSparqlResult result to communicate with a database.

QSparqlQuery::QSparqlQuery ( const QSparqlQuery other  ) 

Constructs a copy of other.

QSparqlQuery::~QSparqlQuery (  ) 

Destroys the object and frees any allocated resources.


Member Function Documentation

void QSparqlQuery::bindValue ( const QString &  placeholder,
const QVariant &  val 
)

Set the placeholder placeholder to be bound to value val in the query. Note that the placeholder mark (?: or $:) must not be included when specifying the placeholder name.

See also:
bindValue(), boundValue() boundValues()
void QSparqlQuery::bindValue ( const QSparqlBinding binding  ) 

Set the placeholder binding.name() to be bound to value binding.value() in the query. Note that the placeholder mark (?: or $:) must not be included when specifying the placeholder name.

void QSparqlQuery::bindValues ( const QSparqlResultRow bindings  ) 

Iterates through the variable name - value pairs from the bindings and adds them as bindings.

QVariant QSparqlQuery::boundValue ( const QString &  placeholder  )  const

Returns the value for the placeholder.

See also:
boundValues() bindValue()
QMap< QString, QSparqlBinding > QSparqlQuery::boundValues (  )  const

Returns a map of the bound values.

See also:
boundValue() bindValue()
QSparqlQuery & QSparqlQuery::operator= ( const QSparqlQuery other  ) 

Assigns other to this object.

QString QSparqlQuery::preparedQueryText (  )  const

Replaces the placeholders with the bound values and returns the resulting query.

QString QSparqlQuery::query (  )  const

Returns the query text without replacements.

void QSparqlQuery::setQuery ( const QString &  query  ) 

Sets the query text to query. The bound placeholders are not affected.

void QSparqlQuery::setType ( StatementType  type  ) 

Sets the statement type to type.

QSparqlQuery::StatementType QSparqlQuery::type (  )  const

Returns the statement type.

void QSparqlQuery::unbindValues (  ) 

Clears all bound values.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Enumerations Enumerator