aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-03-10 16:32:02 +0100
committerDavid Robillard <d@drobilla.net>2022-01-13 23:04:08 -0500
commit7d62993d8402ad4438c422af3369b9e8c778a0a5 (patch)
treec22afafea2db939ee447d327e810f439cc9b8930
parent4bcc80ffab1d219efd224c42769a25284612f3df (diff)
downloadserd-7d62993d8402ad4438c422af3369b9e8c778a0a5.tar.gz
serd-7d62993d8402ad4438c422af3369b9e8c778a0a5.tar.bz2
serd-7d62993d8402ad4438c422af3369b9e8c778a0a5.zip
Add initial flags to write context
-rw-r--r--src/writer.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/writer.c b/src/writer.c
index a3d9d8e8..83363773 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
@@ -154,11 +152,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));
@@ -169,8 +168,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;
@@ -952,18 +955,18 @@ serd_writer_write_statement(SerdWriter* const 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);
}
}