LMMS
Loading...
Searching...
No Matches
writer.c File Reference
#include "serd_internal.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Classes

struct  WriteContext
struct  SepRule
struct  SerdWriterImpl

Macros

#define NS_RDF   "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
#define NS_XSD   "http://www.w3.org/2001/XMLSchema#"
#define READ_BYTE()
#define TRY(write_result)

Enumerations

enum  Sep {
  SEP_NONE , SEP_END_S , SEP_END_P , SEP_END_O ,
  SEP_S_P , SEP_P_O , SEP_ANON_BEGIN , SEP_ANON_END ,
  SEP_LIST_BEGIN , SEP_LIST_SEP , SEP_LIST_END
}
enum  TextContext { WRITE_STRING , WRITE_LONG_STRING }
enum  Field { FIELD_NONE , FIELD_SUBJECT , FIELD_PREDICATE , FIELD_OBJECT }

Functions

static void w_err (SerdWriter *writer, SerdStatus st, const char *fmt,...)
static WriteContextanon_stack_top (SerdWriter *writer)
static void copy_node (SerdNode *dst, const SerdNode *src)
static size_t sink (const void *buf, size_t len, SerdWriter *writer)
static uint32_t parse_utf8_char (SerdWriter *writer, const uint8_t *utf8, size_t *size)
static size_t write_character (SerdWriter *writer, const uint8_t *utf8, size_t *size)
static bool uri_must_escape (const uint8_t c)
static size_t write_uri (SerdWriter *writer, const uint8_t *utf8, size_t n_bytes)
static bool lname_must_escape (const uint8_t c)
static size_t write_lname (SerdWriter *writer, const uint8_t *utf8, size_t n_bytes)
static size_t write_text (SerdWriter *writer, TextContext ctx, const uint8_t *utf8, size_t n_bytes)
static size_t uri_sink (const void *buf, size_t len, void *stream)
static void write_newline (SerdWriter *writer)
static void write_sep (SerdWriter *writer, const Sep sep)
static SerdStatus reset_context (SerdWriter *writer, bool del)
static bool is_inline_start (const SerdWriter *writer, Field field, SerdStatementFlags flags)
static bool write_node (SerdWriter *writer, const SerdNode *node, const SerdNode *datatype, const SerdNode *lang, Field field, SerdStatementFlags flags)
static bool is_resource (const SerdNode *node)
static void write_pred (SerdWriter *writer, SerdStatementFlags flags, const SerdNode *pred)
static bool write_list_obj (SerdWriter *writer, SerdStatementFlags flags, const SerdNode *predicate, const SerdNode *object, const SerdNode *datatype, const SerdNode *lang)
SERD_API SerdStatus serd_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)
SERD_API SerdStatus serd_writer_end_anon (SerdWriter *writer, const SerdNode *node)
SERD_API SerdStatus serd_writer_finish (SerdWriter *writer)
SERD_API SerdWriterserd_writer_new (SerdSyntax syntax, SerdStyle style, SerdEnv *env, const SerdURI *base_uri, SerdSink ssink, void *stream)
SERD_API void serd_writer_set_error_sink (SerdWriter *writer, SerdErrorSink error_sink, void *error_handle)
SERD_API void serd_writer_chop_blank_prefix (SerdWriter *writer, const uint8_t *prefix)
SERD_API SerdStatus serd_writer_set_base_uri (SerdWriter *writer, const SerdNode *uri)
SERD_API SerdStatus serd_writer_set_root_uri (SerdWriter *writer, const SerdNode *uri)
SERD_API SerdStatus serd_writer_set_prefix (SerdWriter *writer, const SerdNode *name, const SerdNode *uri)
SERD_API void serd_writer_free (SerdWriter *writer)
SERD_API SerdEnvserd_writer_get_env (SerdWriter *writer)
SERD_API size_t serd_file_sink (const void *buf, size_t len, void *stream)
SERD_API size_t serd_chunk_sink (const void *buf, size_t len, void *stream)
SERD_API uint8_tserd_chunk_sink_finish (SerdChunk *stream)

Variables

static const WriteContext WRITE_CONTEXT_NULL
static const SepRule rules []

Macro Definition Documentation

◆ NS_RDF

#define NS_RDF   "http://www.w3.org/1999/02/22-rdf-syntax-ns#"

◆ NS_XSD

#define NS_XSD   "http://www.w3.org/2001/XMLSchema#"

◆ READ_BYTE

#define READ_BYTE ( )
Value:
in = utf8[i++] & 0x3F; \
c = (c << 6) | in;
register unsigned i
Definition inflate.c:1575
float in
Definition lilv_test.c:1460
return c
Definition crypt.c:175

◆ TRY

