diff options
author | David Robillard <d@drobilla.net> | 2018-07-05 21:01:12 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-08 23:23:05 -0500 |
commit | a79d62b9f8c0a75efe56d135a0f08b898969338d (patch) | |
tree | af6dcd93705db49e613f6d3cde2e0d386f9b0add /src | |
parent | e0fc63762de7fd92d6b35c20185e14117839a90f (diff) | |
download | serd-a79d62b9f8c0a75efe56d135a0f08b898969338d.tar.gz serd-a79d62b9f8c0a75efe56d135a0f08b898969338d.tar.bz2 serd-a79d62b9f8c0a75efe56d135a0f08b898969338d.zip |
Simplify writer style options
Diffstat (limited to 'src')
-rw-r--r-- | src/serdi.c | 34 | ||||
-rw-r--r-- | src/writer.c | 5 |
2 files changed, 6 insertions, 33 deletions
diff --git a/src/serdi.c b/src/serdi.c index eec58bd5..27ffbe71 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -87,36 +87,6 @@ quiet_error_func(void* const handle, const SerdError* const e) return SERD_SUCCESS; } -static SerdWriterFlags -choose_style(const SerdSyntax input_syntax, - const SerdSyntax output_syntax, - const bool ascii, - const bool bulk_write, - const bool full_uris) -{ - SerdWriterFlags writer_flags = 0u; - if (output_syntax == SERD_NTRIPLES || ascii) { - writer_flags |= SERD_WRITE_ASCII; - } else if (output_syntax == SERD_TURTLE) { - writer_flags |= SERD_WRITE_ABBREVIATED; - if (!full_uris) { - writer_flags |= SERD_WRITE_CURIED; - } - } - - if ((input_syntax == SERD_TURTLE || input_syntax == SERD_TRIG) || - (writer_flags & SERD_WRITE_CURIED)) { - // Base URI may change and/or we're abbreviating URIs, so must resolve - writer_flags |= SERD_WRITE_RESOLVED; - } - - if (bulk_write) { - writer_flags |= SERD_WRITE_BULK; - } - - return writer_flags; -} - int main(int argc, char** argv) { @@ -238,7 +208,9 @@ main(int argc, char** argv) } const SerdWriterFlags writer_flags = - choose_style(input_syntax, output_syntax, ascii, bulk_write, full_uris); + ((ascii ? SERD_WRITE_ASCII : 0) | // + (bulk_write ? SERD_WRITE_BULK : 0) | // + (full_uris ? (SERD_WRITE_UNQUALIFIED | SERD_WRITE_UNRESOLVED) : 0)); SerdNode* base = NULL; if (a < argc) { // Base URI given on command line diff --git a/src/writer.c b/src/writer.c index 663d8f64..455c720c 100644 --- a/src/writer.c +++ b/src/writer.c @@ -581,7 +581,7 @@ write_uri_node(SerdWriter* const writer, return sink("()", 2, writer) == 2; } - if (has_scheme && (writer->flags & SERD_WRITE_CURIED) && + if (has_scheme && !(writer->flags & SERD_WRITE_UNQUALIFIED) && serd_env_qualify_in_place(writer->env, node, &prefix, &suffix) && is_name(serd_node_string(prefix), serd_node_length(prefix)) && is_name(suffix.buf, suffix.len)) { @@ -602,7 +602,8 @@ write_uri_node(SerdWriter* const writer, } write_sep(writer, SEP_URI_BEGIN); - if ((writer->flags & SERD_WRITE_RESOLVED) && serd_env_base_uri(writer->env)) { + if (!(writer->flags & SERD_WRITE_UNRESOLVED) && + serd_env_base_uri(writer->env)) { const SerdURIView base_uri = serd_env_base_uri_view(writer->env); SerdURIView uri = serd_parse_uri(node_str); SerdURIView abs_uri = serd_resolve_uri(uri, base_uri); |