From 1f8eca44b68052f8306d9166cc062e6fe344c988 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 11 May 2009 21:51:20 +0000 Subject: Type preserving Redland URI <-> atom URI. git-svn-id: http://svn.drobilla.net/lad/trunk/raul@1976 a436a847-0d15-0410-975c-d299462d15a1 --- raul/AtomRDF.hpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'raul') 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); -- cgit v1.2.1