aboutsummaryrefslogtreecommitdiffstats
path: root/include/serd/serd.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-07-22 18:35:31 -0400
committerDavid Robillard <d@drobilla.net>2022-01-14 19:37:51 -0500
commit955be33cead7596506cf86211da6b0e53827ef96 (patch)
tree0dac1a7a31e8c50d1ba7200648d6ce402f97867d /include/serd/serd.h
parent34852e8faa380f12b11522cfa998df4f260e3856 (diff)
downloadserd-955be33cead7596506cf86211da6b0e53827ef96.tar.gz
serd-955be33cead7596506cf86211da6b0e53827ef96.tar.bz2
serd-955be33cead7596506cf86211da6b0e53827ef96.zip
Avoid dynamic allocation when fetching interned nodes
This is more or less a total rewrite of SerdNodes and the underlying ZixHash to make efficient use of the new node construction API.
Diffstat (limited to 'include/serd/serd.h')
-rw-r--r--include/serd/serd.h93
1 files changed, 79 insertions, 14 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h
index f67752a5..77986150 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -1223,25 +1223,33 @@ serd_nodes_intern(SerdNodes* SERD_NONNULL nodes,
const SerdNode* SERD_NULLABLE node);
/**
- Manage `node`.
+ Make a string node.
+
+ A new node will be added if an equivalent node is not already in the set.
+*/
+SERD_API
+const SerdNode* SERD_ALLOCATED
+serd_nodes_string(SerdNodes* SERD_NONNULL nodes, SerdStringView string);
- Like `serd_nodes_intern`, but takes ownership of `node`, freeing it and
- returning a previously interned/managed equivalent node if necessary.
+/**
+ Make a URI node from a string.
- @return A node that is equivalent to `node`.
+ A new node will be constructed with serd_node_construct_token() if an
+ equivalent one is not already in the set.
*/
SERD_API
const SerdNode* SERD_ALLOCATED
-serd_nodes_manage(SerdNodes* SERD_NONNULL nodes, SerdNode* SERD_NULLABLE node);
+serd_nodes_uri(SerdNodes* SERD_NONNULL nodes, SerdStringView string);
/**
- Make a string node.
+ Make a URI node from a parsed URI.
- A new node will be added if an equivalent node is not already in the set.
+ A new node will be constructed with serd_node_construct_uri() if an
+ equivalent one is not already in the set.
*/
SERD_API
const SerdNode* SERD_ALLOCATED
-serd_nodes_string(SerdNodes* SERD_NONNULL nodes, SerdStringView string);
+serd_nodes_parsed_uri(SerdNodes* SERD_NONNULL nodes, SerdURIView uri);
/**
Make a literal node with optional datatype or language.
@@ -1273,18 +1281,75 @@ serd_nodes_literal(SerdNodes* SERD_NONNULL nodes,
SerdStringView meta);
/**
- Make a URI node.
+ Make a canonical xsd:boolean node.
- A new node will be added if an equivalent node is not already in the set.
+ A new node will be constructed with serd_node_construct_boolean() if an
+ equivalent one is not already in the set.
*/
SERD_API
const SerdNode* SERD_ALLOCATED
-serd_nodes_uri(SerdNodes* SERD_NONNULL nodes, SerdStringView string);
+serd_nodes_boolean(SerdNodes* SERD_NONNULL nodes, bool value);
+
+/**
+ Make a canonical xsd:decimal node.
+
+ A new node will be constructed with serd_node_construct_decimal() if an
+ equivalent one is not already in the set.
+*/
+SERD_API
+const SerdNode* SERD_ALLOCATED
+serd_nodes_decimal(SerdNodes* SERD_NONNULL nodes, double value);
+
+/**
+ Make a canonical xsd:double node.
+
+ A new node will be constructed with serd_node_construct_double() if an
+ equivalent one is not already in the set.
+*/
+SERD_API
+const SerdNode* SERD_ALLOCATED
+serd_nodes_double(SerdNodes* SERD_NONNULL nodes, double value);
+
+/**
+ Make a canonical xsd:float node.
+
+ A new node will be constructed with serd_node_construct_float() if an
+ equivalent one is not already in the set.
+*/
+SERD_API
+const SerdNode* SERD_ALLOCATED
+serd_nodes_float(SerdNodes* SERD_NONNULL nodes, float value);
+
+/**
+ Make a canonical xsd:integer node.
+
+ A new node will be constructed with serd_node_construct_integer() if an
+ equivalent one is not already in the set.
+*/
+SERD_API
+const SerdNode* SERD_ALLOCATED
+serd_nodes_integer(SerdNodes* SERD_NONNULL nodes,
+ int64_t value,
+ SerdStringView datatype);
+
+/**
+ Make a canonical xsd:base64Binary node.
+
+ A new node will be constructed with serd_node_construct_base64() if an
+ equivalent one is not already in the set.
+*/
+SERD_API
+const SerdNode* SERD_ALLOCATED
+serd_nodes_base64(SerdNodes* SERD_NONNULL nodes,
+ const void* SERD_NONNULL value,
+ size_t value_size,
+ SerdStringView datatype);
/**
Make a blank node.
- A new node will be added if an equivalent node is not already in the set.
+ A new node will be constructed with serd_node_construct_token() if an
+ equivalent one is not already in the set.
*/
SERD_API
const SerdNode* SERD_ALLOCATED
@@ -1299,8 +1364,8 @@ serd_nodes_blank(SerdNodes* SERD_NONNULL nodes, SerdStringView string);
*/
SERD_API
void
-serd_nodes_deref(SerdNodes* SERD_NONNULL nodes,
- const SerdNode* SERD_NONNULL node);
+serd_nodes_deref(SerdNodes* SERD_NONNULL nodes,
+ const SerdNode* SERD_NULLABLE node);
/**
@}