diff options
author | David Robillard <d@drobilla.net> | 2018-12-29 20:05:00 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-07 15:32:23 -0500 |
commit | 88402a1cddba79e339fc92037be2449c429c0780 (patch) | |
tree | 0764b3080cbf216ae5993ac77718ea10f3803f0f /src | |
parent | f4b1ec91cff0a543a8f7e553ab2113a1c31e0d86 (diff) | |
download | serd-88402a1cddba79e339fc92037be2449c429c0780.tar.gz serd-88402a1cddba79e339fc92037be2449c429c0780.tar.bz2 serd-88402a1cddba79e339fc92037be2449c429c0780.zip |
Rename SerdStyle to SerdWriterFlags
Diffstat (limited to 'src')
-rw-r--r-- | src/serdi.c | 22 | ||||
-rw-r--r-- | src/writer.c | 48 |
2 files changed, 35 insertions, 35 deletions
diff --git a/src/serdi.c b/src/serdi.c index c6ca4fc3..68b1a497 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -149,34 +149,34 @@ serd_fopen(const char* path, const char* mode) return fd; } -static SerdStyle +static SerdWriterFlags choose_style(const SerdSyntax input_syntax, const SerdSyntax output_syntax, const bool ascii, const bool bulk_write, const bool full_uris) { - unsigned output_style = 0u; + SerdWriterFlags writer_flags = 0u; if (output_syntax == SERD_NTRIPLES || ascii) { - output_style |= SERD_STYLE_ASCII; + writer_flags |= SERD_WRITE_ASCII; } else if (output_syntax == SERD_TURTLE) { - output_style |= SERD_STYLE_ABBREVIATED; + writer_flags |= SERD_WRITE_ABBREVIATED; if (!full_uris) { - output_style |= SERD_STYLE_CURIED; + writer_flags |= SERD_WRITE_CURIED; } } if ((input_syntax == SERD_TURTLE || input_syntax == SERD_TRIG) || - (output_style & SERD_STYLE_CURIED)) { + (writer_flags & SERD_WRITE_CURIED)) { // Base URI may change and/or we're abbreviating URIs, so must resolve - output_style |= SERD_STYLE_RESOLVED; + writer_flags |= SERD_WRITE_RESOLVED; } if (bulk_write) { - output_style |= SERD_STYLE_BULK; + writer_flags |= SERD_WRITE_BULK; } - return (SerdStyle)output_style; + return writer_flags; } int @@ -305,7 +305,7 @@ main(int argc, char** argv) : SERD_NQUADS); } - const SerdStyle output_style = + const SerdWriterFlags writer_flags = choose_style(input_syntax, output_syntax, ascii, bulk_write, full_uris); SerdURIView base_uri = SERD_URI_NULL; @@ -320,7 +320,7 @@ main(int argc, char** argv) SerdEnv* const env = serd_env_new(&base); SerdWriter* const writer = serd_writer_new( - output_syntax, output_style, env, &base_uri, serd_file_sink, out_fd); + output_syntax, writer_flags, env, &base_uri, serd_file_sink, out_fd); SerdReader* const reader = serd_reader_new(input_syntax, diff --git a/src/writer.c b/src/writer.c index c365f23c..24c56895 100644 --- a/src/writer.c +++ b/src/writer.c @@ -92,24 +92,24 @@ static const SepRule rules[] = {{NULL, 0, 0, 0, 0}, {"\n", 1, 0, 1, 0}}; struct SerdWriterImpl { - SerdSyntax syntax; - SerdStyle style; - SerdEnv* env; - SerdNode root_node; - SerdURIView root_uri; - SerdURIView base_uri; - SerdStack anon_stack; - SerdByteSink byte_sink; - SerdErrorSink error_sink; - void* error_handle; - WriteContext context; - SerdNode list_subj; - unsigned list_depth; - unsigned indent; - char* bprefix; - size_t bprefix_len; - Sep last_sep; - bool empty; + SerdSyntax syntax; + SerdWriterFlags flags; + SerdEnv* env; + SerdNode root_node; + SerdURIView root_uri; + SerdURIView base_uri; + SerdStack anon_stack; + SerdByteSink byte_sink; + SerdErrorSink error_sink; + void* error_handle; + WriteContext context; + SerdNode list_subj; + unsigned list_depth; + unsigned indent; + char* bprefix; + size_t bprefix_len; + Sep last_sep; + bool empty; }; typedef enum { WRITE_STRING, WRITE_LONG_STRING } TextContext; @@ -196,7 +196,7 @@ write_character(SerdWriter* writer, const uint8_t* utf8, size_t* size) break; } - if (!(writer->style & SERD_STYLE_ASCII)) { + if (!(writer->flags & SERD_WRITE_ASCII)) { // Write UTF-8 character directly to UTF-8 output return sink(utf8, *size, writer); } @@ -579,7 +579,7 @@ write_uri_node(SerdWriter* const writer, return sink("a", 1, writer) == 1; } - if (has_scheme && (writer->style & SERD_STYLE_CURIED) && + if (has_scheme && (writer->flags & SERD_WRITE_CURIED) && serd_env_qualify(writer->env, node, &prefix, &suffix) && is_name(suffix.buf, suffix.len)) { write_uri(writer, prefix.buf, prefix.n_bytes); @@ -599,7 +599,7 @@ write_uri_node(SerdWriter* const writer, } write_sep(writer, SEP_URI_BEGIN); - if (writer->style & SERD_STYLE_RESOLVED) { + if (writer->flags & SERD_WRITE_RESOLVED) { SerdURIView in_base_uri; SerdURIView uri; SerdURIView abs_uri; @@ -953,7 +953,7 @@ serd_writer_finish(SerdWriter* writer) SerdWriter* serd_writer_new(SerdSyntax syntax, - SerdStyle style, + SerdWriterFlags flags, SerdEnv* env, const SerdURIView* base_uri, SerdSink ssink, @@ -963,7 +963,7 @@ serd_writer_new(SerdSyntax syntax, SerdWriter* writer = (SerdWriter*)calloc(1, sizeof(SerdWriter)); writer->syntax = syntax; - writer->style = style; + writer->flags = flags; writer->env = env; writer->root_node = SERD_NODE_NULL; writer->root_uri = SERD_URI_NULL; @@ -973,7 +973,7 @@ serd_writer_new(SerdSyntax syntax, writer->list_subj = SERD_NODE_NULL; writer->empty = true; writer->byte_sink = serd_byte_sink_new( - ssink, stream, (style & SERD_STYLE_BULK) ? SERD_PAGE_SIZE : 1); + ssink, stream, (flags & SERD_WRITE_BULK) ? SERD_PAGE_SIZE : 1); return writer; } |