From 846553f8894264d64cdd1dfb08df56fe08189dac Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 3 Jun 2018 19:24:59 +0200 Subject: Add SerdStatement --- include/serd/serd.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 6 deletions(-) (limited to 'include/serd/serd.h') diff --git a/include/serd/serd.h b/include/serd/serd.h index b5c7c4f0..e32e66cc 100644 --- a/include/serd/serd.h +++ b/include/serd/serd.h @@ -84,6 +84,9 @@ extern "C" { /// Global library state typedef struct SerdWorldImpl SerdWorld; +/// A subject, predicate, and object, with optional graph context +typedef struct SerdStatementImpl SerdStatement; + /// The origin of a statement in a document typedef struct SerdCursorImpl SerdCursor; @@ -841,12 +844,10 @@ typedef SerdStatus (*SerdPrefixFunc)(void* SERD_NULLABLE handle, Called for every RDF statement in the serialisation. */ -typedef SerdStatus (*SerdStatementFunc)(void* SERD_NULLABLE handle, - SerdStatementFlags flags, - const SerdNode* SERD_NULLABLE graph, - const SerdNode* SERD_NONNULL subject, - const SerdNode* SERD_NONNULL predicate, - const SerdNode* SERD_NONNULL object); +typedef SerdStatus (*SerdStatementFunc)(void* SERD_NULLABLE handle, + SerdStatementFlags flags, + const SerdStatement* SERD_NONNULL + statement); /** Sink function for anonymous node end markers @@ -1037,6 +1038,13 @@ serd_sink_write_prefix(const SerdSink* SERD_NONNULL sink, const SerdNode* SERD_NONNULL name, const SerdNode* SERD_NONNULL uri); +/// Write a statement +SERD_API +SerdStatus +serd_sink_write_statement(const SerdSink* SERD_NONNULL sink, + SerdStatementFlags flags, + const SerdStatement* SERD_NONNULL statement); + /// Write a statement from individual nodes SERD_API SerdStatus @@ -1264,6 +1272,43 @@ SERD_API SerdStatus serd_writer_finish(SerdWriter* SERD_NONNULL writer); +/** + @} + @defgroup serd_statement Statement + @{ +*/ + +/// Return the given node in `statement` +SERD_PURE_API +const SerdNode* SERD_NULLABLE +serd_statement_node(const SerdStatement* SERD_NONNULL statement, + SerdField field); + +/// Return the subject in `statement` +SERD_PURE_API +const SerdNode* SERD_NONNULL +serd_statement_subject(const SerdStatement* SERD_NONNULL statement); + +/// Return the predicate in `statement` +SERD_PURE_API +const SerdNode* SERD_NONNULL +serd_statement_predicate(const SerdStatement* SERD_NONNULL statement); + +/// Return the object in `statement` +SERD_PURE_API +const SerdNode* SERD_NONNULL +serd_statement_object(const SerdStatement* SERD_NONNULL statement); + +/// Return the graph in `statement` +SERD_PURE_API +const SerdNode* SERD_NULLABLE +serd_statement_graph(const SerdStatement* SERD_NONNULL statement); + +/// Return the source location where `statement` originated, or NULL +SERD_PURE_API +const SerdCursor* SERD_NULLABLE +serd_statement_cursor(const SerdStatement* SERD_NONNULL statement); + /** @} @defgroup serd_cursor Cursor -- cgit v1.2.1