aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-01-12 16:18:17 -0500
committerDavid Robillard <d@drobilla.net>2022-01-28 21:57:29 -0500
commit77eebec72c0507309ce89f8cdaceff4adfd147cf (patch)
treea0ce99f34ed769e980d094b7df51761ecf9dcf1e /src
parentd91b3c9ec59976c40742c852d25dccf67b445e61 (diff)
downloadserd-77eebec72c0507309ce89f8cdaceff4adfd147cf.tar.gz
serd-77eebec72c0507309ce89f8cdaceff4adfd147cf.tar.bz2
serd-77eebec72c0507309ce89f8cdaceff4adfd147cf.zip
Add serd_nodes_file_uri()
Diffstat (limited to 'src')
-rw-r--r--src/nodes.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/nodes.c b/src/nodes.c
index d488fc71..b989259d 100644
--- a/src/nodes.c
+++ b/src/nodes.c
@@ -504,6 +504,32 @@ serd_nodes_parsed_uri(SerdNodes* const nodes, const SerdURIView uri)
}
const SerdNode*
+serd_nodes_file_uri(SerdNodes* const nodes,
+ const SerdStringView path,
+ const SerdStringView hostname)
+{
+ assert(nodes);
+
+ /* Computing a hash for the serialised URI here would be quite complex, so,
+ since this isn't expected to be a particularly hot case, we just allocate
+ a new entry and try to do a normal insertion. */
+
+ // Determine how much space the node needs
+ SerdWriteResult r = serd_node_construct_file_uri(0u, NULL, path, hostname);
+ assert(r.status == SERD_OVERFLOW); // Currently no other errors
+
+ // Allocate a new entry to write the URI node into
+ NodesEntry* const entry = new_entry(nodes->allocator, r.count);
+ if (entry) {
+ r = serd_node_construct_file_uri(r.count, &entry->node, path, hostname);
+ assert(!r.status);
+ (void)r;
+ }
+
+ return serd_nodes_manage_entry(nodes, entry);
+}
+
+const SerdNode*
serd_nodes_blank(SerdNodes* const nodes, const SerdStringView string)
{
return serd_nodes_token(nodes, SERD_BLANK, string);