summaryrefslogtreecommitdiffstats
path: root/raul
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-05-11 21:51:20 +0000
committerDavid Robillard <d@drobilla.net>2009-05-11 21:51:20 +0000
commit1f8eca44b68052f8306d9166cc062e6fe344c988 (patch)
tree48edbfe0a2b573bc787a66970e8378f296cc6ed2 /raul
parente7898429a0c7c1007e0fabf5bec075fac1d84c31 (diff)
downloadraul-1f8eca44b68052f8306d9166cc062e6fe344c988.tar.gz
raul-1f8eca44b68052f8306d9166cc062e6fe344c988.tar.bz2
raul-1f8eca44b68052f8306d9166cc062e6fe344c988.zip
Type preserving Redland URI <-> atom URI.
git-svn-id: http://svn.drobilla.net/lad/trunk/raul@1976 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'raul')
-rw-r--r--raul/AtomRDF.hpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/raul/AtomRDF.hpp b/raul/AtomRDF.hpp
index 365aade..1aebe49 100644
--- a/raul/AtomRDF.hpp
+++ b/raul/AtomRDF.hpp
@@ -41,14 +41,14 @@ namespace AtomRDF {
inline Atom
node_to_atom(const Redland::Node& node)
{
- if (node.type() == Redland::Node::RESOURCE)
- return Atom(node.to_c_string());
+ if (node.is_bool())
+ return Atom(bool(node.to_bool()));
+ else if (node.is_resource())
+ return Atom(Atom::URI, node.to_c_string());
else if (node.is_float())
return Atom(node.to_float());
else if (node.is_int())
return Atom(node.to_int());
- else if (node.is_bool())
- return Atom(node.to_bool());
else
return Atom(node.to_c_string());
}
@@ -91,6 +91,10 @@ atom_to_node(Redland::World& world, const Atom& atom)
str = "false";
type = librdf_new_uri(world.world(), CUC("http://www.w3.org/2001/XMLSchema#boolean"));
break;
+ case Atom::URI:
+ str = atom.get_uri();
+ node = librdf_new_node_from_uri_string(world.world(), CUC(str.c_str()));
+ break;
case Atom::STRING:
str = atom.get_string();
break;
@@ -101,7 +105,7 @@ atom_to_node(Redland::World& world, const Atom& atom)
break;
}
- if (str != "")
+ if (!node && str != "")
node = librdf_new_node_from_typed_literal(world.world(), CUC(str.c_str()), NULL, type);
return Redland::Node(world, node);