diff options
author | David Robillard <d@drobilla.net> | 2020-08-12 20:49:54 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-10-27 13:13:59 +0100 |
commit | aafc82f0bee3b222d395ef959aa4a6917f2ef0b2 (patch) | |
tree | 4c16ea92f95676bc30053553235b34f857f37702 /src/node.c | |
parent | 722d2e1353641c9be3adee51b20bd99a76201742 (diff) | |
download | serd-aafc82f0bee3b222d395ef959aa4a6917f2ef0b2.tar.gz serd-aafc82f0bee3b222d395ef959aa4a6917f2ef0b2.tar.bz2 serd-aafc82f0bee3b222d395ef959aa4a6917f2ef0b2.zip |
Make it possible to allocate nodes with CURIE datatypes
Diffstat (limited to 'src/node.c')
-rw-r--r-- | src/node.c | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -233,6 +233,7 @@ SerdNode* serd_new_typed_literal_expanded(const char* str, const size_t str_len, const SerdNodeFlags flags, + const SerdNodeType datatype_type, const SerdStringView datatype_prefix, const SerdStringView datatype_suffix) { @@ -250,7 +251,7 @@ serd_new_typed_literal_expanded(const char* str, char* const datatype_buf = serd_node_buffer(datatype_node); datatype_node->n_bytes = datatype_uri_len; - datatype_node->type = SERD_URI; + datatype_node->type = datatype_type; memcpy(datatype_buf, datatype_prefix.buf, datatype_prefix.len); memcpy(datatype_buf + datatype_prefix.len, datatype_suffix.buf, @@ -297,18 +298,19 @@ static SerdNode* serd_new_typed_literal_i(const char* str, const size_t str_len, SerdNodeFlags flags, - const char* datatype_uri, - const size_t datatype_uri_len) + SerdNodeType datatype_type, + const char* datatype, + const size_t datatype_len) { assert(str); - assert(datatype_uri); - assert(strcmp(datatype_uri, NS_RDF "langString")); + assert(datatype); + assert(strcmp(datatype, NS_RDF "langString")); - const SerdStringView datatype_prefix = {datatype_uri, datatype_uri_len}; + const SerdStringView datatype_prefix = {datatype, datatype_len}; const SerdStringView datatype_suffix = {"", 0}; return serd_new_typed_literal_expanded( - str, str_len, flags, datatype_prefix, datatype_suffix); + str, str_len, flags, datatype_type, datatype_prefix, datatype_suffix); } SerdNode* @@ -331,7 +333,7 @@ serd_new_literal(const char* str, return serd_new_plain_literal_i(str, str_len, flags, lang, lang_len); } else if (datatype_uri) { return serd_new_typed_literal_i( - str, str_len, flags, datatype_uri, datatype_uri_len); + str, str_len, flags, SERD_URI, datatype_uri, datatype_uri_len); } else { return serd_new_substring(str, str_len); } @@ -361,7 +363,8 @@ serd_new_typed_literal(const char* str, const SerdNode* datatype) } else if (!datatype) { return serd_new_string(str); } else if (!strcmp(serd_node_buffer_c(datatype), NS_RDF "langString") || - serd_node_type(datatype) != SERD_URI) { + (serd_node_type(datatype) != SERD_URI && + serd_node_type(datatype) != SERD_CURIE)) { return NULL; } @@ -371,6 +374,7 @@ serd_new_typed_literal(const char* str, const SerdNode* datatype) return serd_new_typed_literal_i(str, str_len, flags, + serd_node_type(datatype), serd_node_string(datatype), serd_node_length(datatype)); } |