aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/writer.c b/src/writer.c
index e23058f0..2b2d5ed8 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -18,6 +18,7 @@
#include "env.h"
#include "node.h"
#include "serd_internal.h"
+#include "sink.h"
#include "stack.h"
#include "string_utils.h"
#include "uri_utils.h"
@@ -92,6 +93,7 @@ static const SepRule rules[] = {{NULL, 0, 0, 0, 0},
{"\n", 1, 0, 1, 0}};
struct SerdWriterImpl {
+ SerdSink iface;
SerdSyntax syntax;
SerdWriterFlags flags;
SerdEnv* env;
@@ -113,6 +115,11 @@ struct SerdWriterImpl {
typedef enum { WRITE_STRING, WRITE_LONG_STRING } TextContext;
+static SerdStatus
+serd_writer_set_prefix(SerdWriter* writer,
+ const SerdNode* name,
+ const SerdNode* uri);
+
static bool
write_node(SerdWriter* writer,
const SerdNode* node,
@@ -785,7 +792,7 @@ write_list_obj(SerdWriter* writer,
return false;
}
-SerdStatus
+static SerdStatus
serd_writer_write_statement(SerdWriter* writer,
SerdStatementFlags flags,
const SerdNode* graph,
@@ -915,7 +922,7 @@ serd_writer_write_statement(SerdWriter* writer,
return SERD_SUCCESS;
}
-SerdStatus
+static SerdStatus
serd_writer_end_anon(SerdWriter* writer, const SerdNode* node)
{
if (writer->syntax == SERD_NTRIPLES || writer->syntax == SERD_NQUADS) {
@@ -976,6 +983,12 @@ serd_writer_new(SerdSyntax syntax,
writer->byte_sink = serd_byte_sink_new(
ssink, stream, (flags & SERD_WRITE_BULK) ? SERD_PAGE_SIZE : 1);
+ writer->iface.handle = writer;
+ writer->iface.base = (SerdBaseFunc)serd_writer_set_base_uri;
+ writer->iface.prefix = (SerdPrefixFunc)serd_writer_set_prefix;
+ writer->iface.statement = (SerdStatementFunc)serd_writer_write_statement;
+ writer->iface.end = (SerdEndFunc)serd_writer_end_anon;
+
return writer;
}
@@ -1083,6 +1096,12 @@ serd_writer_free(SerdWriter* writer)
free(writer);
}
+const SerdSink*
+serd_writer_sink(SerdWriter* writer)
+{
+ return &writer->iface;
+}
+
SerdEnv*
serd_writer_env(SerdWriter* writer)
{