summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-01-28 23:55:02 +0000
committerDavid Robillard <d@drobilla.net>2011-01-28 23:55:02 +0000
commit3d6190d171b33a51ec7af8848fb292a09497927d (patch)
tree7b1e38dc81d7823dc1e3d6f342395ac2c97d90d7 /src
parent9d9cd92a474f8ad5b8c75d3bedede0960281ef48 (diff)
downloadsord-3d6190d171b33a51ec7af8848fb292a09497927d.tar.gz
sord-3d6190d171b33a51ec7af8848fb292a09497927d.tar.bz2
sord-3d6190d171b33a51ec7af8848fb292a09497927d.zip
(More) proper marshaling between Serd and Sord nodes.
git-svn-id: http://svn.drobilla.net/sord/trunk@10 3d64ff67-21c5-427c-a301-fe4f08042e5a
Diffstat (limited to 'src')
-rw-r--r--src/syntax.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/syntax.c b/src/syntax.c
index 4a58ac9..e0f9ab4 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -93,7 +93,38 @@ event_prefix(void* handle,
static inline SordID
sord_node_from_serd_node(ReadState* state, const SerdNode* sn)
{
- return sord_get_uri_counted(state->sord, true, (const char*)sn->buf, sn->n_chars);
+ switch (sn->type) {
+ case SERD_NOTHING:
+ return NULL;
+ case SERD_LITERAL:
+ return sord_get_literal(state->sord, true, NULL,
+ (const char*)sn->buf, NULL);
+ case SERD_URI:
+ return sord_get_uri_counted(state->sord, true,
+ (const char*)sn->buf, sn->n_chars);
+ case SERD_CURIE: {
+ SerdURI uri;
+ if (!serd_uri_parse(sn->buf, &uri)) {
+ return false;
+ }
+ SerdURI abs_uri;
+ if (!serd_uri_resolve(&uri, &state->base_uri, &abs_uri)) {
+ return false;
+ }
+ SerdURI ignored;
+ SerdNode serd_uri = serd_node_new_uri(&abs_uri, &ignored);
+ SordNode sord_uri = sord_get_uri_counted(state->sord, true,
+ (const char*)serd_uri.buf,
+ serd_uri.n_chars);
+ serd_node_free(&serd_uri);
+ return sord_uri;
+ }
+ case SERD_BLANK_ID:
+ case SERD_ANON_BEGIN:
+ case SERD_ANON:
+ return sord_get_blank(state->sord, true, (const char*)sn->buf);
+ }
+ return NULL;
}
static bool