diff options
author | David Robillard <d@drobilla.net> | 2017-01-05 16:22:52 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2017-01-05 16:22:52 -0500 |
commit | 0c71ed6ce02ee7ff65a5da2cf863c5712a67cb4b (patch) | |
tree | 217344e3fac3b1f6cb8e116ef257cfa39835529f /src/writer.c | |
parent | 4c6600603704454df7c3a21039111f195d2d0ff1 (diff) | |
download | serd-0c71ed6ce02ee7ff65a5da2cf863c5712a67cb4b.tar.gz serd-0c71ed6ce02ee7ff65a5da2cf863c5712a67cb4b.tar.bz2 serd-0c71ed6ce02ee7ff65a5da2cf863c5712a67cb4b.zip |
Add support for NQuads
Diffstat (limited to 'src/writer.c')
-rw-r--r-- | src/writer.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/writer.c b/src/writer.c index 0d1ebded..59c05420 100644 --- a/src/writer.c +++ b/src/writer.c @@ -1,5 +1,5 @@ /* - Copyright 2011-2016 David Robillard <http://drobilla.net> + Copyright 2011-2017 David Robillard <http://drobilla.net> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -431,7 +431,8 @@ typedef enum { FIELD_NONE, FIELD_SUBJECT, FIELD_PREDICATE, - FIELD_OBJECT + FIELD_OBJECT, + FIELD_GRAPH } Field; static bool @@ -491,6 +492,7 @@ write_node(SerdWriter* writer, case SERD_CURIE: switch (writer->syntax) { case SERD_NTRIPLES: + case SERD_NQUADS: if (serd_env_expand(writer->env, node, &uri_prefix, &suffix)) { w_err(writer, SERD_ERR_BAD_CURIE, "undefined namespace prefix `%s'\n", node->buf); @@ -661,11 +663,16 @@ serd_writer_write_statement(SerdWriter* writer, switch (writer->syntax) { case SERD_NTRIPLES: + case SERD_NQUADS: TRY(write_node(writer, subject, NULL, NULL, FIELD_SUBJECT, flags)); sink(" ", 1, writer); TRY(write_node(writer, predicate, NULL, NULL, FIELD_PREDICATE, flags)); sink(" ", 1, writer); TRY(write_node(writer, object, datatype, lang, FIELD_OBJECT, flags)); + if (writer->syntax == SERD_NQUADS && graph) { + sink(" ", 1, writer); + TRY(write_node(writer, graph, datatype, lang, FIELD_GRAPH, flags)); + } sink(" .\n", 3, writer); return SERD_SUCCESS; default: |