aboutsummaryrefslogtreecommitdiffstats
path: root/include/serd
diff options
context:
space:
mode:
Diffstat (limited to 'include/serd')
-rw-r--r--include/serd/serd.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h
index 05c1ed8c..4067fa3f 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -1666,6 +1666,54 @@ serd_env_write_prefixes(const SerdEnv* SERD_NONNULL env,
const SerdSink* SERD_NONNULL sink);
/**
+ 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.
+
+ @param env Environment of `str`. This must define any abbreviations needed
+ to parse the string.
+
+ @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,
+ SerdEnv* SERD_NULLABLE env);
+
+/**
+ 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 write as a string.
+
+ @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.
+
+ @param env Environment for the output string. This can be used to
+ abbreviate things nicely by setting namespace prefixes.
+
+ @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,
+ const SerdEnv* SERD_NULLABLE env);
+
+/**
@}
@defgroup serd_byte_source Byte Source
@{