aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c62
1 files changed, 27 insertions, 35 deletions
diff --git a/src/writer.c b/src/writer.c
index c520638e..f55b47d4 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -129,7 +129,7 @@ struct SerdWriterImpl {
SerdSink iface;
SerdSyntax syntax;
SerdWriterFlags flags;
- SerdEnv* env;
+ const SerdEnv* env;
SerdNode* root_node;
SerdURIView root_uri;
WriteContext* anon_stack;
@@ -1184,7 +1184,7 @@ SerdWriter*
serd_writer_new(SerdWorld* world,
SerdSyntax syntax,
SerdWriterFlags flags,
- SerdEnv* env,
+ const SerdEnv* env,
SerdByteSink* byte_sink)
{
const WriteContext context = WRITE_CONTEXT_NULL;
@@ -1230,22 +1230,18 @@ serd_writer_set_base_uri(SerdWriter* writer, const SerdNode* uri)
return SERD_ERR_BAD_ARG;
}
- SerdStatus st =
- serd_env_set_base_uri(writer->env, serd_node_string_view(uri));
-
- if (!st) {
- if (writer->syntax == SERD_TURTLE || writer->syntax == SERD_TRIG) {
- if (ctx(writer, SERD_GRAPH) || ctx(writer, SERD_SUBJECT)) {
- TRY(st, esink(" .\n\n", 4, writer));
- reset_context(writer, true);
- }
- TRY(st, esink("@base <", 7, writer));
- TRY(st, esink(serd_node_string(uri), uri->n_bytes, writer));
- TRY(st, esink("> .\n", 4, writer));
+ SerdStatus st = SERD_SUCCESS;
+ if (writer->syntax == SERD_TURTLE || writer->syntax == SERD_TRIG) {
+ if (ctx(writer, SERD_GRAPH) || ctx(writer, SERD_SUBJECT)) {
+ TRY(st, esink(" .\n\n", 4, writer));
+ reset_context(writer, true);
}
- writer->indent = 0;
- reset_context(writer, true);
+ TRY(st, esink("@base <", 7, writer));
+ TRY(st, esink(serd_node_string(uri), uri->n_bytes, writer));
+ TRY(st, esink("> .\n", 4, writer));
}
+ writer->indent = 0;
+ reset_context(writer, true);
return st;
}
@@ -1273,27 +1269,23 @@ serd_writer_set_prefix(SerdWriter* writer,
return SERD_ERR_BAD_ARG;
}
- SerdStatus st = serd_env_set_prefix(
- writer->env, serd_node_string_view(name), serd_node_string_view(uri));
-
- if (!st) {
- if (writer->syntax == SERD_TURTLE || writer->syntax == SERD_TRIG) {
- if (ctx(writer, SERD_GRAPH) || ctx(writer, SERD_SUBJECT)) {
- TRY(st, esink(" .\n\n", 4, writer));
- reset_context(writer, true);
- }
-
- TRY(st, esink("@prefix ", 8, writer));
- TRY(st, esink(serd_node_string(name), name->n_bytes, writer));
- TRY(st, esink(": <", 3, writer));
- TRY(st, write_uri_from_node(writer, uri));
- TRY(st, esink("> .\n", 4, writer));
+ SerdStatus st = SERD_SUCCESS;
+ if (writer->syntax == SERD_TURTLE || writer->syntax == SERD_TRIG) {
+ if (ctx(writer, SERD_GRAPH) || ctx(writer, SERD_SUBJECT)) {
+ TRY(st, esink(" .\n\n", 4, writer));
+ reset_context(writer, true);
}
- writer->indent = 0;
- reset_context(writer, true);
+ TRY(st, esink("@prefix ", 8, writer));
+ TRY(st, esink(serd_node_string(name), name->n_bytes, writer));
+ TRY(st, esink(": <", 3, writer));
+ TRY(st, write_uri_from_node(writer, uri));
+ TRY(st, esink("> .\n", 4, writer));
}
+ writer->indent = 0;
+ reset_context(writer, true);
+
return st;
}
@@ -1317,8 +1309,8 @@ serd_writer_sink(SerdWriter* writer)
return &writer->iface;
}
-SerdEnv*
-serd_writer_env(SerdWriter* writer)
+const SerdEnv*
+serd_writer_env(const SerdWriter* writer)
{
return writer->env;
}