aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/serdi.c24
-rw-r--r--src/writer.c52
2 files changed, 38 insertions, 38 deletions
diff --git a/src/serdi.c b/src/serdi.c
index 0ec6366f..0a7cfc56 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -138,7 +138,7 @@ serd_fopen(const char* const path, const char* const mode)
return fd;
}
-static SerdStyle
+static SerdWriterFlags
choose_style(const SerdSyntax input_syntax,
const SerdSyntax output_syntax,
const bool ascii,
@@ -146,31 +146,31 @@ choose_style(const SerdSyntax input_syntax,
const bool full_uris,
const bool lax)
{
- 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;
}
if (!lax) {
- output_style |= SERD_STYLE_STRICT;
+ writer_flags |= SERD_WRITE_STRICT;
}
- return (SerdStyle)output_style;
+ return writer_flags;
}
int
@@ -313,7 +313,7 @@ main(int argc, char** argv)
: SERD_NQUADS);
}
- const SerdStyle output_style = choose_style(
+ const SerdWriterFlags writer_flags = choose_style(
input_syntax, output_syntax, ascii, bulk_write, full_uris, lax);
SerdURIView base_uri = SERD_URI_NULL;
@@ -328,7 +328,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 19f5d269..e8225a41 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -114,21 +114,21 @@ static const SepRule rules[] = {
#undef SEP_EACH
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;
- char* bprefix;
- size_t bprefix_len;
- Sep last_sep;
- int indent;
+ 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;
+ char* bprefix;
+ size_t bprefix_len;
+ Sep last_sep;
+ int indent;
};
typedef enum { WRITE_STRING, WRITE_LONG_STRING } TextContext;
@@ -271,7 +271,7 @@ write_character(SerdWriter* writer,
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);
}
@@ -333,7 +333,7 @@ write_uri(SerdWriter* writer, const char* utf8, size_t n_bytes, SerdStatus* st)
size_t size = 0;
len += write_character(writer, (const uint8_t*)utf8 + i, &size, st);
i += size;
- if (*st && (writer->style & SERD_STYLE_STRICT)) {
+ if (*st && (writer->flags & SERD_WRITE_STRICT)) {
break;
}
@@ -356,7 +356,7 @@ ewrite_uri(SerdWriter* writer, const char* utf8, size_t n_bytes)
SerdStatus st = SERD_SUCCESS;
write_uri(writer, utf8, n_bytes, &st);
- return (st == SERD_ERR_BAD_WRITE || (writer->style & SERD_STYLE_STRICT))
+ return (st == SERD_ERR_BAD_WRITE || (writer->flags & SERD_WRITE_STRICT))
? st
: SERD_SUCCESS;
}
@@ -522,7 +522,7 @@ write_text(SerdWriter* writer,
// Write UTF-8 character
size_t size = 0;
write_character(writer, (const uint8_t*)utf8 + i - 1, &size, &st);
- if (st && (writer->style & SERD_STYLE_STRICT)) {
+ if (st && (writer->flags & SERD_WRITE_STRICT)) {
return st;
}
@@ -536,7 +536,7 @@ write_text(SerdWriter* writer,
}
}
- return (writer->style & SERD_STYLE_STRICT) ? st : SERD_SUCCESS;
+ return (writer->flags & SERD_WRITE_STRICT) ? st : SERD_SUCCESS;
}
typedef struct {
@@ -731,7 +731,7 @@ write_uri_node(SerdWriter* const writer,
return esink("()", 2, writer);
}
- 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(prefix.buf, prefix.n_bytes) &&
is_name(suffix.buf, suffix.len)) {
@@ -751,7 +751,7 @@ write_uri_node(SerdWriter* const writer,
TRY(st, esink("<", 1, writer));
- if (writer->style & SERD_STYLE_RESOLVED) {
+ if (writer->flags & SERD_WRITE_RESOLVED) {
SerdURIView in_base_uri;
SerdURIView uri;
SerdURIView abs_uri;
@@ -784,7 +784,7 @@ write_curie(SerdWriter* const writer, const SerdNode* const node)
// In fast-and-loose Turtle/TriG mode CURIEs are simply passed through
const bool fast =
- !(writer->style & (SERD_STYLE_CURIED | SERD_STYLE_RESOLVED));
+ !(writer->flags & (SERD_WRITE_CURIED | SERD_WRITE_RESOLVED));
if (!supports_abbrev(writer) || !fast) {
if ((st = serd_env_expand(writer->env, node, &prefix, &suffix))) {
@@ -1119,7 +1119,7 @@ serd_writer_finish(SerdWriter* writer)
SerdWriter*
serd_writer_new(SerdSyntax syntax,
- SerdStyle style,
+ SerdWriterFlags flags,
SerdEnv* env,
const SerdURIView* base_uri,
SerdSink ssink,
@@ -1129,7 +1129,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;
@@ -1137,7 +1137,7 @@ serd_writer_new(SerdSyntax syntax,
writer->anon_stack = serd_stack_new(SERD_PAGE_SIZE);
writer->context = context;
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;
}