serd.h   serd.h 
skipping to change at line 24 skipping to change at line 24
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/** /**
@file serd.h API for Serd, a lightweight RDF syntax library. @file serd.h API for Serd, a lightweight RDF syntax library.
*/ */
#ifndef SERD_SERD_H #ifndef SERD_SERD_H
#define SERD_SERD_H #define SERD_SERD_H
#include <stdarg.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#ifdef SERD_SHARED #ifdef SERD_SHARED
# ifdef _WIN32 # ifdef _WIN32
# define SERD_LIB_IMPORT __declspec(dllimport) # define SERD_LIB_IMPORT __declspec(dllimport)
# define SERD_LIB_EXPORT __declspec(dllexport) # define SERD_LIB_EXPORT __declspec(dllexport)
# else # else
# define SERD_LIB_IMPORT __attribute__((visibility("default"))) # define SERD_LIB_IMPORT __attribute__((visibility("default")))
skipping to change at line 92 skipping to change at line 93
/** /**
Return status code. Return status code.
*/ */
typedef enum { typedef enum {
SERD_SUCCESS, /**< No error */ SERD_SUCCESS, /**< No error */
SERD_FAILURE, /**< Non-fatal failure */ SERD_FAILURE, /**< Non-fatal failure */
SERD_ERR_UNKNOWN, /**< Unknown error */ SERD_ERR_UNKNOWN, /**< Unknown error */
SERD_ERR_BAD_SYNTAX, /**< Invalid syntax */ SERD_ERR_BAD_SYNTAX, /**< Invalid syntax */
SERD_ERR_BAD_ARG, /**< Invalid argument */ SERD_ERR_BAD_ARG, /**< Invalid argument */
SERD_ERR_NOT_FOUND /**< Not found */ 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 hap
pen) */
} SerdStatus; } SerdStatus;
/** /**
RDF syntax type. RDF syntax type.
*/ */
typedef enum { typedef enum {
/** /**
Turtle - Terse RDF Triple Language (UTF-8). Turtle - Terse RDF Triple Language (UTF-8).
@see <a href="http://www.w3.org/TeamSubmission/turtle/">Turtle</a > @see <a href="http://www.w3.org/TeamSubmission/turtle/">Turtle</a >
*/ */
skipping to change at line 219 skipping to change at line 223
/** /**
An unterminated string fragment. An unterminated string fragment.
*/ */
typedef struct { typedef struct {
const uint8_t* buf; /**< Start of chunk */ const uint8_t* buf; /**< Start of chunk */
size_t len; /**< Length of chunk in bytes */ size_t len; /**< Length of chunk in bytes */
} SerdChunk; } SerdChunk;
/** /**
An error description.
*/
typedef struct {
SerdStatus status; /**< 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 */
} SerdError;
/**
A parsed URI. A parsed URI.
This struct directly refers to chunks in other strings, it does not own any 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 memory itself. Thus, URIs can be parsed and/or resolved against a base URI
in-place without allocating memory. in-place without allocating memory.
*/ */
typedef struct { typedef struct {
SerdChunk scheme; /**< Scheme */ SerdChunk scheme; /**< Scheme */
SerdChunk authority; /**< Authority */ SerdChunk authority; /**< Authority */
SerdChunk path_base; /**< Path prefix if relative */ SerdChunk path_base; /**< Path prefix if relative */
skipping to change at line 516 skipping to change at line 532
void void
serd_node_free(SerdNode* node); serd_node_free(SerdNode* node);
/** /**
@} @}
@name Event Handlers @name Event Handlers
@{ @{
*/ */
/** /**
Sink (callback) for errors.
@param handle Handle for user data.
@param error Error description.
*/
typedef SerdStatus (*SerdErrorSink)(void* handle,
const SerdError* error);
/**
Sink (callback) for base URI changes. Sink (callback) for base URI changes.
Called whenever the base URI of the serialisation changes. Called whenever the base URI of the serialisation changes.
*/ */
typedef SerdStatus (*SerdBaseSink)(void* handle, typedef SerdStatus (*SerdBaseSink)(void* handle,
const SerdNode* uri); const SerdNode* uri);
/** /**
Sink (callback) for namespace definitions. Sink (callback) for namespace definitions.
skipping to change at line 667 skipping to change at line 692
SerdReader* SerdReader*
serd_reader_new(SerdSyntax syntax, serd_reader_new(SerdSyntax syntax,
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.
The @p error_sink will be called with @p handle as its first argument.
If
no error function is set, errors are printed to stderr in GCC style.
*/
SERD_API
void
serd_reader_set_error_sink(SerdReader* reader,
SerdErrorSink error_sink,
void* handle);
/**
Return the @c handle passed to @ref serd_reader_new. Return the @c handle passed to @ref 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
skipping to change at line 708 skipping to change at line 745
/** /**
Read a file at a given @c uri. Read a file at a given @c 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.
Iff @p bulk is true, @p file will be read a page at a time. This is mor
e
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
arrives, set @p bulk to false.
*/
SERD_API
SerdStatus
serd_reader_start_stream(SerdReader* me,
FILE* file,
const uint8_t* name,
bool bulk);
/**
Read a single "chunk" of data during an incremental read.
This function will read a single top level description, and return. Thi
s
may be a directive, statement, or several statements; essentially it rea
ds
until a '.' is encountered. This is particularly useful for reading
directly from a pipe or socket.
*/
SERD_API
SerdStatus
serd_reader_read_chunk(SerdReader* me);
/**
Finish an incremental read from a file handle.
*/
SERD_API
SerdStatus
serd_reader_end_stream(SerdReader* me);
/**
Read @c file. Read @c 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 @c utf8.
skipping to change at line 795 skipping to change at line 866
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.
The @p error_sink will be called with @p handle as its first argument.
If
no error function is set, errors are printed to stderr.
*/
SERD_API
void
serd_writer_set_error_sink(SerdWriter* writer,
SerdErrorSink error_sink,
void* handle);
/**
Set a prefix to be removed from matching blank node identifiers. Set a prefix to be removed from matching blank node identifiers.
*/ */
SERD_API SERD_API
void void
serd_writer_chop_blank_prefix(SerdWriter* writer, serd_writer_chop_blank_prefix(SerdWriter* writer,
const uint8_t* prefix); const uint8_t* prefix);
/** /**
Set the current output base URI (and emit directive if applicable). Set the current output base URI (and emit directive if applicable).
 End of changes. 7 change blocks. 
1 lines changed or deleted 95 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/