diff options
author | David Robillard <d@drobilla.net> | 2019-12-18 19:09:49 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-08 23:23:06 -0500 |
commit | fc3e5a0a7c9c64d275fec498f0e80dc02444c12d (patch) | |
tree | 538ab16491a4726431233fe22b2cd08b001281c6 /src/writer.c | |
parent | b7948f8c9ad54c30e2579fd5da4626c6f3de325a (diff) | |
download | serd-fc3e5a0a7c9c64d275fec498f0e80dc02444c12d.tar.gz serd-fc3e5a0a7c9c64d275fec498f0e80dc02444c12d.tar.bz2 serd-fc3e5a0a7c9c64d275fec498f0e80dc02444c12d.zip |
Add support for parsing variables
This adds a reader flag and serdi option for extending a syntax with support
for SPARQL-like variables, for storing things like patterns or simple queries.
Diffstat (limited to 'src/writer.c')
-rw-r--r-- | src/writer.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/writer.c b/src/writer.c index b1404a91..fbc9dd5d 100644 --- a/src/writer.c +++ b/src/writer.c @@ -881,6 +881,18 @@ write_blank(SerdWriter* const writer, } SERD_WARN_UNUSED_RESULT static SerdStatus +write_variable(SerdWriter* const writer, const SerdNode* node) +{ + SerdStatus st = SERD_SUCCESS; + + TRY(st, esink("?", 1, writer)); + TRY(st, esink(serd_node_string(node), node->n_bytes, writer)); + + writer->last_sep = SEP_NONE; + return st; +} + +SERD_WARN_UNUSED_RESULT static SerdStatus write_node(SerdWriter* writer, const SerdNode* node, const SerdField field, @@ -895,6 +907,8 @@ write_node(SerdWriter* writer, return write_curie(writer, node, field, flags); case SERD_BLANK: return write_blank(writer, node, field, flags); + case SERD_VARIABLE: + return write_variable(writer, node); } return SERD_ERR_INTERNAL; |