#define TRY ( write_result)
Value:
if (!write_result) { \
return SERD_ERR_UNKNOWN; \
}
@ SERD_ERR_UNKNOWN
Unknown error.
Definition serd.h:103

Enumeration Type Documentation

◆ Field

enum Field
Enumerator
FIELD_NONE 
FIELD_SUBJECT 
FIELD_PREDICATE 
FIELD_OBJECT 

◆ Sep

enum Sep
Enumerator
SEP_NONE 
SEP_END_S 

End of a subject ('.').

SEP_END_P 

End of a predicate (';').

SEP_END_O 

End of an object (',').

SEP_S_P 

Between a subject and predicate (whitespace).

SEP_P_O 

Between a predicate and object (whitespace).

SEP_ANON_BEGIN 

Start of anonymous node ('[').

SEP_ANON_END 

End of anonymous node (']').

SEP_LIST_BEGIN 

Start of list ('(').

SEP_LIST_SEP 

List separator (whitespace).

SEP_LIST_END 

End of list (')').

◆ TextContext

Enumerator
WRITE_STRING 
WRITE_LONG_STRING 

Function Documentation

◆ anon_stack_top()

WriteContext * anon_stack_top ( SerdWriter * writer)
inlinestatic

◆ copy_node()

void copy_node ( SerdNode * dst,
const SerdNode * src )
static

◆ is_inline_start()

bool is_inline_start ( const SerdWriter * writer,
Field field,
SerdStatementFlags flags )
static

◆ is_resource()

bool is_resource ( const SerdNode * node)
inlinestatic

◆ lname_must_escape()

bool lname_must_escape ( const uint8_t c)
static

◆ parse_utf8_char()

uint32_t parse_utf8_char ( SerdWriter * writer,
const uint8_t * utf8,
size_t * size )
inlinestatic

◆ reset_context()

SerdStatus reset_context ( SerdWriter * writer,
bool del )
static

◆ sink()

size_t sink ( const void * buf,
size_t len,
SerdWriter * writer )
inlinestatic

◆ uri_must_escape()

bool uri_must_escape ( const uint8_t c)
inlinestatic

◆ uri_sink()

size_t uri_sink ( const void * buf,
size_t len,
void * stream )
static

◆ w_err()

void w_err ( SerdWriter * writer,
SerdStatus st,
const char * fmt,
... )
static

◆ write_character()

size_t write_character ( SerdWriter * writer,
const uint8_t * utf8,
size_t * size )
static

◆ write_list_obj()

bool write_list_obj ( SerdWriter * writer,
SerdStatementFlags flags,
const SerdNode * predicate,
const SerdNode * object,
const SerdNode * datatype,
const SerdNode * lang )
static

◆ write_lname()

size_t write_lname ( SerdWriter * writer,
const uint8_t * utf8,
size_t n_bytes )
static

◆ write_newline()

void write_newline ( SerdWriter * writer)
static

◆ write_node()

bool write_node ( SerdWriter * writer,
const SerdNode * node,
const SerdNode * datatype,
const SerdNode * lang,
Field field,
SerdStatementFlags flags )
static

◆ write_pred()

void write_pred ( SerdWriter * writer,
SerdStatementFlags flags,
const SerdNode * pred )
static

◆ write_sep()

void write_sep ( SerdWriter * writer,
const Sep sep )
static

◆ write_text()

size_t write_text ( SerdWriter * writer,
TextContext ctx,
const uint8_t * utf8,
size_t n_bytes )
static

◆ write_uri()

size_t write_uri ( SerdWriter * writer,
const uint8_t * utf8,
size_t n_bytes )
static

Variable Documentation

◆ rules

const SepRule rules[]
static
Initial value:
= {
{ NULL, 0, 0, 0, 0 },
{ " .\n\n", 4, 0, 0, 0 },
{ " ;", 2, 0, 1, 1 },
{ " ,", 2, 0, 1, 0 },
{ NULL, 0, 0, 1, 0 },
{ " ", 1, 0, 0, 0 },
{ "[", 1, 0, 1, 1 },
{ "]", 1, 1, 0, 0 },
{ "(", 1, 0, 0, 0 },
{ NULL, 1, 0, 1, 0 },
{ ")", 1, 1, 0, 0 },
{ "\n", 1, 0, 1, 0 }
}
#define NULL
Definition CarlaBridgeFormat.cpp:30

◆ WRITE_CONTEXT_NULL

const WriteContext WRITE_CONTEXT_NULL
static
Initial value:
= {
{ 0, 0, 0, 0, SERD_NOTHING },
{ 0, 0, 0, 0, SERD_NOTHING },
{ 0, 0, 0, 0, SERD_NOTHING }
}
@ SERD_NOTHING
Definition serd.h:152