diff options
author | David Robillard <d@drobilla.net> | 2022-01-02 22:52:39 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-01-28 21:57:29 -0500 |
commit | 6e274953587941934e8f291d2dd99b843d5580ab (patch) | |
tree | a5bd7e131ae4cfabaa7ec92d75dd3007b8380239 /src | |
parent | 30487c277ac5d4be5786733ca7b98adb4c810ae9 (diff) | |
download | serd-6e274953587941934e8f291d2dd99b843d5580ab.tar.gz serd-6e274953587941934e8f291d2dd99b843d5580ab.tar.bz2 serd-6e274953587941934e8f291d2dd99b843d5580ab.zip |
Remove datatype arguments from integer and base64 constructors
Diffstat (limited to 'src')
-rw-r--r-- | src/node.c | 53 | ||||
-rw-r--r-- | src/nodes.c | 21 |
2 files changed, 27 insertions, 47 deletions
@@ -350,45 +350,37 @@ serd_node_construct_float(const size_t buf_size, } SerdWriteResult -serd_node_construct_integer(const size_t buf_size, - void* const buf, - const int64_t value, - const SerdStringView datatype) +serd_node_construct_integer(const size_t buf_size, + void* const buf, + const int64_t value) { - if (datatype.len && !serd_uri_string_has_scheme(datatype.buf)) { - return result(SERD_BAD_ARG, 0); - } - char temp[24] = {0}; const ExessResult r = exess_write_long(value, sizeof(temp), temp); MUST_SUCCEED(r.status); // The only error is buffer overrun - return serd_node_construct_literal( - buf_size, - buf, - SERD_SUBSTRING(temp, r.count), - SERD_HAS_DATATYPE, - datatype.len ? datatype : SERD_STRING(NS_XSD "integer")); + return serd_node_construct_literal(buf_size, + buf, + SERD_SUBSTRING(temp, r.count), + SERD_HAS_DATATYPE, + SERD_STRING(NS_XSD "integer")); } SerdWriteResult -serd_node_construct_base64(const size_t buf_size, - void* const buf, - const size_t value_size, - const void* const value, - const SerdStringView datatype) +serd_node_construct_base64(const size_t buf_size, + void* const buf, + const size_t value_size, + const void* const value) { static const SerdStringView xsd_base64Binary = SERD_STRING(NS_XSD "base64Binary"); // Verify argument sanity - if (!value || !value_size || - (datatype.len && !serd_uri_string_has_scheme(datatype.buf))) { + if (!value || !value_size) { return result(SERD_BAD_ARG, 0); } // Determine the type to use (default to xsd:base64Binary) - const SerdStringView type = datatype.len ? datatype : xsd_base64Binary; + const SerdStringView type = xsd_base64Binary; const size_t type_length = serd_node_pad_length(type.len); const size_t type_size = sizeof(SerdNode) + type_length; @@ -856,15 +848,13 @@ serd_new_decimal(SerdAllocator* const allocator, const double d) } SerdNode* -serd_new_integer(SerdAllocator* const allocator, - const int64_t i, - const SerdStringView datatype) +serd_new_integer(SerdAllocator* const allocator, const int64_t i) { - SerdWriteResult r = serd_node_construct_integer(0, NULL, i, datatype); + SerdWriteResult r = serd_node_construct_integer(0, NULL, i); SerdNode* const node = serd_node_try_malloc(allocator, r); if (node) { - r = serd_node_construct_integer(r.count, node, i, datatype); + r = serd_node_construct_integer(r.count, node, i); MUST_SUCCEED(r.status); assert(serd_node_length(node) == strlen(serd_node_string(node))); serd_node_check_padding(node); @@ -874,16 +864,13 @@ serd_new_integer(SerdAllocator* const allocator, } SerdNode* -serd_new_base64(SerdAllocator* const allocator, - const void* buf, - size_t size, - const SerdStringView datatype) +serd_new_base64(SerdAllocator* const allocator, const void* buf, size_t size) { - SerdWriteResult r = serd_node_construct_base64(0, NULL, size, buf, datatype); + SerdWriteResult r = serd_node_construct_base64(0, NULL, size, buf); SerdNode* const node = serd_node_try_malloc(allocator, r); if (node) { - r = serd_node_construct_base64(r.count, node, size, buf, datatype); + r = serd_node_construct_base64(r.count, node, size, buf); MUST_SUCCEED(r.status); assert(serd_node_length(node) == strlen(serd_node_string(node))); serd_node_check_padding(node); diff --git a/src/nodes.c b/src/nodes.c index 09b63f2a..90dd4f2c 100644 --- a/src/nodes.c +++ b/src/nodes.c @@ -451,23 +451,18 @@ serd_nodes_float(SerdNodes* const nodes, const float value) } const SerdNode* -serd_nodes_integer(SerdNodes* const nodes, - const int64_t value, - const SerdStringView datatype) +serd_nodes_integer(SerdNodes* const nodes, const int64_t value) { StaticNode key = empty_static_node; return try_intern( - nodes, - serd_node_construct_integer(sizeof(key), &key, value, datatype), - &key.node); + nodes, serd_node_construct_integer(sizeof(key), &key, value), &key.node); } const SerdNode* -serd_nodes_base64(SerdNodes* const nodes, - const void* const value, - const size_t value_size, - const SerdStringView datatype) +serd_nodes_base64(SerdNodes* const nodes, + const void* const value, + const size_t value_size) { assert(nodes); assert(value); @@ -482,14 +477,12 @@ serd_nodes_base64(SerdNodes* const nodes, like a Real Database(TM) would largely avoid this problem. */ // Determine how much space the node needs - SerdWriteResult r = - serd_node_construct_base64(0, NULL, value_size, value, datatype); + SerdWriteResult r = serd_node_construct_base64(0, NULL, value_size, value); // Allocate a new entry to and construct the node into it NodesEntry* const entry = new_entry(nodes->allocator, r.count); if (entry) { - r = serd_node_construct_base64( - r.count, &entry->node, value_size, value, datatype); + r = serd_node_construct_base64(r.count, &entry->node, value_size, value); assert(!r.status); (void)r; |