From 5edfa72b81b46866a87d4f3c118492ee99bc0476 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 11 Jul 2021 18:44:03 -0400 Subject: Remove SERD_CURIE node datatype entirely --- include/serd/serd.h | 70 +++++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 34 deletions(-) (limited to 'include') diff --git a/include/serd/serd.h b/include/serd/serd.h index 7be9395c..05c1ed8c 100644 --- a/include/serd/serd.h +++ b/include/serd/serd.h @@ -569,14 +569,6 @@ typedef enum { */ SERD_URI = 2, - /** - CURIE, a shortened URI. - - Value is an unquoted CURIE string relative to the current environment, - e.g. "rdf:type". @see [CURIE Syntax 1.0](http://www.w3.org/TR/curie) - */ - SERD_CURIE = 3, - /** A blank node. @@ -584,7 +576,7 @@ typedef enum { is meaningful only within this serialisation. @see [RDF 1.1 Turtle](http://www.w3.org/TR/turtle/#grammar-production-BLANK_NODE_LABEL) */ - SERD_BLANK = 4, + SERD_BLANK = 3, /** A variable node. @@ -593,7 +585,7 @@ typedef enum { which is meaningful only within this serialisation. @see [SPARQL 1.1 Query Language](https://www.w3.org/TR/sparql11-query/#rVar) */ - SERD_VARIABLE = 5 + SERD_VARIABLE = 4 } SerdNodeType; /** @@ -639,11 +631,6 @@ SERD_API SerdNode* SERD_ALLOCATED serd_new_blank(SerdStringView string); -/// Create a new CURIE node -SERD_API -SerdNode* SERD_ALLOCATED -serd_new_curie(SerdStringView string); - /// Create a new URI node SERD_API SerdNode* SERD_ALLOCATED @@ -999,15 +986,6 @@ SERD_API const SerdNode* SERD_ALLOCATED serd_nodes_uri(SerdNodes* SERD_NONNULL nodes, SerdStringView string); -/** - Make a CURIE 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_curie(SerdNodes* SERD_NONNULL nodes, SerdStringView string); - /** Make a blank node. @@ -1636,25 +1614,50 @@ serd_env_set_prefix(SerdEnv* SERD_NONNULL env, SerdStringView uri); /** - Qualify `uri` into a CURIE if possible. + Qualify `uri` into a prefix and suffix (like a CURIE) if possible. + + @param env Environment with prefixes to use. + + @param uri URI to qualify. + + @param prefix On success, pointed to a prefix string slice, which is only + valid until the next time `env` is mutated. - Returns null if `uri` can not be qualified (usually because no corresponding - prefix is defined). + @param suffix On success, pointed to a suffix string slice, which is only + valid until the next time `env` is mutated. + + @return #SERD_SUCCESS, or #SERD_FAILURE if `uri` can not be qualified with + `env`. +*/ +SERD_API +SerdStatus +serd_env_qualify(const SerdEnv* SERD_NULLABLE env, + SerdStringView uri, + SerdStringView* SERD_NONNULL prefix, + SerdStringView* SERD_NONNULL suffix); + +/** + Expand `curie` to an absolute URI if possible. + + For example, if `env` has the prefix "rdf" set to + , then calling this with curie + "rdf:type" will produce . + + Returns null if `node` can not be expanded. */ SERD_API SerdNode* SERD_ALLOCATED -serd_env_qualify(const SerdEnv* SERD_NULLABLE env, - const SerdNode* SERD_NULLABLE uri); +serd_env_expand_curie(const SerdEnv* SERD_NULLABLE env, SerdStringView curie); /** - Expand `node`, which must be a CURIE or URI, to a full URI. + Expand `node` to an absolute URI if possible. Returns null if `node` can not be expanded. */ SERD_API SerdNode* SERD_ALLOCATED -serd_env_expand(const SerdEnv* SERD_NULLABLE env, - const SerdNode* SERD_NULLABLE node); +serd_env_expand_node(const SerdEnv* SERD_NULLABLE env, + const SerdNode* SERD_NULLABLE node); /// Write all prefixes in `env` to `sink` SERD_API @@ -1740,8 +1743,7 @@ typedef enum { SERD_READ_LAX = 1u << 0u, ///< Tolerate invalid input where possible SERD_READ_VARIABLES = 1u << 1u, ///< Support variable nodes SERD_READ_EXACT_BLANKS = 1u << 2u, ///< Allow clashes with generated blanks - SERD_READ_PREFIXED = 1u << 3u, ///< Do not expand prefixed names - SERD_READ_RELATIVE = 1u << 4u, ///< Do not expand relative URI references + SERD_READ_RELATIVE = 1u << 3u, ///< Do not expand relative URI references } SerdReaderFlag; /// Bitwise OR of SerdReaderFlag values -- cgit v1.2.1