Serd C API¶
This is the complete public C API of serd.
-
struct
SerdNode
¶ A syntactic RDF node.
-
const uint8_t *
buf
¶ Value string.
-
size_t
n_bytes
¶ Size in bytes (excluding null)
-
size_t
n_chars
¶ String length (excluding null)
-
SerdNodeFlags
flags
¶ Node flags (string properties)
-
const uint8_t *
-
struct
SerdChunk
¶ An unterminated string fragment.
-
const uint8_t *
buf
¶ Start of chunk.
-
size_t
len
¶ Length of chunk in bytes.
-
const uint8_t *
-
struct
SerdError
¶ An error description.
-
SerdStatus
status
¶ Error code.
-
const uint8_t *
filename
¶ File with error.
-
unsigned
line
¶ Line in file with error or 0.
-
unsigned
col
¶ Column in file with error.
-
const char *
fmt
¶ Printf-style format string.
-
va_list *
args
¶ Arguments for fmt.
-
SerdStatus
-
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.
Authority.
-
enum
SerdStatus
¶ Return status code.
-
enumerator
SERD_SUCCESS
¶ No error.
-
enumerator
SERD_FAILURE
¶ Non-fatal failure.
-
enumerator
SERD_ERR_UNKNOWN
¶ Unknown error.
-
enumerator
SERD_ERR_BAD_SYNTAX
¶ Invalid syntax.
-
enumerator
SERD_ERR_BAD_ARG
¶ Invalid argument.
-
enumerator
SERD_ERR_NOT_FOUND
¶ Not found.
-
enumerator
SERD_ERR_ID_CLASH
¶ Encountered clashing blank node IDs.
-
enumerator
SERD_ERR_BAD_CURIE
¶ Invalid CURIE (e.g. prefix does not exist)
-
enumerator
SERD_ERR_INTERNAL
¶ Unexpected internal error (should not happen)
-
enumerator
-
enum
SerdSyntax
¶ RDF syntax type.
-
enumerator
SERD_TURTLE
¶ Terse triples http://www.w3.org/TR/turtle.
-
enumerator
SERD_NTRIPLES
¶ Line-based triples http://www.w3.org/TR/n-triples/.
-
enumerator
SERD_NQUADS
¶ Line-based quads http://www.w3.org/TR/n-quads/.
-
enumerator
SERD_TRIG
¶ Terse quads http://www.w3.org/TR/trig/.
-
enumerator
-
enum
SerdStatementFlag
¶ Flags indicating inline abbreviation information for a statement.
-
enumerator
SERD_EMPTY_S
¶ Empty blank node subject.
-
enumerator
SERD_EMPTY_O
¶ Empty blank node object.
-
enumerator
SERD_ANON_S_BEGIN
¶ Start of anonymous subject.
-
enumerator
SERD_ANON_O_BEGIN
¶ Start of anonymous object.
-
enumerator
SERD_ANON_CONT
¶ Continuation of anonymous node.
-
enumerator
SERD_LIST_S_BEGIN
¶ Start of list subject.
-
enumerator
SERD_LIST_O_BEGIN
¶ Start of list object.
-
enumerator
SERD_LIST_CONT
¶ Continuation of list.
-
enumerator
-
enum
SerdType
¶ Type of a node.
An RDF node, in the abstract sense, can be either a resource, literal, or a blank. This type is more precise, because syntactically there are two ways to refer to a resource (by URI or CURIE).
There are also two ways to refer to a blank node in syntax (by ID or anonymously), but this is handled by statement flags rather than distinct node types.
-
enumerator
SERD_NOTHING
¶ The type of a nonexistent node. This type is useful as a sentinel, but is never emitted by the reader.
-
enumerator
SERD_LITERAL
¶ Literal value. A literal optionally has either a language, or a datatype (not both).
-
enumerator
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”). RFC3986
-
enumerator
SERD_CURIE
¶ CURIE, a shortened URI. Value is an unquoted CURIE string relative to the current environment, e.g. “rdf:type”. CURIE Syntax 1.0
-
enumerator
SERD_BLANK
¶ A blank node. Value is a blank node ID without any syntactic prefix, like “id3”, which is meaningful only within this serialisation. RDF 1.1 Turtle
-
enumerator
-
enum
SerdNodeFlag
¶ Flags indicating certain string properties relevant to serialisation.
-
enumerator
SERD_HAS_NEWLINE
¶ Contains line breaks (‘n’ or ‘r’)
-
enumerator
SERD_HAS_QUOTE
¶ Contains quotes (‘”’)
-
enumerator
-
enum
SerdStyle
¶ Syntax style options.
These flags allow more precise control of writer output style. Note that some options are only supported for some syntaxes, for example, NTriples does not support abbreviation and is always ASCII.
-
enumerator
SERD_STYLE_ABBREVIATED
¶ Abbreviate triples when possible.
-
enumerator
SERD_STYLE_ASCII
¶ Escape all non-ASCII characters.
-
enumerator
SERD_STYLE_RESOLVED
¶ Resolve URIs against base URI.
-
enumerator
SERD_STYLE_CURIED
¶ Shorten URIs into CURIEs.
-
enumerator
SERD_STYLE_BULK
¶ Write output in pages.
-
enumerator
-
typedef struct SerdEnvImpl
SerdEnv
¶ Lexical environment for relative URIs or CURIEs (base URI and namespaces)
-
typedef struct SerdReaderImpl
SerdReader
¶ Streaming parser that reads a text stream and writes to a statement sink.
-
typedef struct SerdWriterImpl
SerdWriter
¶ Streaming serialiser that writes a text stream as statements are pushed.
-
typedef uint32_t
SerdStatementFlags
¶ Bitwise OR of SerdStatementFlag values.
-
typedef uint32_t
SerdNodeFlags
¶ Bitwise OR of SerdNodeFlag values.
-
void
serd_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.