diff options
author | David Robillard <d@drobilla.net> | 2018-06-03 22:23:28 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-10-27 13:13:58 +0100 |
commit | bcd9ce4800688e3b53cc198d26e2e44627a2ec7a (patch) | |
tree | 3ab029af12597a24d816c9e6900ef86eaa5de8d5 /src | |
parent | 6a91bfca72fc2cfd7ba1002174475d71e35b2969 (diff) | |
download | serd-bcd9ce4800688e3b53cc198d26e2e44627a2ec7a.tar.gz serd-bcd9ce4800688e3b53cc198d26e2e44627a2ec7a.tar.bz2 serd-bcd9ce4800688e3b53cc198d26e2e44627a2ec7a.zip |
Add cursor to statement
This allows the file and position of statements to be used in sinks, for
example for more helpful error reporting outside the parser.
Diffstat (limited to 'src')
-rw-r--r-- | src/reader.c | 3 | ||||
-rw-r--r-- | src/sink.c | 5 | ||||
-rw-r--r-- | src/statement.c | 6 | ||||
-rw-r--r-- | src/statement.h | 3 |
4 files changed, 14 insertions, 3 deletions
diff --git a/src/reader.c b/src/reader.c index e57f5bd9..f8cd27be 100644 --- a/src/reader.c +++ b/src/reader.c @@ -120,7 +120,8 @@ emit_statement(SerdReader* reader, ReadContext ctx, SerdNode* o) serd_node_zero_pad(o); const SerdStatement statement = { - { ctx.subject, ctx.predicate, o, graph } + { ctx.subject, ctx.predicate, o, graph }, + &reader->source.cur }; const SerdStatus st = !reader->sink->statement @@ -18,6 +18,8 @@ #include "statement.h" +#include <stddef.h> + SerdStatus serd_sink_write_base(const SerdSink* sink, const SerdNode* uri) { @@ -48,7 +50,8 @@ serd_sink_write(const SerdSink* sink, const SerdNode* object, const SerdNode* graph) { - const SerdStatement statement = { { subject, predicate, object, graph } }; + const SerdStatement statement = { { subject, predicate, object, graph }, + NULL }; return sink->statement(sink->handle, flags, &statement); } diff --git a/src/statement.c b/src/statement.c index 8d9c3f72..c9c9dca1 100644 --- a/src/statement.c +++ b/src/statement.c @@ -45,3 +45,9 @@ serd_statement_graph(const SerdStatement* statement) { return statement->nodes[SERD_GRAPH]; } + +const SerdCursor* +serd_statement_cursor(const SerdStatement* statement) +{ + return statement->cursor; +} diff --git a/src/statement.h b/src/statement.h index 19b4a91f..1cb5345c 100644 --- a/src/statement.h +++ b/src/statement.h @@ -27,7 +27,8 @@ typedef const SerdNode* SerdQuad[4]; struct SerdStatementImpl { - SerdQuad nodes; + SerdQuad nodes; + SerdCursor* cursor; }; #endif // SERD_STATEMENT_H |