LMMS
Loading...
Searching...
No Matches
Writer

Functions

SERD_API SerdWriter *SERD_ALLOCATED serd_writer_new (SerdSyntax syntax, SerdStyle style, SerdEnv *SERD_NONNULL env, const SerdURI *SERD_NULLABLE base_uri, SerdSink SERD_NONNULL ssink, void *SERD_NULLABLE stream)
 Create a new RDF writer.
SERD_API void serd_writer_free (SerdWriter *SERD_NULLABLE writer)
 Free writer.
SERD_PURE_API SerdEnv *SERD_NONNULL serd_writer_get_env (SerdWriter *SERD_NONNULL writer)
 Return the env used by writer.
SERD_API size_t serd_file_sink (const void *SERD_NONNULL buf, size_t len, void *SERD_NONNULL stream)
SERD_API size_t serd_chunk_sink (const void *SERD_NONNULL buf, size_t len, void *SERD_NONNULL stream)
SERD_API uint8_t *SERD_NULLABLE serd_chunk_sink_finish (SerdChunk *SERD_NONNULL stream)
SERD_API void serd_writer_set_error_sink (SerdWriter *SERD_NONNULL writer, SerdErrorSink SERD_NONNULL error_sink, void *SERD_NULLABLE error_handle)
SERD_API void serd_writer_chop_blank_prefix (SerdWriter *SERD_NONNULL writer, const uint8_t *SERD_NULLABLE prefix)
SERD_API SerdStatus serd_writer_set_base_uri (SerdWriter *SERD_NONNULL writer, const SerdNode *SERD_NULLABLE uri)
SERD_API SerdStatus serd_writer_set_root_uri (SerdWriter *SERD_NONNULL writer, const SerdNode *SERD_NULLABLE uri)
SERD_API SerdStatus serd_writer_set_prefix (SerdWriter *SERD_NONNULL writer, const SerdNode *SERD_NONNULL name, const SerdNode *SERD_NONNULL uri)
SERD_API SerdStatus serd_writer_write_statement (SerdWriter *SERD_NONNULL writer, SerdStatementFlags flags, const SerdNode *SERD_NULLABLE graph, const SerdNode *SERD_NONNULL subject, const SerdNode *SERD_NONNULL predicate, const SerdNode *SERD_NONNULL object, const SerdNode *SERD_NULLABLE datatype, const SerdNode *SERD_NULLABLE lang)
SERD_API SerdStatus serd_writer_end_anon (SerdWriter *SERD_NONNULL writer, const SerdNode *SERD_NULLABLE node)
SERD_API SerdStatus serd_writer_finish (SerdWriter *SERD_NONNULL writer)

Detailed Description

Function Documentation

◆ serd_chunk_sink()

SERD_API size_t serd_chunk_sink ( const void *SERD_NONNULL buf,
size_t len,
void *SERD_NONNULL stream )

A convenience sink function for writing to a string

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

◆ serd_chunk_sink_finish()

SERD_API uint8_t *SERD_NULLABLE serd_chunk_sink_finish ( SerdChunk *SERD_NONNULL stream)

Finish a serialisation to a chunk with serd_chunk_sink().

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

◆ serd_file_sink()

SERD_API size_t serd_file_sink ( const void *SERD_NONNULL buf,
size_t len,
void *SERD_NONNULL stream )

A convenience sink function for writing to a FILE*.

This function can be used as a SerdSink when writing to a FILE*. The stream parameter must be a FILE* opened for writing.

◆ serd_writer_chop_blank_prefix()

SERD_API void serd_writer_chop_blank_prefix ( SerdWriter *SERD_NONNULL writer,
const uint8_t *SERD_NULLABLE 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.

◆ serd_writer_end_anon()

SERD_API SerdStatus serd_writer_end_anon ( SerdWriter *SERD_NONNULL writer,
const SerdNode *SERD_NULLABLE node )

Mark the end of an anonymous node's description.

Note this function can be safely casted to SerdEndSink.

◆ serd_writer_finish()

SERD_API SerdStatus serd_writer_finish ( SerdWriter *SERD_NONNULL writer)

Finish a write

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

◆ serd_writer_free()

SERD_API void serd_writer_free ( SerdWriter *SERD_NULLABLE writer)

Free writer.

◆ serd_writer_get_env()

SERD_PURE_API SerdEnv *SERD_NONNULL serd_writer_get_env ( SerdWriter *SERD_NONNULL writer)

Return the env used by writer.

◆ serd_writer_new()

Create a new RDF writer.

◆ serd_writer_set_base_uri()

SERD_API SerdStatus serd_writer_set_base_uri ( SerdWriter *SERD_NONNULL writer,
const SerdNode *SERD_NULLABLE uri )

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

Note this function can be safely casted to SerdBaseSink.

◆ serd_writer_set_error_sink()

SERD_API void serd_writer_set_error_sink ( SerdWriter *SERD_NONNULL writer,
SerdErrorSink SERD_NONNULL error_sink,
void *SERD_NULLABLE error_handle )

Set a function to be called when errors occur during writing.

The error_sink will be called with handle as its first argument. If no error function is set, errors are printed to stderr.

◆ serd_writer_set_prefix()

SERD_API SerdStatus serd_writer_set_prefix ( SerdWriter *SERD_NONNULL writer,
const SerdNode *SERD_NONNULL name,
const SerdNode *SERD_NONNULL uri )

Set a namespace prefix (and emit directive if applicable).

Note this function can be safely casted to SerdPrefixSink.

◆ serd_writer_set_root_uri()

SERD_API SerdStatus serd_writer_set_root_uri ( SerdWriter *SERD_NONNULL writer,
const SerdNode *SERD_NULLABLE 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.

◆ serd_writer_write_statement()

Write a statement.

Note this function can be safely casted to SerdStatementSink.