aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-06-03 19:24:59 +0200
committerDavid Robillard <d@drobilla.net>2021-03-08 23:23:05 -0500
commit846553f8894264d64cdd1dfb08df56fe08189dac (patch)
tree6ca8d42da04999851491edcf6811d05d4962bcac /include
parent7c6c3159d1804f4855d9a4e0cd52486f61fcbab6 (diff)
downloadserd-846553f8894264d64cdd1dfb08df56fe08189dac.tar.gz
serd-846553f8894264d64cdd1dfb08df56fe08189dac.tar.bz2
serd-846553f8894264d64cdd1dfb08df56fe08189dac.zip
Add SerdStatement
Diffstat (limited to 'include')
-rw-r--r--include/serd/serd.h57
1 files changed, 51 insertions, 6 deletions
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
@@ -1266,6 +1274,43 @@ 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
@{
*/