Writer

SerdWriter *serd_writer_new(SerdWorld *world, SerdSyntax syntax, SerdWriterFlags flags, const SerdEnv *env, SerdByteSink *byte_sink)

Create a new RDF writer.

void serd_writer_free(SerdWriter *writer)

Free writer

const SerdSink *serd_writer_sink(SerdWriter *writer)

Return a sink interface that emits statements via writer

const SerdEnv *serd_writer_env(const SerdWriter *writer)

Return the env used by writer

size_t serd_buffer_sink(const void *buf, size_t size, size_t nmemb, void *stream)

A convenience sink function for writing to a string.

This function can be used as a SerdSink to write to a SerdBuffer which is resized as necessary with realloc(). The stream parameter must point to an initialized SerdBuffer. When the write is finished, the string should be retrieved with serd_buffer_sink_finish().

char *serd_buffer_sink_finish(SerdBuffer *stream)

Finish a serialisation to a buffer with serd_buffer_sink().

The returned string is the result of the serialisation, which is null terminated (by this function) and owned by the caller.

void serd_writer_chop_blank_prefix(SerdWriter *writer, const char *prefix)

Set a prefix to be removed from matching blank node identifiers.

This is the counterpart to serd_reader_add_blank_prefix() which can be used to “undo” added prefixes.

SerdStatus serd_writer_set_base_uri(SerdWriter *writer, const SerdNode *uri)

Set the current output base URI, and emit a directive if applicable.

Note this function can be safely casted to SerdBaseSink.

SerdStatus serd_writer_set_root_uri(SerdWriter *writer, const SerdNode *uri)

Set the current root URI.

The root URI should be a prefix of the base URI. The path of the root URI is the highest path any relative up-reference can refer to. For example, with root file:///foo/root and base file:///foo/root/base, file:///foo/root will be written as <../>, but file:///foo will be written non-relatively as file:///foo. If the root is not explicitly set, it defaults to the base URI, so no up-references will be created at all.

SerdStatus serd_writer_finish(SerdWriter *writer)

Finish a write.

This flushes any pending output, for example terminating punctuation, so that the output is a complete document.