Dataquay::Node Class Reference

A single RDF node, with conversions to and from variant types. More...

#include <dataquay/Node.h>

List of all members.

Public Types

enum  Type { Nothing, URI, Literal, Blank }
 Node type. More...

Public Member Functions

 Node ()
 Construct a node with no node type (used for example as an undefined node when pattern matching a triple).
 Node (QUrl u)
 Construct a node with a URI node type and the given URI.
 Node (Type t, QString v)
 Construct a node with the given node type and value, and with no defined data type URI.
 Node (Type t, QString v, QString dt)
 Construct a node with the given node type, value, and data type URI.
 ~Node ()
QVariant toVariant () const
 Convert a Node to a QVariant.

Static Public Member Functions

static Node fromVariant (QVariant v)
 Convert a QVariant to a Node.

Public Attributes

Type type
QString value
QString datatype


Detailed Description

A single RDF node, with conversions to and from variant types.

Definition at line 52 of file Node.h.


Member Enumeration Documentation

Node type.

Enumerator:
Nothing 
URI 
Literal 
Blank 

Definition at line 58 of file Node.h.


Constructor & Destructor Documentation

Dataquay::Node::Node (  )  [inline]

Construct a node with no node type (used for example as an undefined node when pattern matching a triple).

Definition at line 64 of file Node.h.

Dataquay::Node::Node ( QUrl  u  )  [inline]

Construct a node with a URI node type and the given URI.

Note that URIs using namespace prefixes will need to be expanded before they can safely be represented in a QUrl. Call Store::expand() to achieve this. In general you should ensure that URIs are expanded when placed in a Node object rather than being stored in prefixed form.

(One basic principle of this RDF library is that we use QString to represent URIs that may be local or namespace prefixed, and QUrl to represent expanded or canonical URIs.)

Definition at line 79 of file Node.h.

Dataquay::Node::Node ( Type  t,
QString  v 
) [inline]

Construct a node with the given node type and value, and with no defined data type URI.

Definition at line 85 of file Node.h.

Dataquay::Node::Node ( Type  t,
QString  v,
QString  dt 
) [inline]

Construct a node with the given node type, value, and data type URI.

Definition at line 91 of file Node.h.

Dataquay::Node::~Node (  )  [inline]

Definition at line 93 of file Node.h.


Member Function Documentation

Node Dataquay::Node::fromVariant ( QVariant  v  )  [static]

Convert a QVariant to a Node.

Simple QVariant types (integer, etc) are converted to literal Nodes whose values are encoded as XSD datatypes, with the node's value storing the XSD representation and the node's datatype storing the XSD datatype URI.

QVariants containing QUrls are converted to URI nodes. Note that URIs using namespace prefixes will need to be expanded before they can safely be represented in a QUrl or URL variant. Call Store::expand() to achieve this. In general you should ensure that URIs are expanded when placed in a Node object rather than being stored in prefixed form.

Other QVariants including complex structures are converted into literals containing an encoded representation which may be converted back again using toVariant but cannot be directly read from or interchanged using the node's value. These types are given a specific fixed datatype URI.

Definition at line 49 of file Node.cpp.

References datatype, DEBUG, Dataquay::encodedVariantTypeURI, Literal, type, URI, and value.

Referenced by Dataquay::PropertyObject::setProperty().

QVariant Dataquay::Node::toVariant (  )  const

Convert a Node to a QVariant.

See fromVariant for details of the conversion.

Note that URI nodes are returned as QUrl variants, not QString variants. This may result in invalid QUrls if the URIs were not properly expanded on construction (see the notes about fromVariant).

Definition at line 98 of file Node.cpp.

References Blank, datatype, DEBUG, Dataquay::encodedVariantTypeURI, Nothing, type, URI, and value.

Referenced by Dataquay::PropertyObject::getProperty().


Member Data Documentation


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

Generated on Thu Sep 24 23:19:48 2009 for Dataquay by  doxygen 1.5.7.1