summaryrefslogtreecommitdiffstats
path: root/src/RDFNode.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-09-08 01:11:31 +0000
committerDavid Robillard <d@drobilla.net>2007-09-08 01:11:31 +0000
commitb1d0c86db891dabb77fbc9655e7e5d5740ccf701 (patch)
tree8662547873719a803438efbd9958abd7f788d2d8 /src/RDFNode.cpp
parenta6eadd534d1a3971cac14a1073ad6e29a3d88751 (diff)
downloadraul-b1d0c86db891dabb77fbc9655e7e5d5740ccf701.tar.gz
raul-b1d0c86db891dabb77fbc9655e7e5d5740ccf701.tar.bz2
raul-b1d0c86db891dabb77fbc9655e7e5d5740ccf701.zip
Pretty RDF boolean reading.
git-svn-id: http://svn.drobilla.net/lad/raul@699 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/RDFNode.cpp')
-rw-r--r--src/RDFNode.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/RDFNode.cpp b/src/RDFNode.cpp
index afba06c..a4c672f 100644
--- a/src/RDFNode.cpp
+++ b/src/RDFNode.cpp
@@ -134,6 +134,29 @@ Node::to_float()
return strtod((const char*)librdf_node_get_literal_value(_node), NULL);
}
+bool
+Node::is_bool()
+{
+ if (_node && librdf_node_get_type(_node) == LIBRDF_NODE_TYPE_LITERAL) {
+ librdf_uri* datatype_uri = librdf_node_get_literal_value_datatype_uri(_node);
+ if (datatype_uri && !strcmp((const char*)librdf_uri_as_string(datatype_uri),
+ "http://www.w3.org/2001/XMLSchema#boolean"))
+ return true;
+ }
+ return false;
+}
+
+
+float
+Node::to_bool()
+{
+ assert(is_bool());
+ if (!strcmp((const char*)librdf_node_get_literal_value(_node), "true"))
+ return true;
+ else
+ return false;
+}
+
} // namespace RDF
} // namespace Raul