serd - A lightweight RDF syntax library
Contents
Data Structure Documentation
Enumeration Type Documentation
enumSerdStatus
Return status code.
EnumeratorSERD_SUCCESS
No error.
SERD_FAILURE
Non-fatal failure.
SERD_ERR_UNKNOWN
Unknown error.
SERD_ERR_BAD_SYNTAX
Invalid syntax.
SERD_ERR_BAD_ARG
Invalid argument.
SERD_ERR_NOT_FOUND
Not found.
SERD_ERR_ID_CLASH
Encountered clashing blank node IDs.
SERD_ERR_BAD_CURIE
Invalid CURIE (e.g. prefix does not exist)
SERD_ERR_INTERNAL
Unexpected internal error (should not happen)
enumSerdSyntax
RDF syntax type.
EnumeratorSERD_TURTLE
Turtle - Terse RDF Triple Language (UTF-8).
Seealso
Turtle
SERD_NTRIPLES
NTriples - Line-based RDF triples (ASCII).
Seealso
NTriples
SERD_NQUADS
NQuads - Line-based RDF quads (UTF-8).
Seealso
NQuads
SERD_TRIG
TriG - Terse RDF quads (UTF-8).
Seealso
Trig
enumSerdStatementFlag
Flags indicating inline abbreviation information for a statement.
EnumeratorSERD_EMPTY_S
Empty blank node subject.
SERD_EMPTY_O
Empty blank node object.
SERD_ANON_S_BEGIN
Start of anonymous subject.
SERD_ANON_O_BEGIN
Start of anonymous object.
SERD_ANON_CONT
Continuation of anonymous node.
SERD_LIST_S_BEGIN
Start of list subject.
SERD_LIST_O_BEGIN
Start of list object.
SERD_LIST_CONT
Continuation of list.
enumSerdType
Type of a syntactic RDF node. This is more precise than the type of an abstract RDF node. An abstract
node is either a resource, literal, or blank. In syntax there are two ways to refer to a resource (by URI
or CURIE) and two ways to refer to a blank (by ID or anonymously). Anonymous (inline) blank nodes are
expressed using SerdStatementFlags rather than this type.
EnumeratorSERD_NOTHING
The type of a nonexistent node. This type is useful as a sentinel, but is never emitted by the
reader.
SERD_LITERAL
Literal value. A literal optionally has either a language, or a datatype (not both).
SERD_URI
URI (absolute or relative). Value is an unquoted URI string, which is either a relative reference
with respect to the current base URI (e.g. 'foo/bar'), or an absolute URI (e.g.
'http://example.org/foo').
Seealso
RFC3986.
SERD_CURIE
CURIE, a shortened URI. Value is an unquoted CURIE string relative to the current environment,
e.g. 'rdf:type'.
Seealso
CURIE Syntax 1.0
SERD_BLANK
A blank node. Value is a blank node ID, e.g. 'id3', which is meaningful only within this
serialisation.
Seealso
Turtle nodeID
enumSerdNodeFlag
Flags indicating certain string properties relevant to serialisation.
EnumeratorSERD_HAS_NEWLINE
Contains line breaks ('\n' or '\r')
SERD_HAS_QUOTE
Contains quotes (''')
enumSerdStyle
Syntax style options. The style of the writer output can be controlled by ORing together values from this
enumeration. Note that some options are only supported for some syntaxes (e.g. NTriples does not support
abbreviation and is always ASCII).
EnumeratorSERD_STYLE_ABBREVIATED
Abbreviate triples when possible.
SERD_STYLE_ASCII
Escape all non-ASCII characters.
SERD_STYLE_RESOLVED
Resolve URIs against base URI.
SERD_STYLE_CURIED
Shorten URIs into CURIEs.
SERD_STYLE_BULK
Write output in pages.
Function Documentation
voidserd_free(void*ptr)
Free memory allocated by Serd. This function exists because some systems require memory allocated by a
library to be freed by code in the same library. It is otherwise equivalent to the standard C free()
function.
constuint8_t*serd_strerror(SerdStatusstatus)
Return a string describing a status code.
size_tserd_strlen(constuint8_t*str,size_t*n_bytes,SerdNodeFlags*flags)
Measure a UTF-8 string.
Returns
Length of str in characters (except NULL).
Parametersstr A null-terminated UTF-8 string.
n_bytes (Output) Set to the size of str in bytes (except NULL).
flags (Output) Set to the applicable flags.
doubleserd_strtod(constchar*str,char**endptr)
Parse a string to a double. The API of this function is identical to the standard C strtod function,
except this function is locale-independent and always matches the lexical format used in the Turtle
grammar (the decimal point is always '.').
void*serd_base64_decode(constuint8_t*str,size_tlen,size_t*size)
Decode a base64 string. This function can be used to deserialise a blob node created with
serd_node_new_blob().
Parametersstr Base64 string to decode.
len The length of str.
size Set to the size of the returned blob in bytes.
Returns
A newly allocated blob which must be freed with serd_free().
constuint8_t*serd_uri_to_path(constuint8_t*uri)
Return the local path for uri, or NULL if uri is not a file URI. Note this (inappropriately named)
function only removes the file scheme if necessary, and returns uri unmodified if it is an absolute path.
Percent encoding and other issues are not handled, to properly convert a file URI to a path, use
serd_file_uri_parse().
uint8_t*serd_file_uri_parse(constuint8_t*uri,uint8_t**hostname)
Get the unescaped path and hostname from a file URI.
Parametersuri A file URI.
hostname If non-NULL, set to the hostname, if present.
Returns
The path component of the URI.
The returned path and *hostname must be freed with serd_free().
boolserd_uri_string_has_scheme(constuint8_t*utf8)
Return true iff utf8 starts with a valid URI scheme.
SerdStatusserd_uri_parse(constuint8_t*utf8,SerdURI*out)
Parse utf8, writing result to out.
voidserd_uri_resolve(constSerdURI*r,constSerdURI*base,SerdURI*t)
Set target t to reference r resolved against base.
Seealsohttp://tools.ietf.org/html/rfc3986#section-5.2.2
size_tserd_uri_serialise(constSerdURI*uri,SerdSinksink,void*stream)
Serialise uri with a series of calls to sink.
size_tserd_uri_serialise_relative(constSerdURI*uri,constSerdURI*base,constSerdURI*root,SerdSinksink,void*stream)
Serialise uri relative to base with a series of calls to sink. The uri is written as a relative URI iff
if it a child of base and root. The optional root parameter must be a prefix of base and can be used keep
up-references ('../') within a certain namespace.
SerdNodeserd_node_from_string(SerdTypetype,constuint8_t*str)
Make a (shallow) node from str. This measures, but does not copy, str. No memory is allocated.
SerdNodeserd_node_from_substring(SerdTypetype,constuint8_t*str,size_tlen)
Make a (shallow) node from a prefix of str. This measures, but does not copy, str. No memory is
allocated. Note that the returned node may not be null terminated.
SerdNodeserd_node_copy(constSerdNode*node)
Make a deep copy of node.
Returns
a node that the caller must free with serd_node_free().
boolserd_node_equals(constSerdNode*a,constSerdNode*b)
Return true iff a is equal to b.
SerdNodeserd_node_new_uri_from_node(constSerdNode*uri_node,constSerdURI*base,SerdURI*out)
Simple wrapper for serd_node_new_uri() to resolve a URI node.
SerdNodeserd_node_new_uri_from_string(constuint8_t*str,constSerdURI*base,SerdURI*out)
Simple wrapper for serd_node_new_uri() to resolve a URI string.
SerdNodeserd_node_new_file_uri(constuint8_t*path,constuint8_t*hostname,SerdURI*out,boolescape)
Create a new file URI node from a file system path and optional hostname. Backslashes in Windows paths
will be converted and '' will always be percent encoded. If escape is true, all other invalid characters
will be percent encoded as well.
If path is relative, hostname is ignored. If out is not NULL, it will be set to the parsed URI.
SerdNodeserd_node_new_uri(constSerdURI*uri,constSerdURI*base,SerdURI*out)
Create a new node by serialising uri into a new string.
Parametersuri The URI to serialise.
base Base URI to resolve uri against (or NULL for no resolution).
out Set to the parsing of the new URI (i.e. points only to memory owned by the new returned node).
SerdNodeserd_node_new_relative_uri(constSerdURI*uri,constSerdURI*base,constSerdURI*root,SerdURI*out)
Create a new node by serialising uri into a new relative URI.
Parametersuri The URI to serialise.
base Base URI to make uri relative to, if possible.
root Root URI for resolution (see serd_uri_serialise_relative()).
out Set to the parsing of the new URI (i.e. points only to memory owned by the new returned node).
SerdNodeserd_node_new_decimal(doubled,unsignedfrac_digits)
Create a new node by serialising d into an xsd:decimal string. The resulting node will always contain a
`.', start with a digit, and end with a digit (i.e. will have a leading and/or trailing `0' if
necessary). It will never be in scientific notation. A maximum of frac_digits digits will be written
after the decimal point, but trailing zeros will automatically be omitted (except one if d is a round
integer).
Note that about 16 and 8 fractional digits are required to precisely represent a double and float,
respectively.
Parametersd The value for the new node.
frac_digits The maximum number of digits after the decimal place.
SerdNodeserd_node_new_integer(int64_ti)
Create a new node by serialising i into an xsd:integer string.
SerdNodeserd_node_new_blob(constvoid*buf,size_tsize,boolwrap_lines)
Create a node by serialising buf into an xsd:base64Binary string. This function can be used to make a
serialisable node out of arbitrary binary data, which can be decoded using serd_base64_decode().
Parametersbuf Raw binary input data.
size Size of buf.
wrap_lines Wrap lines at 76 characters to conform to RFC 2045.
voidserd_node_free(SerdNode*node)
Free any data owned by node. Note that if node is itself dynamically allocated (which is not the case for
nodes created internally by serd), it will not be freed.
SerdEnv*serd_env_new(constSerdNode*base_uri)
Create a new environment.
voidserd_env_free(SerdEnv*env)
Free ns.
constSerdNode*serd_env_get_base_uri(constSerdEnv*env,SerdURI*out)
Get the current base URI.
SerdStatusserd_env_set_base_uri(SerdEnv*env,constSerdNode*uri)
Set the current base URI.
SerdStatusserd_env_set_prefix(SerdEnv*env,constSerdNode*name,constSerdNode*uri)
Set a namespace prefix.
SerdStatusserd_env_set_prefix_from_strings(SerdEnv*env,constuint8_t*name,constuint8_t*uri)
Set a namespace prefix.
boolserd_env_qualify(constSerdEnv*env,constSerdNode*uri,SerdNode*prefix,SerdChunk*suffix)
Qualify uri into a CURIE if possible.
SerdStatusserd_env_expand(constSerdEnv*env,constSerdNode*curie,SerdChunk*uri_prefix,SerdChunk*uri_suffix)
Expand curie. Errors: SERD_ERR_BAD_ARG if curie is not valid, or SERD_ERR_BAD_CURIE if prefix is not
defined in env.
SerdNodeserd_env_expand_node(constSerdEnv*env,constSerdNode*node)
Expand node, which must be a CURIE or URI, to a full URI. Returns null if node can not be expanded.
voidserd_env_foreach(constSerdEnv*env,SerdPrefixSinkfunc,void*handle)
Call func for each prefix defined in env.
SerdReader*serd_reader_new(SerdSyntaxsyntax,void*handle,void(*)(void*)free_handle,SerdBaseSinkbase_sink,SerdPrefixSinkprefix_sink,SerdStatementSinkstatement_sink,SerdEndSinkend_sink)
Create a new RDF reader.
voidserd_reader_set_strict(SerdReader*reader,boolstrict)
Enable or disable strict parsing. The reader is non-strict (lax) by default, which will tolerate URIs
with invalid characters. Setting strict will fail when parsing such files. An error is printed for
invalid input in either case.
voidserd_reader_set_error_sink(SerdReader*reader,SerdErrorSinkerror_sink,void*error_handle)
Set a function to be called when errors occur during reading. The error_sink will be called with handle
as its first argument. If no error function is set, errors are printed to stderr in GCC style.
void*serd_reader_get_handle(constSerdReader*reader)
Return the handle passed to serd_reader_new().
voidserd_reader_add_blank_prefix(SerdReader*reader,constuint8_t*prefix)
Set a prefix to be added to all blank node identifiers. This is useful when multiple files are to be
parsed into the same output (e.g. a store, or other files). Since Serd preserves blank node IDs, this
could cause conflicts where two non-equivalent blank nodes are merged, resulting in corrupt data. By
setting a unique blank node prefix for each parsed file, this can be avoided, while preserving blank node
names.
voidserd_reader_set_default_graph(SerdReader*reader,constSerdNode*graph)
Set the URI of the default graph. If this is set, the reader will emit quads with the graph set to the
given node for any statements that are not in a named graph (which is currently all of them since Serd
currently does not support any graph syntaxes).
SerdStatusserd_reader_read_file(SerdReader*reader,constuint8_t*uri)
Read a file at a given uri.
SerdStatusserd_reader_start_stream(SerdReader*reader,FILE*file,constuint8_t*name,boolbulk)
Start an incremental read from a file handle. Iff bulk is true, file will be read a page at a time. This
is more efficient, but uses a page of memory and means that an entire page of input must be ready before
any callbacks will fire. To react as soon as input arrives, set bulk to false.
SerdStatusserd_reader_start_source_stream(SerdReader*reader,SerdSourceread_func,SerdStreamErrorFuncerror_func,void*stream,constuint8_t*name,size_tpage_size)
Start an incremental read from a user-specified source. The read_func is guaranteed to only be called for
page_size elements with size 1 (i.e. page_size bytes).
SerdStatusserd_reader_read_chunk(SerdReader*reader)
Read a single 'chunk' of data during an incremental read. This function will read a single top level
description, and return. This may be a directive, statement, or several statements; essentially it reads
until a '.' is encountered. This is particularly useful for reading directly from a pipe or socket.
SerdStatusserd_reader_end_stream(SerdReader*reader)
Finish an incremental read from a file handle.
SerdStatusserd_reader_read_file_handle(SerdReader*reader,FILE*file,constuint8_t*name)
Read file.
SerdStatusserd_reader_read_source(SerdReader*reader,SerdSourcesource,SerdStreamErrorFuncerror,void*stream,constuint8_t*name,size_tpage_size)
Read a user-specified byte source.
SerdStatusserd_reader_read_string(SerdReader*reader,constuint8_t*utf8)
Read utf8.
voidserd_reader_free(SerdReader*reader)
Free reader.
SerdWriter*serd_writer_new(SerdSyntaxsyntax,SerdStylestyle,SerdEnv*env,constSerdURI*base_uri,SerdSinkssink,void*stream)
Create a new RDF writer.
voidserd_writer_free(SerdWriter*writer)
Free writer.
SerdEnv*serd_writer_get_env(SerdWriter*writer)
Return the env used by writer.
size_tserd_file_sink(constvoid*buf,size_tlen,void*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.
size_tserd_chunk_sink(constvoid*buf,size_tlen,void*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().
uint8_t*serd_chunk_sink_finish(SerdChunk*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.
voidserd_writer_set_error_sink(SerdWriter*writer,SerdErrorSinkerror_sink,void*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.
voidserd_writer_chop_blank_prefix(SerdWriter*writer,constuint8_t*prefix)
Set a prefix to be removed from matching blank node identifiers.
SerdStatusserd_writer_set_base_uri(SerdWriter*writer,constSerdNode*uri)
Set the current output base URI (and emit directive if applicable). Note this function can be safely
casted to SerdBaseSink.
SerdStatusserd_writer_set_root_uri(SerdWriter*writer,constSerdNode*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.
SerdStatusserd_writer_set_prefix(SerdWriter*writer,constSerdNode*name,constSerdNode*uri)
Set a namespace prefix (and emit directive if applicable). Note this function can be safely casted to
SerdPrefixSink.
SerdStatusserd_writer_write_statement(SerdWriter*writer,SerdStatementFlagsflags,constSerdNode*graph,constSerdNode*subject,constSerdNode*predicate,constSerdNode*object,constSerdNode*datatype,constSerdNode*lang)
Write a statement. Note this function can be safely casted to SerdStatementSink.
SerdStatusserd_writer_end_anon(SerdWriter*writer,constSerdNode*node)
Mark the end of an anonymous node's description. Note this function can be safely casted to SerdEndSink.
SerdStatusserd_writer_finish(SerdWriter*writer)
Finish a write.
Name
serd - A lightweight RDF syntax library
Struct Serdchunk
An unterminated string fragment.
DataFields:
const uint8_t * buf Start of chunk.
size_t len Length of chunk in bytes.
Struct Serderror
An error description.
DataFields:SerdStatusstatus Error code.
const uint8_t * filename File where error was encountered, or NULL.
unsigned line Line where error was encountered, or 0.
unsigned col Column where error was encountered.
const char * fmt Message format string (printf style)
va_list * args Arguments for fmt.
Struct Serdnode
A syntactic RDF node.
DataFields:
const uint8_t * buf Value string.
size_t n_bytes Size in bytes (not including null)
size_t n_chars Length in characters (not including null)
SerdNodeFlagsflags Node flags (e.g. string properties)
SerdTypetype Node type.
Struct Serduri
A parsed URI.
This struct directly refers to chunks in other strings, it does not own any memory itself. Thus, URIs can
be parsed and/or resolved against a base URI in-place without allocating memory.
DataFields:SerdChunkscheme Scheme.
SerdChunkauthority Authority.
SerdChunkpath_base Path prefix if relative.
SerdChunkpath Path suffix.
SerdChunkquery Query.
SerdChunkfragment Fragment.
Synopsis
DataStructures
struct SerdNode
struct SerdChunk
struct SerdError
struct SerdURITypedefs
typedef struct SerdEnvImpl SerdEnv
typedef struct SerdReaderImpl SerdReader
typedef struct SerdWriterImpl SerdWriter
typedef uint32_t SerdStatementFlags
typedef uint32_t SerdNodeFlagsEnumerations
enum SerdStatus
enum SerdSyntax
enum SerdStatementFlag
enum SerdType
enum SerdNodeFlag
enum SerdStyleFunctions
void serd_free (void *ptr)
StringUtilities
const uint8_t * serd_strerror (SerdStatus status)
size_t serd_strlen (const uint8_t *str, size_t *n_bytes, SerdNodeFlags *flags)
double serd_strtod (const char *str, char **endptr)
void * serd_base64_decode (const uint8_t *str, size_t len, size_t *size)
ByteStreams
typedef int(* SerdStreamErrorFunc) (void *stream)
typedef size_t(* SerdSource) (void *buf, size_t size, size_t nmemb, void *stream)
typedef size_t(* SerdSink) (const void *buf, size_t len, void *stream)
URI
static const SerdURISERD_URI_NULL
const uint8_t * serd_uri_to_path (const uint8_t *uri)
uint8_t * serd_file_uri_parse (const uint8_t *uri, uint8_t **hostname)
bool serd_uri_string_has_scheme (const uint8_t *utf8)
SerdStatusserd_uri_parse (const uint8_t *utf8, SerdURI *out)
void serd_uri_resolve (const SerdURI *r, const SerdURI *base, SerdURI *t)
size_t serd_uri_serialise (const SerdURI *uri, SerdSink sink, void *stream)
size_t serd_uri_serialise_relative (const SerdURI *uri, const SerdURI *base, const SerdURI *root,
SerdSink sink, void *stream)
Node
static const SerdNodeSERD_NODE_NULL = { NULL, 0, 0, 0, SERD_NOTHING }
SerdNodeserd_node_from_string (SerdType type, const uint8_t *str)
SerdNodeserd_node_from_substring (SerdType type, const uint8_t *str, size_t len)
SerdNodeserd_node_copy (const SerdNode *node)
bool serd_node_equals (const SerdNode *a, const SerdNode *b)
SerdNodeserd_node_new_uri_from_node (const SerdNode *uri_node, const SerdURI *base, SerdURI *out)
SerdNodeserd_node_new_uri_from_string (const uint8_t *str, const SerdURI *base, SerdURI *out)
SerdNodeserd_node_new_file_uri (const uint8_t *path, const uint8_t *hostname, SerdURI *out, bool escape)
SerdNodeserd_node_new_uri (const SerdURI *uri, const SerdURI *base, SerdURI *out)
SerdNodeserd_node_new_relative_uri (const SerdURI *uri, const SerdURI *base, const SerdURI *root,
SerdURI *out)
SerdNodeserd_node_new_decimal (double d, unsigned frac_digits)
SerdNodeserd_node_new_integer (int64_t i)
SerdNodeserd_node_new_blob (const void *buf, size_t size, bool wrap_lines)
void serd_node_free (SerdNode *node)
EventHandlers
typedef SerdStatus(* SerdErrorSink) (void *handle, const SerdError *error)
typedef SerdStatus(* SerdBaseSink) (void *handle, const SerdNode *uri)
typedef SerdStatus(* SerdPrefixSink) (void *handle, const SerdNode *name, const SerdNode *uri)
typedef SerdStatus(* SerdStatementSink) (void *handle, SerdStatementFlags flags, const SerdNode *graph,
const SerdNode *subject, const SerdNode *predicate, const SerdNode *object, const SerdNode
*object_datatype, const SerdNode *object_lang)
typedef SerdStatus(* SerdEndSink) (void *handle, const SerdNode *node)
EnvironmentSerdEnv * serd_env_new (const SerdNode *base_uri)
void serd_env_free (SerdEnv *env)
const SerdNode * serd_env_get_base_uri (const SerdEnv *env, SerdURI *out)
SerdStatusserd_env_set_base_uri (SerdEnv *env, const SerdNode *uri)
SerdStatusserd_env_set_prefix (SerdEnv *env, const SerdNode *name, const SerdNode *uri)
SerdStatusserd_env_set_prefix_from_strings (SerdEnv *env, const uint8_t *name, const uint8_t *uri)
bool serd_env_qualify (const SerdEnv *env, const SerdNode *uri, SerdNode *prefix, SerdChunk *suffix)
SerdStatusserd_env_expand (const SerdEnv *env, const SerdNode *curie, SerdChunk *uri_prefix, SerdChunk
*uri_suffix)
SerdNodeserd_env_expand_node (const SerdEnv *env, const SerdNode *node)
void serd_env_foreach (const SerdEnv *env, SerdPrefixSink func, void *handle)
ReaderSerdReader * serd_reader_new (SerdSyntax syntax, void *handle, void(*free_handle)(void *), SerdBaseSink
base_sink, SerdPrefixSink prefix_sink, SerdStatementSink statement_sink, SerdEndSink end_sink)
void serd_reader_set_strict (SerdReader *reader, bool strict)
void serd_reader_set_error_sink (SerdReader *reader, SerdErrorSink error_sink, void *error_handle)
void * serd_reader_get_handle (const SerdReader *reader)
void serd_reader_add_blank_prefix (SerdReader *reader, const uint8_t *prefix)
void serd_reader_set_default_graph (SerdReader *reader, const SerdNode *graph)
SerdStatusserd_reader_read_file (SerdReader *reader, const uint8_t *uri)
SerdStatusserd_reader_start_stream (SerdReader *reader, FILE *file, const uint8_t *name, bool bulk)
SerdStatusserd_reader_start_source_stream (SerdReader *reader, SerdSource read_func, SerdStreamErrorFunc
error_func, void *stream, const uint8_t *name, size_t page_size)
SerdStatusserd_reader_read_chunk (SerdReader *reader)
SerdStatusserd_reader_end_stream (SerdReader *reader)
SerdStatusserd_reader_read_file_handle (SerdReader *reader, FILE *file, const uint8_t *name)
SerdStatusserd_reader_read_source (SerdReader *reader, SerdSource source, SerdStreamErrorFunc error,
void *stream, const uint8_t *name, size_t page_size)
SerdStatusserd_reader_read_string (SerdReader *reader, const uint8_t *utf8)
void serd_reader_free (SerdReader *reader)
WriterSerdWriter * serd_writer_new (SerdSyntax syntax, SerdStyle style, SerdEnv *env, const SerdURI *base_uri,
SerdSink ssink, void *stream)
void serd_writer_free (SerdWriter *writer)
SerdEnv * serd_writer_get_env (SerdWriter *writer)
size_t serd_file_sink (const void *buf, size_t len, void *stream)
size_t serd_chunk_sink (const void *buf, size_t len, void *stream)
uint8_t * serd_chunk_sink_finish (SerdChunk *stream)
void serd_writer_set_error_sink (SerdWriter *writer, SerdErrorSink error_sink, void *error_handle)
void serd_writer_chop_blank_prefix (SerdWriter *writer, const uint8_t *prefix)
SerdStatusserd_writer_set_base_uri (SerdWriter *writer, const SerdNode *uri)
SerdStatusserd_writer_set_root_uri (SerdWriter *writer, const SerdNode *uri)
SerdStatusserd_writer_set_prefix (SerdWriter *writer, const SerdNode *name, const SerdNode *uri)
SerdStatusserd_writer_write_statement (SerdWriter *writer, SerdStatementFlags flags, const SerdNode
*graph, const SerdNode *subject, const SerdNode *predicate, const SerdNode *object, const SerdNode
*datatype, const SerdNode *lang)
SerdStatusserd_writer_end_anon (SerdWriter *writer, const SerdNode *node)
SerdStatusserd_writer_finish (SerdWriter *writer)
Typedef Documentation
typedefstructSerdEnvImplSerdEnv
Environment. Represents the state required to resolve a CURIE or relative URI, e.g. the base URI and set
of namespace prefixes at a particular point.
typedefstructSerdReaderImplSerdReader
RDF reader. Parses RDF by calling user-provided sink functions as input is consumed (much like an XML SAX
parser).
typedefstructSerdWriterImplSerdWriter
RDF writer. Provides a number of functions to allow writing RDF syntax out to some stream. These
functions are deliberately compatible with the sink functions used by SerdReader, so a reader can be
directly connected to a writer to re-serialise a document with minimal overhead.
typedefuint32_tSerdStatementFlags
Bitwise OR of SerdStatementFlag values.
typedefuint32_tSerdNodeFlags
Bitwise OR of SerdNodeFlag values.
typedefint(*SerdStreamErrorFunc)(void*stream)
Function to detect I/O stream errors. Identical semantics to ferror.
Returns
Non-zero if stream has encountered an error.
typedefsize_t(*SerdSource)(void*buf,size_tsize,size_tnmemb,void*stream)
Source function for raw string input. Identical semantics to fread, but may set errno for more
informative error reporting than supported by SerdStreamErrorFunc.
Parametersbuf Output buffer.
size Size of a single element of data in bytes (always 1).
nmemb Number of elements to read.
stream Stream to read from (FILE* for fread).
Returns
Number of elements (bytes) read.
typedefsize_t(*SerdSink)(constvoid*buf,size_tlen,void*stream)
Sink function for raw string output.
typedefSerdStatus(*SerdErrorSink)(void*handle,constSerdError*error)
Sink (callback) for errors.
Parametershandle Handle for user data.
error Error description.
typedefSerdStatus(*SerdBaseSink)(void*handle,constSerdNode*uri)
Sink (callback) for base URI changes. Called whenever the base URI of the serialisation changes.
typedefSerdStatus(*SerdPrefixSink)(void*handle,constSerdNode*name,constSerdNode*uri)
Sink (callback) for namespace definitions. Called whenever a prefix is defined in the serialisation.
typedefSerdStatus(*SerdStatementSink)(void*handle,SerdStatementFlagsflags,constSerdNode*graph,constSerdNode*subject,constSerdNode*predicate,constSerdNode*object,constSerdNode*object_datatype,constSerdNode*object_lang)
Sink (callback) for statements. Called for every RDF statement in the serialisation.
typedefSerdStatus(*SerdEndSink)(void*handle,constSerdNode*node)
Sink (callback) for anonymous node end markers. This is called to indicate that the anonymous node with
the given value will no longer be referred to by any future statements (i.e. the anonymous serialisation
of the node is finished).
Variable Documentation
constSerdURISERD_URI_NULL[static]Initialvalue:
= {
{NULL, 0}, {NULL, 0}, {NULL, 0}, {NULL, 0}, {NULL, 0}, {NULL, 0}
}
constSerdNodeSERD_NODE_NULL={NULL,0,0,0,SERD_NOTHING}[static]