summaryrefslogtreecommitdiffstats
path: root/raul/AtomRedland.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-10-08 19:36:52 +0000
committerDavid Robillard <d@drobilla.net>2007-10-08 19:36:52 +0000
commitc50bee51f5c5e6a43068d2fc4c9c76586fa9fb60 (patch)
treeb20e893c8280101985168be3f62014776593ae84 /raul/AtomRedland.hpp
parent9f975e1e8a7dd0d8d90739829dc07d1188ad51e5 (diff)
downloadraul-c50bee51f5c5e6a43068d2fc4c9c76586fa9fb60.tar.gz
raul-c50bee51f5c5e6a43068d2fc4c9c76586fa9fb60.tar.bz2
raul-c50bee51f5c5e6a43068d2fc4c9c76586fa9fb60.zip
Update.. stuff... I hate SVN...
git-svn-id: http://svn.drobilla.net/lad/raul@855 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'raul/AtomRedland.hpp')
-rw-r--r--raul/AtomRedland.hpp44
1 files changed, 18 insertions, 26 deletions
diff --git a/raul/AtomRedland.hpp b/raul/AtomRedland.hpp
index 0ce260b..95f5d9d 100644
--- a/raul/AtomRedland.hpp
+++ b/raul/AtomRedland.hpp
@@ -23,9 +23,9 @@
#include <cstring>
#include <librdf.h>
#include <raul/Atom.hpp>
-using std::cerr; using std::endl;
+#include <raul/RDFNode.hpp>
-#define U(x) ((const unsigned char*)(x))
+#define CUC(x) ((const unsigned char*)(x))
namespace Raul {
@@ -56,14 +56,14 @@ public:
os << atom.get_int32();
str = os.str();
// xsd:integer -> pretty integer literals in Turtle
- type = librdf_new_uri(world, U("http://www.w3.org/2001/XMLSchema#integer"));
+ type = librdf_new_uri(world, CUC("http://www.w3.org/2001/XMLSchema#integer"));
break;
case Atom::FLOAT:
os.precision(20);
os << atom.get_float();
str = os.str();
// xsd:decimal -> pretty decimal (float) literals in Turtle
- type = librdf_new_uri(world, U("http://www.w3.org/2001/XMLSchema#decimal"));
+ type = librdf_new_uri(world, CUC("http://www.w3.org/2001/XMLSchema#decimal"));
break;
case Atom::BOOL:
// xsd:boolean -> pretty boolean literals in Turtle
@@ -71,7 +71,7 @@ public:
str = "true";
else
str = "false";
- type = librdf_new_uri(world, U("http://www.w3.org/2001/XMLSchema#boolean"));
+ type = librdf_new_uri(world, CUC("http://www.w3.org/2001/XMLSchema#boolean"));
break;
case Atom::STRING:
str = atom.get_string();
@@ -79,35 +79,27 @@ public:
case Atom::BLOB:
case Atom::NIL:
default:
- cerr << "WARNING: Unserializable Atom!" << endl;
+ std::cerr << "WARNING: Unserializable Atom!" << std::endl;
}
if (str != "")
- node = librdf_new_node_from_typed_literal(world, U(str.c_str()), NULL, type);
+ node = librdf_new_node_from_typed_literal(world, CUC(str.c_str()), NULL, type);
return node;
}
-#if 0
- static Atom node_to_atom(librdf_node* node) {
- /*switch (type) {
- case 'i':
- return Atom(arg->i);
- case 'f':
- return Atom(arg->f);
- case 's':
- return Atom(&arg->s);
- //case 'b'
- // FIXME: How to get a blob from a lo_arg?
- //return Atom(arg->b);
- default:
- return Atom();
- }*/
- cerr << "FIXME: node_to_atom\n";
- return Atom();
+ static Atom rdf_node_to_atom(const RDF::Node& node) {
+ if (node.type() == RDF::Node::RESOURCE)
+ return Atom(node.to_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_string());
}
-#endif
-
};