aboutsummaryrefslogtreecommitdiffstats
path: root/serd/serd.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-05-11 18:11:44 +0200
committerDavid Robillard <d@drobilla.net>2018-05-27 18:23:15 +0200
commit4bc530b356ed4b390816669725e684d038e48aa0 (patch)
tree4a79ccbd7e3fa8dc53f85d93fab19d09f99c5c0d /serd/serd.h
parent1f4990c7d2e297dc0252ff193e66339d8db38837 (diff)
downloadserd-4bc530b356ed4b390816669725e684d038e48aa0.tar.gz
serd-4bc530b356ed4b390816669725e684d038e48aa0.tar.bz2
serd-4bc530b356ed4b390816669725e684d038e48aa0.zip
Clean up node construction API
Diffstat (limited to 'serd/serd.h')
-rw-r--r--serd/serd.h97
1 files changed, 40 insertions, 57 deletions
diff --git a/serd/serd.h b/serd/serd.h
index 0f937b24..89f612a3 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -439,18 +439,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`.
@@ -466,15 +459,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
@@ -489,72 +486,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.
@@ -772,8 +757,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.
@@ -986,13 +970,12 @@ serd_reader_free(SerdReader* reader);
*/
SERD_API
SerdWriter*
-serd_writer_new(SerdWorld* world,
- SerdSyntax syntax,
- SerdStyle style,
- SerdEnv* env,
- const SerdURI* base_uri,
- SerdSink ssink,
- void* stream);
+serd_writer_new(SerdWorld* world,
+ SerdSyntax syntax,
+ SerdStyle style,
+ SerdEnv* env,
+ SerdSink ssink,
+ void* stream);
/**
Free `writer`.