#include <dataquay/Node.h>
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 |
Definition at line 52 of file Node.h.
| enum Dataquay::Node::Type |
| Dataquay::Node::Node | ( | ) | [inline] |
| 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.)
| Dataquay::Node::Node | ( | Type | t, | |
| QString | v | |||
| ) | [inline] |
| Dataquay::Node::Node | ( | Type | t, | |
| QString | v, | |||
| QString | dt | |||
| ) | [inline] |
| 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().
Definition at line 130 of file Node.h.
Referenced by fromVariant(), Dataquay::operator<<(), Dataquay::operator==(), Dataquay::operator>>(), and toVariant().
| QString Dataquay::Node::value |
Definition at line 131 of file Node.h.
Referenced by fromVariant(), Dataquay::operator<<(), Dataquay::operator==(), Dataquay::operator>>(), and toVariant().
| QString Dataquay::Node::datatype |
Definition at line 132 of file Node.h.
Referenced by fromVariant(), Dataquay::operator<<(), Dataquay::operator==(), Dataquay::operator>>(), and toVariant().
1.5.7.1