Dataquay 0.8
Dataquay::Uri Class Reference

Uri represents a single URI. More...

#include <Uri.h>

Public Member Functions

 Uri ()
 Construct an empty (invalid, null) URI.
 
 Uri (const QString &s)
 Construct a URI from the given string, which is expected to contain the text of a complete well-formed absolute URI.
 
 Uri (const QUrl &u)
 Construct a URI from the given QUrl, which is expected to contain a complete well-formed URI.
 
 ~Uri ()
 
QString toString () const
 
QUrl toUrl () const
 
int length () const
 
QString scheme () const
 
bool operator== (const Uri &u) const
 
bool operator!= (const Uri &u) const
 
bool operator< (const Uri &u) const
 
bool operator> (const Uri &u) const
 

Static Public Member Functions

static bool isCompleteUri (QString s)
 Return true if the given string contains a complete URI, i.e.
 
static QString metaTypeName ()
 
static int metaTypeId ()
 
static bool hasUriType (const QVariant &)
 Return true if the given variant has metatype metatypeId().
 
static Uri rdfTypeUri ()
 Return the rdf:type URI.
 

Detailed Description

Uri represents a single URI.

It is a very thin wrapper around a string. Its purpose is to allow us to distinguish between abbreviated URIs (CURIEs) which may be subject to prefix expansion (represented by strings) and full URIs (represented by Uri).

In terms of the Turtle syntax, anything written within angle brackets is a Uri, while a bare string in URI context is not: it should be stored as a QString and converted to a Uri using Store::expand(). For example, http://xmlns.com/foaf/0.1/name is a Uri, while foaf:name is just a string. Never store the latter form in a Uri object without expanding it first.

Dataquay uses Uri in preference to QUrl because the latter is relatively slow to convert to and from string forms. Uri imposes no overhead over a string, it simply aids type safety.

Definition at line 76 of file Uri.h.

Constructor & Destructor Documentation

◆ Uri() [1/3]

Dataquay::Uri::Uri ( )
inline

Construct an empty (invalid, null) URI.

Definition at line 82 of file Uri.h.

◆ Uri() [2/3]

Dataquay::Uri::Uri ( const QString & s)
inlineexplicit

Construct a URI from the given string, which is expected to contain the text of a complete well-formed absolute URI.

As special cases, file: URIs are allowed to be relative ("file:x" will be expanded to "file://x" automatically) and "a" will be expanded to the rdf:type URI.

This will throw RDFIncompleteURI if given an incomplete or relative URI, so use care when constructing Uri objects from unvalidated input. Call isComplete() if you wish to test whether a URI string will be accepted before constructing.

To construct a Uri from an abbreviated or relative URI via prefix or base expansion, use Store::expand().

This constructor is intentionally marked explicit; no silent conversion is available.

Definition at line 104 of file Uri.h.

◆ Uri() [3/3]

Dataquay::Uri::Uri ( const QUrl & u)
inlineexplicit

Construct a URI from the given QUrl, which is expected to contain a complete well-formed URI.

May throw RDFIncompleteURI.

Definition at line 113 of file Uri.h.

◆ ~Uri()

Dataquay::Uri::~Uri ( )
inline

Definition at line 116 of file Uri.h.

Member Function Documentation

◆ toString()

QString Dataquay::Uri::toString ( ) const
inline

Definition at line 119 of file Uri.h.

◆ toUrl()

QUrl Dataquay::Uri::toUrl ( ) const
inline

Definition at line 120 of file Uri.h.

◆ length()

int Dataquay::Uri::length ( ) const
inline

Definition at line 121 of file Uri.h.

◆ scheme()

QString Dataquay::Uri::scheme ( ) const

◆ operator==()

bool Dataquay::Uri::operator== ( const Uri & u) const

Referenced by operator!=().

◆ operator!=()

bool Dataquay::Uri::operator!= ( const Uri & u) const
inline

Definition at line 126 of file Uri.h.

References operator==().

◆ operator<()

bool Dataquay::Uri::operator< ( const Uri & u) const
inline

Definition at line 127 of file Uri.h.

◆ operator>()

bool Dataquay::Uri::operator> ( const Uri & u) const
inline

Definition at line 128 of file Uri.h.

◆ isCompleteUri()

static bool Dataquay::Uri::isCompleteUri ( QString s)
static

Return true if the given string contains a complete URI, i.e.

if it is possible to construct a Uri object from it.

◆ metaTypeName()

static QString Dataquay::Uri::metaTypeName ( )
static

◆ metaTypeId()

static int Dataquay::Uri::metaTypeId ( )
static

◆ hasUriType()

static bool Dataquay::Uri::hasUriType ( const QVariant & )
static

Return true if the given variant has metatype metatypeId().

◆ rdfTypeUri()

static Uri Dataquay::Uri::rdfTypeUri ( )
static

Return the rdf:type URI.


The documentation for this class was generated from the following file: