aboutsummaryrefslogtreecommitdiffstats
path: root/serd
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-02-16 17:03:27 +0000
committerDavid Robillard <d@drobilla.net>2011-02-16 17:03:27 +0000
commit0e7dfee8bae6655b316f1d0cabbad7df4dba6105 (patch)
treecc568baf815586293145caa774ad443d8b4ff612 /serd
parentebbaf807a95ad9fb80e0bfcfdab629a257c5836d (diff)
downloadserd-0e7dfee8bae6655b316f1d0cabbad7df4dba6105.tar.gz
serd-0e7dfee8bae6655b316f1d0cabbad7df4dba6105.tar.bz2
serd-0e7dfee8bae6655b316f1d0cabbad7df4dba6105.zip
Add SERD_STYLE_RESOLVED option for resolving (expanding) relative URIs in output.
Add serd_env_qualify and serd_env_foreach. git-svn-id: http://svn.drobilla.net/serd/trunk@101 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'serd')
-rw-r--r--serd/serd.h67
1 files changed, 44 insertions, 23 deletions
diff --git a/serd/serd.h b/serd/serd.h
index 98064bac..9655cdd2 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -222,6 +222,29 @@ SERD_API
void
serd_node_free(SerdNode* node);
+/** @} */
+/** @name SerdHandlers
+ * @brief Event handlers (user-provided worker functions).
+ * @{
+ */
+
+/** Sink for base URI changes. */
+typedef bool (*SerdBaseSink)(void* handle,
+ const SerdNode* uri);
+
+/** Sink for namespace definitions. */
+typedef bool (*SerdPrefixSink)(void* handle,
+ const SerdNode* name,
+ const SerdNode* uri);
+
+/** Sink for statements. */
+typedef bool (*SerdStatementSink)(void* handle,
+ const SerdNode* graph,
+ const SerdNode* subject,
+ const SerdNode* predicate,
+ const SerdNode* object,
+ const SerdNode* object_datatype,
+ const SerdNode* object_lang);
/** @} */
/** @name SerdEnv
@@ -246,38 +269,35 @@ serd_env_add(SerdEnv env,
const SerdNode* name,
const SerdNode* uri);
-/** Expand @a qname. */
+/** Qualify @a into a CURIE if possible. */
+SERD_API
+bool
+serd_env_qualify(const SerdEnv env,
+ const SerdNode* uri,
+ SerdNode* prefix,
+ SerdChunk* suffix);
+
+/** Expand @a curie. */
SERD_API
bool
serd_env_expand(const SerdEnv env,
- const SerdNode* qname,
+ const SerdNode* curie,
SerdChunk* uri_prefix,
SerdChunk* uri_suffix);
+/** Call @a func for each prefix defined in @a env. */
+SERD_API
+void
+serd_env_foreach(const SerdEnv env,
+ SerdPrefixSink func,
+ void* handle);
+
/** @} */
/** @name SerdReader
* @brief Reader of RDF syntax.
* @{
*/
-/** Sink for base URI changes. */
-typedef bool (*SerdBaseSink)(void* handle,
- const SerdNode* uri);
-
-/** Sink for namespace definitions. */
-typedef bool (*SerdPrefixSink)(void* handle,
- const SerdNode* name,
- const SerdNode* uri);
-
-/** Sink for statements. */
-typedef bool (*SerdStatementSink)(void* handle,
- const SerdNode* graph,
- const SerdNode* subject,
- const SerdNode* predicate,
- const SerdNode* object,
- const SerdNode* object_datatype,
- const SerdNode* object_lang);
-
/** Sink for anonymous node end markers.
* This is called to indicate that the anonymous node with the given
* @a value will no longer be referred to by any future statements
@@ -333,7 +353,8 @@ serd_reader_free(SerdReader reader);
typedef enum {
SERD_STYLE_ABBREVIATED = 1, /**< Abbreviate triples when possible. */
- SERD_STYLE_ASCII = 1 << 1 /**< Escape all non-ASCII characters. */
+ SERD_STYLE_ASCII = 1 << 1, /**< Escape all non-ASCII characters. */
+ SERD_STYLE_RESOLVED = 1 << 2 /**< Resolve relative URIs against base. */
} SerdStyle;
/** Create a new RDF writer. */
@@ -351,13 +372,13 @@ SERD_API
void
serd_writer_free(SerdWriter writer);
-/** Set the current output base URI. */
+/** Set the current output base URI (and emit directive if applicable). */
SERD_API
void
serd_writer_set_base_uri(SerdWriter writer,
const SerdURI* uri);
-/** Set the current output base URI. */
+/** Set a namespace prefix (and emit directive if applicable). */
SERD_API
void
serd_writer_set_prefix(SerdWriter writer,