aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-03-10 16:32:02 +0100
committerDavid Robillard <d@drobilla.net>2021-03-08 23:23:05 -0500
commit673341c991a1f58c0ea08fa2f35327a58f7934f5 (patch)
treec80206a6d1d0eee12f262bb83ea36ede3a5bee13 /src/writer.c
parent6f6dc590561d1d73a15eb9501e0d22e28f26508b (diff)
downloadserd-673341c991a1f58c0ea08fa2f35327a58f7934f5.tar.gz
serd-673341c991a1f58c0ea08fa2f35327a58f7934f5.tar.bz2
serd-673341c991a1f58c0ea08fa2f35327a58f7934f5.zip
Add initial flags to write context
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/writer.c b/src/writer.c
index 17f1dc22..2dbb52bc 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -39,18 +39,16 @@ typedef enum {
} ContextType;
typedef struct {
- ContextType type;
- SerdNode* graph;
- SerdNode* subject;
- SerdNode* predicate;
- bool indented_object;
+ ContextType type;
+ SerdStatementFlags flags;
+ SerdNode* graph;
+ SerdNode* subject;
+ SerdNode* predicate;
+ bool indented_object;
} WriteContext;
-static const WriteContext WRITE_CONTEXT_NULL = {CTX_NAMED,
- NULL,
- NULL,
- NULL,
- false};
+static const WriteContext WRITE_CONTEXT_NULL =
+ {CTX_NAMED, 0, NULL, NULL, NULL, false};
typedef enum {
SEP_NONE, ///< Placeholder for nodes or nothing
@@ -158,11 +156,12 @@ free_context(SerdWriter* writer)
}
static SerdStatus
-push_context(SerdWriter* const writer,
- const ContextType type,
- const SerdNode* const g,
- const SerdNode* const s,
- const SerdNode* const p)
+push_context(SerdWriter* const writer,
+ const ContextType type,
+ const SerdStatementFlags flags,
+ const SerdNode* const g,
+ const SerdNode* const s,
+ const SerdNode* const p)
{
WriteContext* top =
(WriteContext*)serd_stack_push(&writer->anon_stack, sizeof(WriteContext));
@@ -173,8 +172,12 @@ push_context(SerdWriter* const writer,
*top = writer->context;
- const WriteContext new_context = {
- type, serd_node_copy(g), serd_node_copy(s), serd_node_copy(p), false};
+ const WriteContext new_context = {type,
+ flags,
+ serd_node_copy(g),
+ serd_node_copy(s),
+ serd_node_copy(p),
+ false};
writer->context = new_context;
return SERD_SUCCESS;
@@ -980,18 +983,18 @@ serd_writer_write_statement(SerdWriter* writer,
// Push context for list or anonymous subject if necessary
if (!st) {
if (flags & SERD_ANON_S) {
- st = push_context(writer, CTX_BLANK, graph, subject, predicate);
+ st = push_context(writer, CTX_BLANK, flags, graph, subject, predicate);
} else if (flags & SERD_LIST_S) {
- st = push_context(writer, CTX_LIST, graph, subject, NULL);
+ st = push_context(writer, CTX_LIST, flags, graph, subject, NULL);
}
}
// Push context for list or anonymous object if necessary
if (!st) {
if (flags & SERD_ANON_O) {
- st = push_context(writer, CTX_BLANK, graph, object, NULL);
+ st = push_context(writer, CTX_BLANK, flags, graph, object, NULL);
} else if (flags & SERD_LIST_O) {
- st = push_context(writer, CTX_LIST, graph, object, NULL);
+ st = push_context(writer, CTX_LIST, flags, graph, object, NULL);
}
}