aboutsummaryrefslogtreecommitdiffstats
path: root/include/serd
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-06-21 18:19:48 +0200
committerDavid Robillard <d@drobilla.net>2021-03-08 23:23:06 -0500
commit8a13a270d9150e0cd14a049c76c601d09ee539bf (patch)
treebc4a82f47bb296a6277a65fa97c42deb8b908788 /include/serd
parentdc8831a4ebfee8a61975123f969f737845ad537f (diff)
downloadserd-8a13a270d9150e0cd14a049c76c601d09ee539bf.tar.gz
serd-8a13a270d9150e0cd14a049c76c601d09ee539bf.tar.bz2
serd-8a13a270d9150e0cd14a049c76c601d09ee539bf.zip
WIP: Add serd_node_from_syntax() and serd_node_to_syntax()
Diffstat (limited to 'include/serd')
-rw-r--r--include/serd/serd.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h
index f3402dd1..3c75518e 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -715,6 +715,44 @@ serd_write_uri(SerdURIView 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_ALLOCATED
+serd_node_from_syntax(const char* SERD_NONNULL 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_ALLOCATED
+serd_node_to_syntax(const SerdNode* SERD_NONNULL 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