aboutsummaryrefslogtreecommitdiffstats
path: root/serd
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-05-11 18:11:44 +0200
committerDavid Robillard <d@drobilla.net>2018-11-25 22:12:46 +0100
commit3b4397f6ce5fc4aecd1074f78db308cc14f07bb5 (patch)
tree682cedcbe966c41e1c56e4fc387cd7ebf00308a0 /serd
parentadfa427e1c2a219ee071179dacfecc1339b16ab7 (diff)
downloadserd-3b4397f6ce5fc4aecd1074f78db308cc14f07bb5.tar.gz
serd-3b4397f6ce5fc4aecd1074f78db308cc14f07bb5.tar.bz2
serd-3b4397f6ce5fc4aecd1074f78db308cc14f07bb5.zip
Clean up node construction API
Diffstat (limited to 'serd')
-rw-r--r--serd/serd.h97
1 files changed, 40 insertions, 57 deletions
diff --git a/serd/serd.h b/serd/serd.h
index a179dac2..6228211b 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -468,18 +468,11 @@ serd_uri_serialise_relative(const SerdURI* uri,
*/
/**
- Create a new node from `str`.
+ Create a new plain literal string node from `str`.
*/
SERD_API
SerdNode*
-serd_node_new_string(SerdType type, const char* str);
-
-/**
- Create a new node from a prefix of `str`.
-*/
-SERD_API
-SerdNode*
-serd_node_new_substring(SerdType type, const char* str, size_t len);
+serd_node_new_string(const char* str);
/**
Create a new literal node from `str`.
@@ -495,15 +488,19 @@ serd_node_new_literal(const char* str,
/**
Create a new blank node.
-
- Note this function measures `str`, which is a common bottleneck.
- Use sord_node_from_serd_node() instead if `str` is already measured.
*/
SERD_API
SerdNode*
serd_node_new_blank(const char* str);
/**
+ Create a new CURIE node.
+*/
+SERD_API
+SerdNode*
+serd_node_new_curie(const char* str);
+
+/**
Return a deep copy of `node`.
*/
SERD_API
@@ -518,72 +515,60 @@ bool
serd_node_equals(const SerdNode* a, const SerdNode* b);
/**
- Simple wrapper for serd_node_new_uri() to resolve a URI node.
+ Create a new URI from a string.
*/
SERD_API
SerdNode*
-serd_node_new_uri_from_node(const SerdNode* uri_node,
- const SerdURI* base,
- SerdURI* out);
+serd_node_new_uri(const char* str);
/**
- Simple wrapper for serd_node_new_uri() to resolve a URI string.
+ Create a new URI from a string, resolved against a base URI.
*/
SERD_API
SerdNode*
-serd_node_new_uri_from_string(const char* str,
- const SerdURI* base,
- SerdURI* out);
+serd_node_new_resolved_uri(const char* str, const SerdNode* base);
/**
- Create a new file URI node from a file system path and optional hostname.
+ Resolve `node` against `base`.
- Backslashes in Windows paths will be converted and '%' will always be
- percent encoded. If `escape` is true, all other invalid characters will be
- percent encoded as well.
-
- If `path` is relative, `hostname` is ignored.
- If `out` is not NULL, it will be set to the parsed URI.
+ If `node` is not a relative URI, an equivalent new node is returned.
*/
SERD_API
SerdNode*
-serd_node_new_file_uri(const char* path,
- const char* hostname,
- SerdURI* out,
- bool escape);
+serd_node_resolve(const SerdNode* node, const SerdNode* base);
/**
- Create a new node by serialising `uri` into a new string.
-
- @param uri The URI to serialise.
+ Create a new file URI node from a file system path and optional hostname.
- @param base Base URI to resolve `uri` against (or NULL for no resolution).
+ Backslashes in Windows paths will be converted and '%' will always be
+ percent encoded. If `escape` is true, all other invalid characters will be
+ percent encoded as well.
- @param out Set to the parsing of the new URI (i.e. points only to
- memory owned by the new returned node).
+ If `path` is relative, `hostname` is ignored.
+ If `out` is not NULL, it will be set to the parsed URI.
*/
SERD_API
SerdNode*
-serd_node_new_uri(const SerdURI* uri, const SerdURI* base, SerdURI* out);
+serd_node_new_file_uri(const char* path, const char* hostname, bool escape);
/**
- Create a new node by serialising `uri` into a new relative URI.
+ Create a new URI from a string, relative to a base URI.
- @param uri The URI to serialise.
+ @param str URI string.
- @param base Base URI to make `uri` relative to, if possible.
+ @param base Base URI to make `str` relative to, if possible.
- @param root Root URI for resolution (see serd_uri_serialise_relative()).
+ @param root Optional root URI for resolution.
- @param out Set to the parsing of the new URI (i.e. points only to
- memory owned by the new returned node).
+ The URI is made relative iff if it a child of `base` and `root`. The
+ optional `root` parameter must be a prefix of `base` and can be used keep
+ up-references ("../") within a certain namespace.
*/
SERD_API
SerdNode*
-serd_node_new_relative_uri(const SerdURI* uri,
- const SerdURI* base,
- const SerdURI* root,
- SerdURI* out);
+serd_node_new_relative_uri(const char* str,
+ const SerdNode* base,
+ const SerdNode* root);
/**
Create a new node by serialising `d` into an xsd:decimal string.
@@ -801,8 +786,7 @@ serd_env_free(SerdEnv* env);
*/
SERD_API
const SerdNode*
-serd_env_get_base_uri(const SerdEnv* env,
- SerdURI* out);
+serd_env_get_base_uri(const SerdEnv* env);
/**
Set the current base URI.
@@ -999,13 +983,12 @@ serd_reader_free(SerdReader* reader);
*/
SERD_API
SerdWriter*
-serd_writer_new(SerdWorld* world,
- SerdSyntax syntax,
- SerdStyle style,
- SerdEnv* env,
- const SerdURI* base_uri,
- SerdWriteFunc ssink,
- void* stream);
+serd_writer_new(SerdWorld* world,
+ SerdSyntax syntax,
+ SerdStyle style,
+ SerdEnv* env,
+ SerdWriteFunc ssink,
+ void* stream);
/**
Free `writer`.