serd.h | serd.h | |||
---|---|---|---|---|
/* | /* | |||
Copyright 2011-2012 David Robillard <http://drobilla.net> | Copyright 2011-2014 David Robillard <http://drobilla.net> | |||
Permission to use, copy, modify, and/or distribute this software for any | Permission to use, copy, modify, and/or distribute this software for any | |||
purpose with or without fee is hereby granted, provided that the above | purpose with or without fee is hereby granted, provided that the above | |||
copyright notice and this permission notice appear in all copies. | copyright notice and this permission notice appear in all copies. | |||
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |||
skipping to change at line 280 | skipping to change at line 280 | |||
/** | /** | |||
Return a string describing a status code. | Return a string describing a status code. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
const uint8_t* | const uint8_t* | |||
serd_strerror(SerdStatus status); | serd_strerror(SerdStatus status); | |||
/** | /** | |||
Measure a UTF-8 string. | Measure a UTF-8 string. | |||
@return Length of @c str in characters (except NULL). | @return Length of `str` in characters (except NULL). | |||
@param str A null-terminated UTF-8 string. | @param str A null-terminated UTF-8 string. | |||
@param n_bytes (Output) Set to the size of @c str in bytes (except NULL) . | @param n_bytes (Output) Set to the size of `str` in bytes (except NULL). | |||
@param flags (Output) Set to the applicable flags. | @param flags (Output) Set to the applicable flags. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
size_t | size_t | |||
serd_strlen(const uint8_t* str, size_t* n_bytes, SerdNodeFlags* flags); | serd_strlen(const uint8_t* str, size_t* n_bytes, SerdNodeFlags* flags); | |||
/** | /** | |||
Parse a string to a double. | Parse a string to a double. | |||
The API of this function is identical to the standard C strtod function, | The API of this function is identical to the standard C strtod function, | |||
skipping to change at line 306 | skipping to change at line 306 | |||
SERD_API | SERD_API | |||
double | double | |||
serd_strtod(const char* str, char** endptr); | serd_strtod(const char* str, char** endptr); | |||
/** | /** | |||
Decode a base64 string. | Decode a base64 string. | |||
This function can be used to deserialise a blob node created with | This function can be used to deserialise a blob node created with | |||
serd_node_new_blob(). | serd_node_new_blob(). | |||
@param str Base64 string to decode. | @param str Base64 string to decode. | |||
@param len The length of @c str. | @param len The length of `str`. | |||
@param size Set to the size of the returned blob in bytes. | @param size Set to the size of the returned blob in bytes. | |||
@return A newly allocated blob which must be freed with free(). | @return A newly allocated blob which must be freed with free(). | |||
*/ | */ | |||
SERD_API | SERD_API | |||
void* | void* | |||
serd_base64_decode(const uint8_t* str, size_t len, size_t* size); | serd_base64_decode(const uint8_t* str, size_t len, size_t* size); | |||
/** | /** | |||
@} | @} | |||
@name URI | @name URI | |||
@{ | @{ | |||
*/ | */ | |||
static const SerdURI SERD_URI_NULL = {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}}; | static const SerdURI SERD_URI_NULL = {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}}; | |||
/** | /** | |||
Return the local path for @c uri, or NULL if @c uri is not a file 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 | Note this (inappropriately named) function only removes the file scheme if | |||
necessary, and returns @c uri unmodified if it is an absolute path. Per cent | necessary, and returns `uri` unmodified if it is an absolute path. Perc ent | |||
encoding and other issues are not handled, to properly convert a file UR I to | encoding and other issues are not handled, to properly convert a file UR I to | |||
a path, use serd_file_uri_parse(). | a path, use serd_file_uri_parse(). | |||
*/ | */ | |||
SERD_API | SERD_API | |||
const uint8_t* | const uint8_t* | |||
serd_uri_to_path(const uint8_t* uri); | serd_uri_to_path(const uint8_t* uri); | |||
/** | /** | |||
Get the unescaped path and hostname from a file URI. | Get the unescaped path and hostname from a file URI. | |||
@param uri A file URI. | @param uri A file URI. | |||
@param hostname If non-NULL, set to the hostname, if present. | @param hostname If non-NULL, set to the hostname, if present. | |||
@return The path component of the URI. | @return The path component of the URI. | |||
Both the returned path and @c hostname (if applicable) are owned by the | Both the returned path and `hostname` (if applicable) are owned by the | |||
caller and must be freed with free(). | caller and must be freed with free(). | |||
*/ | */ | |||
SERD_API | SERD_API | |||
uint8_t* | uint8_t* | |||
serd_file_uri_parse(const uint8_t* uri, uint8_t** hostname); | serd_file_uri_parse(const uint8_t* uri, uint8_t** hostname); | |||
/** | /** | |||
Return true iff @c utf8 starts with a valid URI scheme. | Return true iff `utf8` starts with a valid URI scheme. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
bool | bool | |||
serd_uri_string_has_scheme(const uint8_t* utf8); | serd_uri_string_has_scheme(const uint8_t* utf8); | |||
/** | /** | |||
Parse @c utf8, writing result to @c out. | Parse `utf8`, writing result to `out`. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdStatus | SerdStatus | |||
serd_uri_parse(const uint8_t* utf8, SerdURI* out); | serd_uri_parse(const uint8_t* utf8, SerdURI* out); | |||
/** | /** | |||
Set @c out to @c uri resolved against @c base. | Set `out` to `uri` resolved against `base`. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
void | void | |||
serd_uri_resolve(const SerdURI* uri, const SerdURI* base, SerdURI* out); | serd_uri_resolve(const SerdURI* uri, const SerdURI* base, SerdURI* out); | |||
/** | /** | |||
Sink function for raw string output. | Sink function for raw string output. | |||
*/ | */ | |||
typedef size_t (*SerdSink)(const void* buf, size_t len, void* stream); | typedef size_t (*SerdSink)(const void* buf, size_t len, void* stream); | |||
/** | /** | |||
Serialise @c uri with a series of calls to @c sink. | Serialise `uri` with a series of calls to `sink`. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
size_t | size_t | |||
serd_uri_serialise(const SerdURI* uri, SerdSink sink, void* stream); | serd_uri_serialise(const SerdURI* uri, SerdSink sink, void* stream); | |||
/** | /** | |||
Serialise @c uri relative to @c base with a series of calls to @c sink. | Serialise `uri` relative to `base` with a series of calls to `sink`. | |||
The @c uri is written as a relative URI iff if it a child of @c base and | The `uri` is written as a relative URI iff if it a child of `base` and @ | |||
@c | c | |||
root. The optional @c root parameter must be a prefix of @c base and ca | root. The optional `root` parameter must be a prefix of `base` and can | |||
n be | be | |||
used keep up-references ("../") within a certain namespace. | used keep up-references ("../") within a certain namespace. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
size_t | size_t | |||
serd_uri_serialise_relative(const SerdURI* uri, | serd_uri_serialise_relative(const SerdURI* uri, | |||
const SerdURI* base, | const SerdURI* base, | |||
const SerdURI* root, | const SerdURI* root, | |||
SerdSink sink, | SerdSink sink, | |||
void* stream); | void* stream); | |||
/** | /** | |||
@} | @} | |||
@name Node | @name Node | |||
@{ | @{ | |||
*/ | */ | |||
static const SerdNode SERD_NODE_NULL = { 0, 0, 0, 0, SERD_NOTHING }; | static const SerdNode SERD_NODE_NULL = { 0, 0, 0, 0, SERD_NOTHING }; | |||
/** | /** | |||
Make a (shallow) node from @c str. | Make a (shallow) node from `str`. | |||
This measures, but does not copy, @c str. No memory is allocated. | This measures, but does not copy, `str`. No memory is allocated. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdNode | SerdNode | |||
serd_node_from_string(SerdType type, const uint8_t* str); | serd_node_from_string(SerdType type, const uint8_t* str); | |||
/** | /** | |||
Make a deep copy of @c node. | Make a deep copy of `node`. | |||
@return a node that the caller must free with @ref serd_node_free. | @return a node that the caller must free with serd_node_free(). | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdNode | SerdNode | |||
serd_node_copy(const SerdNode* node); | serd_node_copy(const SerdNode* node); | |||
/** | /** | |||
Return true iff @c a is equal to @c b. | Return true iff `a` is equal to `b`. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
bool | bool | |||
serd_node_equals(const SerdNode* a, const SerdNode* b); | serd_node_equals(const SerdNode* a, const SerdNode* b); | |||
/** | /** | |||
Simple wrapper for serd_node_new_uri to resolve a URI node. | Simple wrapper for serd_node_new_uri to resolve a URI node. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdNode | SerdNode | |||
skipping to change at line 449 | skipping to change at line 449 | |||
SERD_API | SERD_API | |||
SerdNode | SerdNode | |||
serd_node_new_uri_from_string(const uint8_t* str, | serd_node_new_uri_from_string(const uint8_t* str, | |||
const SerdURI* base, | const SerdURI* base, | |||
SerdURI* out); | SerdURI* out); | |||
/** | /** | |||
Create a new file URI node from a file system path and optional hostname . | 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 | Backslashes in Windows paths will be converted and '%' will always be | |||
percent encoded. If @c escape is true, all other invalid characters wil l be | percent encoded. If `escape` is true, all other invalid characters will be | |||
percent encoded as well. | percent encoded as well. | |||
If @c path is relative, @c hostname is ignored. | If `path` is relative, `hostname` is ignored. | |||
If @c out is not NULL, it will be set to the parsed URI. | If `out` is not NULL, it will be set to the parsed URI. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdNode | SerdNode | |||
serd_node_new_file_uri(const uint8_t* path, | serd_node_new_file_uri(const uint8_t* path, | |||
const uint8_t* hostname, | const uint8_t* hostname, | |||
SerdURI* out, | SerdURI* out, | |||
bool escape); | bool escape); | |||
/** | /** | |||
Create a new node by serialising @c uri into a new string. | Create a new node by serialising `uri` into a new string. | |||
@param uri The URI to parse and serialise. | @param uri The URI to parse and serialise. | |||
@param base Base URI to resolve @c uri against (or NULL for no resolutio n). | @param base Base URI to resolve `uri` against (or NULL for no resolution ). | |||
@param out Set to the parsing of the new URI (i.e. points only to | @param out Set to the parsing of the new URI (i.e. points only to | |||
memory owned by the new returned node). | memory owned by the new returned node). | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdNode | SerdNode | |||
serd_node_new_uri(const SerdURI* uri, const SerdURI* base, SerdURI* out); | serd_node_new_uri(const SerdURI* uri, const SerdURI* base, SerdURI* out); | |||
/** | /** | |||
Create a new node by serialising @c d into an xsd:decimal string. | Create a new node by serialising `d` into an xsd:decimal string. | |||
The resulting node will always contain a `.', start with a digit, and en d | The resulting node will always contain a `.', start with a digit, and en d | |||
with a digit (i.e. will have a leading and/or trailing `0' if necessary) . | 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 @c frac_digits di gits | It will never be in scientific notation. A maximum of `frac_digits` dig its | |||
will be written after the decimal point, but trailing zeros will | will be written after the decimal point, but trailing zeros will | |||
automatically be omitted (except one if @c d is a round integer). | automatically be omitted (except one if `d` is a round integer). | |||
Note that about 16 and 8 fractional digits are required to precisely | Note that about 16 and 8 fractional digits are required to precisely | |||
represent a double and float, respectively. | represent a double and float, respectively. | |||
@param d The value for the new node. | @param d The value for the new node. | |||
@param frac_digits The maximum number of digits after the decimal place. | @param frac_digits The maximum number of digits after the decimal place. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdNode | SerdNode | |||
serd_node_new_decimal(double d, unsigned frac_digits); | serd_node_new_decimal(double d, unsigned frac_digits); | |||
/** | /** | |||
Create a new node by serialising @c i into an xsd:integer string. | Create a new node by serialising `i` into an xsd:integer string. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdNode | SerdNode | |||
serd_node_new_integer(int64_t i); | serd_node_new_integer(int64_t i); | |||
/** | /** | |||
Create a node by serialising @c buf into an xsd:base64Binary string. | Create a node by serialising `buf` into an xsd:base64Binary string. | |||
This function can be used to make a serialisable node out of arbitrary | This function can be used to make a serialisable node out of arbitrary | |||
binary data, which can be decoded using serd_base64_decode(). | binary data, which can be decoded using serd_base64_decode(). | |||
@param buf Raw binary input data. | @param buf Raw binary input data. | |||
@param size Size of @c buf. | @param size Size of `buf`. | |||
@param wrap_lines Wrap lines at 76 characters to conform to RFC 2045. | @param wrap_lines Wrap lines at 76 characters to conform to RFC 2045. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdNode | SerdNode | |||
serd_node_new_blob(const void* buf, size_t size, bool wrap_lines); | serd_node_new_blob(const void* buf, size_t size, bool wrap_lines); | |||
/** | /** | |||
Free any data owned by @c node. | Free any data owned by `node`. | |||
Note that if @c node is itself dynamically allocated (which is not the c ase | Note that if `node` is itself dynamically allocated (which is not the ca se | |||
for nodes created internally by serd), it will not be freed. | for nodes created internally by serd), it will not be freed. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
void | void | |||
serd_node_free(SerdNode* node); | serd_node_free(SerdNode* node); | |||
/** | /** | |||
@} | @} | |||
@name Event Handlers | @name Event Handlers | |||
@{ | @{ | |||
skipping to change at line 575 | skipping to change at line 575 | |||
const SerdNode* subject, | const SerdNode* subject, | |||
const SerdNode* predicate, | const SerdNode* predicate, | |||
const SerdNode* object, | const SerdNode* object, | |||
const SerdNode* object_datatype, | const SerdNode* object_datatype, | |||
const SerdNode* object_lang); | const SerdNode* object_lang); | |||
/** | /** | |||
Sink (callback) for anonymous node end markers. | Sink (callback) for anonymous node end markers. | |||
This is called to indicate that the anonymous node with the given | This is called to indicate that the anonymous node with the given | |||
@c value will no longer be referred to by any future statements | `value` will no longer be referred to by any future statements | |||
(i.e. the anonymous serialisation of the node is finished). | (i.e. the anonymous serialisation of the node is finished). | |||
*/ | */ | |||
typedef SerdStatus (*SerdEndSink)(void* handle, | typedef SerdStatus (*SerdEndSink)(void* handle, | |||
const SerdNode* node); | const SerdNode* node); | |||
/** | /** | |||
@} | @} | |||
@name Environment | @name Environment | |||
@{ | @{ | |||
*/ | */ | |||
/** | /** | |||
Create a new environment. | Create a new environment. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdEnv* | SerdEnv* | |||
serd_env_new(const SerdNode* base_uri); | serd_env_new(const SerdNode* base_uri); | |||
/** | /** | |||
Free @c ns. | Free `ns`. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
void | void | |||
serd_env_free(SerdEnv* env); | serd_env_free(SerdEnv* env); | |||
/** | /** | |||
Get the current base URI. | Get the current base URI. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
const SerdNode* | const SerdNode* | |||
skipping to change at line 636 | skipping to change at line 636 | |||
/** | /** | |||
Set a namespace prefix. | Set a namespace prefix. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdStatus | SerdStatus | |||
serd_env_set_prefix_from_strings(SerdEnv* env, | serd_env_set_prefix_from_strings(SerdEnv* env, | |||
const uint8_t* name, | const uint8_t* name, | |||
const uint8_t* uri); | const uint8_t* uri); | |||
/** | /** | |||
Qualify @c uri into a CURIE if possible. | Qualify `uri` into a CURIE if possible. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
bool | bool | |||
serd_env_qualify(const SerdEnv* env, | serd_env_qualify(const SerdEnv* env, | |||
const SerdNode* uri, | const SerdNode* uri, | |||
SerdNode* prefix, | SerdNode* prefix, | |||
SerdChunk* suffix); | SerdChunk* suffix); | |||
/** | /** | |||
Expand @c curie. | Expand `curie`. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdStatus | SerdStatus | |||
serd_env_expand(const SerdEnv* env, | serd_env_expand(const SerdEnv* env, | |||
const SerdNode* curie, | const SerdNode* curie, | |||
SerdChunk* uri_prefix, | SerdChunk* uri_prefix, | |||
SerdChunk* uri_suffix); | SerdChunk* uri_suffix); | |||
/** | /** | |||
Expand @c node, which must be a CURIE or URI, to a full URI. | Expand `node`, which must be a CURIE or URI, to a full URI. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdNode | SerdNode | |||
serd_env_expand_node(const SerdEnv* env, | serd_env_expand_node(const SerdEnv* env, | |||
const SerdNode* node); | const SerdNode* node); | |||
/** | /** | |||
Call @c func for each prefix defined in @c env. | Call `func` for each prefix defined in `env`. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
void | void | |||
serd_env_foreach(const SerdEnv* env, | serd_env_foreach(const SerdEnv* env, | |||
SerdPrefixSink func, | SerdPrefixSink func, | |||
void* handle); | void* handle); | |||
/** | /** | |||
@} | @} | |||
@name Reader | @name Reader | |||
skipping to change at line 694 | skipping to change at line 694 | |||
void* handle, | void* handle, | |||
void (*free_handle)(void*), | void (*free_handle)(void*), | |||
SerdBaseSink base_sink, | SerdBaseSink base_sink, | |||
SerdPrefixSink prefix_sink, | SerdPrefixSink prefix_sink, | |||
SerdStatementSink statement_sink, | SerdStatementSink statement_sink, | |||
SerdEndSink end_sink); | SerdEndSink end_sink); | |||
/** | /** | |||
Set a function to be called when errors occur during reading. | Set a function to be called when errors occur during reading. | |||
The @p error_sink will be called with @p handle as its first argument. If | 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. | no error function is set, errors are printed to stderr in GCC style. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
void | void | |||
serd_reader_set_error_sink(SerdReader* reader, | serd_reader_set_error_sink(SerdReader* reader, | |||
SerdErrorSink error_sink, | SerdErrorSink error_sink, | |||
void* handle); | void* handle); | |||
/** | /** | |||
Return the @c handle passed to @ref serd_reader_new. | Return the `handle` passed to serd_reader_new(). | |||
*/ | */ | |||
SERD_API | SERD_API | |||
void* | void* | |||
serd_reader_get_handle(const SerdReader* reader); | serd_reader_get_handle(const SerdReader* reader); | |||
/** | /** | |||
Set a prefix to be added to all blank node identifiers. | 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 | 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, th is | (e.g. a store, or other files). Since Serd preserves blank node IDs, th is | |||
skipping to change at line 737 | skipping to change at line 737 | |||
If this is set, the reader will emit quads with the graph set to the giv en | If this is set, the reader will emit quads with the graph set to the giv en | |||
node for any statements that are not in a named graph (which is currentl y | node for any statements that are not in a named graph (which is currentl y | |||
all of them since Serd currently does not support any graph syntaxes). | all of them since Serd currently does not support any graph syntaxes). | |||
*/ | */ | |||
SERD_API | SERD_API | |||
void | void | |||
serd_reader_set_default_graph(SerdReader* reader, | serd_reader_set_default_graph(SerdReader* reader, | |||
const SerdNode* graph); | const SerdNode* graph); | |||
/** | /** | |||
Read a file at a given @c uri. | Read a file at a given `uri`. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdStatus | SerdStatus | |||
serd_reader_read_file(SerdReader* reader, | serd_reader_read_file(SerdReader* reader, | |||
const uint8_t* uri); | const uint8_t* uri); | |||
/** | /** | |||
Start an incremental read from a file handle. | Start an incremental read from a file handle. | |||
Iff @p bulk is true, @p file will be read a page at a time. This is mor e | 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 in put | efficient, but uses a page of memory and means that an entire page of in put | |||
must be ready before any callbacks will fire. To react as soon as input | must be ready before any callbacks will fire. To react as soon as input | |||
arrives, set @p bulk to false. | arrives, set `bulk` to false. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdStatus | SerdStatus | |||
serd_reader_start_stream(SerdReader* me, | serd_reader_start_stream(SerdReader* me, | |||
FILE* file, | FILE* file, | |||
const uint8_t* name, | const uint8_t* name, | |||
bool bulk); | bool bulk); | |||
/** | /** | |||
Read a single "chunk" of data during an incremental read. | Read a single "chunk" of data during an incremental read. | |||
skipping to change at line 779 | skipping to change at line 779 | |||
serd_reader_read_chunk(SerdReader* me); | serd_reader_read_chunk(SerdReader* me); | |||
/** | /** | |||
Finish an incremental read from a file handle. | Finish an incremental read from a file handle. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdStatus | SerdStatus | |||
serd_reader_end_stream(SerdReader* me); | serd_reader_end_stream(SerdReader* me); | |||
/** | /** | |||
Read @c file. | Read `file`. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdStatus | SerdStatus | |||
serd_reader_read_file_handle(SerdReader* reader, | serd_reader_read_file_handle(SerdReader* reader, | |||
FILE* file, | FILE* file, | |||
const uint8_t* name); | const uint8_t* name); | |||
/** | /** | |||
Read @c utf8. | Read `utf8`. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdStatus | SerdStatus | |||
serd_reader_read_string(SerdReader* me, const uint8_t* utf8); | serd_reader_read_string(SerdReader* me, const uint8_t* utf8); | |||
/** | /** | |||
Free @c reader. | Free `reader`. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
void | void | |||
serd_reader_free(SerdReader* reader); | serd_reader_free(SerdReader* reader); | |||
/** | /** | |||
@} | @} | |||
@name Writer | @name Writer | |||
@{ | @{ | |||
*/ | */ | |||
skipping to change at line 820 | skipping to change at line 820 | |||
SERD_API | SERD_API | |||
SerdWriter* | SerdWriter* | |||
serd_writer_new(SerdSyntax syntax, | serd_writer_new(SerdSyntax syntax, | |||
SerdStyle style, | SerdStyle style, | |||
SerdEnv* env, | SerdEnv* env, | |||
const SerdURI* base_uri, | const SerdURI* base_uri, | |||
SerdSink sink, | SerdSink sink, | |||
void* stream); | void* stream); | |||
/** | /** | |||
Free @c writer. | Free `writer`. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
void | void | |||
serd_writer_free(SerdWriter* writer); | serd_writer_free(SerdWriter* writer); | |||
/** | /** | |||
Return the env used by @c writer. | Return the env used by `writer`. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
SerdEnv* | SerdEnv* | |||
serd_writer_get_env(SerdWriter* writer); | serd_writer_get_env(SerdWriter* writer); | |||
/** | /** | |||
A convenience sink function for writing to a FILE*. | A convenience sink function for writing to a FILE*. | |||
This function can be used as a SerdSink when writing to a FILE*. The | This function can be used as a SerdSink when writing to a FILE*. The | |||
@c stream parameter must be a FILE* opened for writing. | `stream` parameter must be a FILE* opened for writing. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
size_t | size_t | |||
serd_file_sink(const void* buf, size_t len, void* stream); | serd_file_sink(const void* buf, size_t len, void* stream); | |||
/** | /** | |||
A convenience sink function for writing to a string. | A convenience sink function for writing to a string. | |||
This function can be used as a SerdSink to write to a SerdChunk which is | This function can be used as a SerdSink to write to a SerdChunk which is | |||
resized as necessary with realloc(). The @c stream parameter must point to | resized as necessary with realloc(). The `stream` parameter must point to | |||
an initialized SerdChunk. When the write is finished, the string should be | an initialized SerdChunk. When the write is finished, the string should be | |||
retrieved with serd_chunk_sink_finish(). | retrieved with serd_chunk_sink_finish(). | |||
*/ | */ | |||
SERD_API | SERD_API | |||
size_t | size_t | |||
serd_chunk_sink(const void* buf, size_t len, void* stream); | serd_chunk_sink(const void* buf, size_t len, void* stream); | |||
/** | /** | |||
Finish a serialisation to a chunk with serd_chunk_sink(). | Finish a serialisation to a chunk with serd_chunk_sink(). | |||
The returned string is the result of the serialisation, which is NULL | The returned string is the result of the serialisation, which is NULL | |||
terminated (by this function) and owned by the caller. | terminated (by this function) and owned by the caller. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
uint8_t* | uint8_t* | |||
serd_chunk_sink_finish(SerdChunk* stream); | serd_chunk_sink_finish(SerdChunk* stream); | |||
/** | /** | |||
Set a function to be called when errors occur during writing. | Set a function to be called when errors occur during writing. | |||
The @p error_sink will be called with @p handle as its first argument. If | The `error_sink` will be called with `handle` as its first argument. If | |||
no error function is set, errors are printed to stderr. | no error function is set, errors are printed to stderr. | |||
*/ | */ | |||
SERD_API | SERD_API | |||
void | void | |||
serd_writer_set_error_sink(SerdWriter* writer, | serd_writer_set_error_sink(SerdWriter* writer, | |||
SerdErrorSink error_sink, | SerdErrorSink error_sink, | |||
void* handle); | void* handle); | |||
/** | /** | |||
Set a prefix to be removed from matching blank node identifiers. | Set a prefix to be removed from matching blank node identifiers. | |||
End of changes. 49 change blocks. | ||||
53 lines changed or deleted | 53 lines changed or added | |||