Esempio n. 1
0
SERD_API
SerdWriter*
serd_writer_new(SerdSyntax     syntax,
                SerdStyle      style,
                SerdEnv*       env,
                const SerdURI* base_uri,
                SerdSink       ssink,
                void*          stream)
{
	const WriteContext context = WRITE_CONTEXT_NULL;
	SerdWriter*        writer  = (SerdWriter*)malloc(sizeof(SerdWriter));
	writer->syntax       = syntax;
	writer->style        = style;
	writer->env          = env;
	writer->root_node    = SERD_NODE_NULL;
	writer->root_uri     = SERD_URI_NULL;
	writer->base_uri     = base_uri ? *base_uri : SERD_URI_NULL;
	writer->anon_stack   = serd_stack_new(sizeof(WriteContext));
	writer->sink         = ssink;
	writer->stream       = stream;
	writer->error_sink   = NULL;
	writer->error_handle = NULL;
	writer->context      = context;
	writer->list_subj    = SERD_NODE_NULL;
	writer->list_depth   = 0;
	writer->bprefix      = NULL;
	writer->bprefix_len  = 0;
	writer->indent       = 0;
	writer->last_sep     = SEP_NONE;
	writer->empty        = true;
	if (style & SERD_STYLE_BULK) {
		writer->bulk_sink = serd_bulk_sink_new(ssink, stream, SERD_PAGE_SIZE);
	}
	return writer;
}
Esempio n. 2
0
SERD_API
SerdWriter*
serd_writer_new(SerdSyntax     syntax,
                SerdStyle      style,
                SerdEnv*       env,
                const SerdURI* base_uri,
                SerdSink       sink,
                void*          stream)
{
	const WriteContext context = WRITE_CONTEXT_NULL;
	SerdWriter*        writer  = malloc(sizeof(struct SerdWriterImpl));
	writer->syntax      = syntax;
	writer->style       = style;
	writer->env         = env;
	writer->base_uri    = base_uri ? *base_uri : SERD_URI_NULL;
	writer->anon_stack  = serd_stack_new(sizeof(WriteContext));
	writer->sink        = sink;
	writer->stream      = stream;
	writer->context     = context;
	writer->bprefix     = NULL;
	writer->bprefix_len = 0;
	writer->indent      = 0;
	writer->empty       = true;
	return writer;
}
Esempio n. 3
0
SERD_API
SerdReader*
serd_reader_new(SerdSyntax        syntax,
                void*             handle,
                void              (*free_handle)(void*),
                SerdBaseSink      base_sink,
                SerdPrefixSink    prefix_sink,
                SerdStatementSink statement_sink,
                SerdEndSink       end_sink)
{
	const Cursor cur = { NULL, 0, 0 };
	SerdReader*  me  = (SerdReader*)malloc(sizeof(struct SerdReaderImpl));
	me->handle           = handle;
	me->free_handle      = free_handle;
	me->base_sink        = base_sink;
	me->prefix_sink      = prefix_sink;
	me->statement_sink   = statement_sink;
	me->end_sink         = end_sink;
	me->error_sink       = NULL;
	me->error_handle     = NULL;
	me->default_graph    = SERD_NODE_NULL;
	me->fd               = 0;
	me->stack            = serd_stack_new(SERD_PAGE_SIZE);
	me->syntax           = syntax;
	me->cur              = cur;
	me->bprefix          = NULL;
	me->bprefix_len      = 0;
	me->next_id          = 1;
	me->read_buf         = 0;
	me->file_buf         = 0;
	me->read_head        = 0;
	me->strict           = false;
	me->eof              = false;
	me->seen_genid       = false;
#ifdef SERD_STACK_CHECK
	me->allocs           = 0;
	me->n_allocs         = 0;
#endif

	me->rdf_first = push_node(me, SERD_URI, NS_RDF "first", 48);
	me->rdf_rest  = push_node(me, SERD_URI, NS_RDF "rest", 47);
	me->rdf_nil   = push_node(me, SERD_URI, NS_RDF "nil", 46);

	return me;
}