diff options
author | David Robillard <d@drobilla.net> | 2021-07-11 18:44:03 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:08 -0500 |
commit | 3a4bd5f1b31cb5c1522d9e6c7222414342682467 (patch) | |
tree | f4d7f87260cdcdd39ad4051c113cadf149c4fa43 /src/writer.c | |
parent | 8c67f9eba47d30913749e607c440b170a5cbd804 (diff) | |
download | serd-3a4bd5f1b31cb5c1522d9e6c7222414342682467.tar.gz serd-3a4bd5f1b31cb5c1522d9e6c7222414342682467.tar.bz2 serd-3a4bd5f1b31cb5c1522d9e6c7222414342682467.zip |
[WIP] Remove SERD_CURIE node datatype entirely
Diffstat (limited to 'src/writer.c')
-rw-r--r-- | src/writer.c | 55 |
1 files changed, 10 insertions, 45 deletions
diff --git a/src/writer.c b/src/writer.c index 05be0500..31daa71c 100644 --- a/src/writer.c +++ b/src/writer.c @@ -840,24 +840,23 @@ write_uri_node(SerdWriter* const writer, const SerdNode* const node, const SerdField field) { - SerdStatus st = SERD_SUCCESS; - const char* const node_str = serd_node_string(node); - const bool has_scheme = serd_uri_string_has_scheme(node_str); + SerdStatus st = SERD_SUCCESS; + const SerdStringView string = serd_node_string_view(node); + const bool has_scheme = serd_uri_string_has_scheme(string.data); if (supports_abbrev(writer)) { - const SerdNode* prefix_node = NULL; - SerdStringView suffix = {NULL, 0}; - if (field == SERD_PREDICATE && !strcmp(node_str, NS_RDF "type")) { + if (field == SERD_PREDICATE && !strcmp(string.data, NS_RDF "type")) { return esink("a", 1, writer); } - if (!strcmp(node_str, NS_RDF "nil")) { + if (!strcmp(string.data, NS_RDF "nil")) { return esink("()", 2, writer); } + SerdStringView prefix = {NULL, 0}; + SerdStringView suffix = {NULL, 0}; if (has_scheme && !(writer->flags & SERD_WRITE_UNQUALIFIED) && - serd_env_qualify_in_place(writer->env, node, &prefix_node, &suffix)) { - const SerdStringView prefix = serd_node_string_view(prefix_node); + !serd_env_qualify(writer->env, string, &prefix, &suffix)) { TRY(st, write_lname(writer, prefix.data, prefix.length)); TRY(st, esink(":", 1, writer)); return write_lname(writer, suffix.data, suffix.length); @@ -868,45 +867,14 @@ write_uri_node(SerdWriter* const writer, !serd_env_base_uri(writer->env)) { return w_err(writer, SERD_BAD_ARG, - "URI reference <%s> in unsupported syntax", - node_str); + "syntax does not support URI reference <%s>", + string.data); } return write_full_uri_node(writer, node); } SERD_NODISCARD static SerdStatus -write_curie(SerdWriter* const writer, const SerdNode* const node) -{ - const char* const node_str = serd_node_string(node); - SerdStringView prefix = {NULL, 0}; - SerdStringView suffix = {NULL, 0}; - SerdStatus st = SERD_SUCCESS; - - // In fast-and-loose Turtle/TriG mode CURIEs are simply passed through - const bool fast = - (writer->flags & (SERD_WRITE_UNQUALIFIED | SERD_WRITE_UNRESOLVED)); - - if (!supports_abbrev(writer) || !fast) { - const SerdStringView curie = serd_node_string_view(node); - if ((st = serd_env_expand_in_place(writer->env, curie, &prefix, &suffix))) { - return w_err(writer, st, "undefined namespace prefix '%s'", node_str); - } - } - - if (!supports_abbrev(writer)) { - TRY(st, esink("<", 1, writer)); - TRY(st, ewrite_uri(writer, prefix.data, prefix.length)); - TRY(st, ewrite_uri(writer, suffix.data, suffix.length)); - TRY(st, esink(">", 1, writer)); - } else { - TRY(st, write_lname(writer, node_str, node->length)); - } - - return st; -} - -SERD_NODISCARD static SerdStatus write_blank(SerdWriter* const writer, const SerdNode* node, const SerdField field, @@ -974,9 +942,6 @@ write_node(SerdWriter* const writer, case SERD_URI: st = write_uri_node(writer, node, field); break; - case SERD_CURIE: - st = write_curie(writer, node); - break; case SERD_BLANK: st = write_blank(writer, node, field, flags); break; |