aboutsummaryrefslogtreecommitdiffstats
path: root/serd
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-06-21 18:19:48 +0200
committerDavid Robillard <d@drobilla.net>2020-10-27 13:13:59 +0100
commit51f917f8a5179a0e16b32a7f478b4245ea7f2505 (patch)
treef09ce814c6a18ee572f035a3527ae5f2207403f9 /serd
parent20e2f827282213714174e52ce7684e315545176c (diff)
downloadserd-51f917f8a5179a0e16b32a7f478b4245ea7f2505.tar.gz
serd-51f917f8a5179a0e16b32a7f478b4245ea7f2505.tar.bz2
serd-51f917f8a5179a0e16b32a7f478b4245ea7f2505.zip
WIP: Add serd_node_from_syntax() and serd_node_to_syntax()
Diffstat (limited to 'serd')
-rw-r--r--serd/serd.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/serd/serd.h b/serd/serd.h
index bac74adc..a43acbca 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -671,6 +671,44 @@ serd_uri_serialise_relative(const SerdURI* uri,
*/
/**
+ Create a node from a string representation in `syntax`.
+
+ The string should be a node as if written as an object in the given syntax,
+ without any extra quoting or punctuation, which is the format returned by
+ serd_node_to_syntax(). These two functions, when used with #SERD_TURTLE,
+ can be used to round-trip any node to a string and back.
+
+ @param str String representation of a node.
+
+ @param syntax Syntax to use. Should be either SERD_TURTLE or SERD_NTRIPLES
+ (the others are redundant). Note that namespaced (CURIE) nodes and relative
+ URIs can not be expressed in NTriples.
+
+ @return A newly allocated node that must be freed with serd_node_free().
+*/
+SERD_API
+SerdNode*
+serd_node_from_syntax(const char* str, SerdSyntax syntax);
+
+/**
+ Return a string representation of `node` in `syntax`.
+
+ The returned string represents that node as if written as an object in the
+ given syntax, without any extra quoting or punctuation.
+
+ @param node Node to serialise.
+
+ @param syntax Syntax to use. Should be either SERD_TURTLE or SERD_NTRIPLES
+ (the others are redundant). Note that namespaced (CURIE) nodes and relative
+ URIs can not be expressed in NTriples.
+
+ @return A newly allocated string that must be freed with serd_free().
+*/
+SERD_API
+char*
+serd_node_to_syntax(const SerdNode* node, SerdSyntax syntax);
+
+/**
Create a new "simple" node that is just a string.
This can be used to create blank, CURIE, or URI nodes from an already