aboutsummaryrefslogtreecommitdiffstats
path: root/serd/serd.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-01-20 07:31:58 +0000
committerDavid Robillard <d@drobilla.net>2011-01-20 07:31:58 +0000
commit0a62fc5f6aafd3e3f67d861634014d7e894c7bfd (patch)
tree570127d89143a64009bb753b2b6550507ae09cfa /serd/serd.h
parentfc2fe593097a523919ee71742081cbc6f3fc4c2c (diff)
downloadserd-0a62fc5f6aafd3e3f67d861634014d7e894c7bfd.tar.gz
serd-0a62fc5f6aafd3e3f67d861634014d7e894c7bfd.tar.bz2
serd-0a62fc5f6aafd3e3f67d861634014d7e894c7bfd.zip
Rework character reading functions to support reading multi-byte characters (take a string dest parameter instead of returning uchar).
Escape ntriples output. Pass all good read tests with output verification. git-svn-id: http://svn.drobilla.net/serd/trunk@8 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'serd/serd.h')
-rw-r--r--serd/serd.h105
1 files changed, 60 insertions, 45 deletions
diff --git a/serd/serd.h b/serd/serd.h
index d3d2b03d..dd4b25b7 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -49,6 +49,10 @@
* @{
*/
+typedef struct SerdNamespacesImpl* SerdNamespaces;
+typedef struct SerdReaderImpl* SerdReader;
+
+
/** RDF syntax */
typedef enum {
SERD_TURTLE = 1,
@@ -57,56 +61,31 @@ typedef enum {
/** Type of RDF node. */
typedef enum {
- BLANK = 1,
- URI = 2,
- QNAME = 3,
- LITERAL = 4
+ BLANK = 1, ///< Blank node (resource with no URI)
+ URI = 2, ///< URI (universal identifier)
+ QNAME = 3, ///< CURIE/QName (URI shortened with a namespace)
+ LITERAL = 4 ///< Literal string (with optional lang or datatype)
} SerdNodeType;
-
-/** @name String
- * @{
- */
-
-/** Measured UTF-8 string. */
-typedef struct {
- size_t n_bytes;
- size_t n_chars;
- uint8_t buf[];
-} SerdString;
-
-/** Create a new UTF-8 string from @a utf8. */
-SERD_API
-SerdString*
-serd_string_new(const uint8_t* utf8);
-
-/** Copy @a string. */
-SERD_API
-SerdString*
-serd_string_copy(const SerdString* string);
-
-/** @} */
-
-
/** @name URIs
* @{
*/
-/** Range of memory. */
+/* Range of memory. */
typedef struct {
const uint8_t* buf;
size_t len;
} SerdRange;
-/** Parsed URI. */
+/* Parsed URI. */
typedef struct {
- SerdRange scheme;
- SerdRange authority;
- SerdRange path_base;
- SerdRange path;
- SerdRange query;
- SerdRange fragment;
- bool base_uri_has_authority;
+ SerdRange scheme; ///< Scheme
+ SerdRange authority; ///< Authority
+ SerdRange path_base; ///< Path prefix if relative
+ SerdRange path; ///< Path suffix
+ SerdRange query; ///< Query
+ SerdRange fragment; ///< Fragment
+ bool base_uri_has_authority; ///< True iff base URI has authority
} SerdURI;
/** Return true iff @a utf8 is a relative URI string. */
@@ -129,11 +108,52 @@ SERD_API
bool
serd_uri_write(const SerdURI* uri, FILE* file);
+/** Sink function for raw string output. */
+typedef size_t (*SerdSink)(const uint8_t* buf, size_t len, void* stream);
+
+/** Serialise @a uri with a series of calls to @a sink. */
+SERD_API
+size_t
+serd_uri_serialise(const SerdURI* uri, SerdSink sink, void* stream);
+
+/** @} */
+
+/** @name String
+ * @{
+ */
+
+/** Measured UTF-8 string. */
+typedef struct {
+ size_t n_bytes; ///< Size in bytes including trailing null byte
+ size_t n_chars; ///< Length in characters
+ uint8_t buf[]; ///< Buffer
+} SerdString;
+
+/** Create a new UTF-8 string from @a utf8. */
+SERD_API
+SerdString*
+serd_string_new(const uint8_t* utf8);
+
+/** Copy @a string. */
+SERD_API
+SerdString*
+serd_string_copy(const SerdString* string);
+
/** Serialise @a uri to a string. */
SERD_API
SerdString*
-serd_uri_serialise(const SerdURI* uri,
- SerdURI* out);
+serd_string_new_from_uri(const SerdURI* uri,
+ SerdURI* out);
+
+SERD_API
+bool
+serd_write_node(FILE* file,
+ const SerdURI* base_uri,
+ SerdNamespaces ns,
+ SerdNodeType type,
+ const SerdString* str,
+ const SerdString* datatype,
+ const SerdString* lang);
/** @} */
@@ -142,9 +162,6 @@ serd_uri_serialise(const SerdURI* uri,
* @{
*/
-/** Reader. */
-typedef struct SerdReaderImpl* SerdReader;
-
/** Handler for base URI changes. */
typedef bool (*SerdBaseHandler)(void* handle,
const SerdString* uri);
@@ -194,8 +211,6 @@ serd_reader_free(SerdReader reader);
* @{
*/
-typedef struct SerdNamespacesImpl* SerdNamespaces;
-
/** Create a new namespaces dictionary. */
SERD_API
SerdNamespaces