aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-03-16 16:21:20 -0400
committerDavid Robillard <d@drobilla.net>2021-03-07 15:32:23 -0500
commita29581d3ba664175c459e20e6c86be09707fde6e (patch)
treed11253ca88b09d7a768740b00332a4d780e3852d /include
parent6e856d3e7a9c3162b9af350d5cec8a3f6bb94ee2 (diff)
downloadserd-a29581d3ba664175c459e20e6c86be09707fde6e.tar.gz
serd-a29581d3ba664175c459e20e6c86be09707fde6e.tar.bz2
serd-a29581d3ba664175c459e20e6c86be09707fde6e.zip
Use char* for strings in public API
The constant casting just makes user code a mess, for no benefit.
Diffstat (limited to 'include')
-rw-r--r--include/serd/serd.h103
1 files changed, 51 insertions, 52 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h
index 0d760f09..7b3d0cf7 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -185,16 +185,16 @@ typedef uint32_t SerdNodeFlags;
/// A syntactic RDF node
typedef struct {
- const uint8_t* SERD_NULLABLE buf; ///< Value string
- size_t n_bytes; ///< Size in bytes (excluding null)
- SerdNodeFlags flags; ///< Node flags (string properties)
- SerdType type; ///< Node type
+ const char* SERD_NULLABLE buf; ///< Value string
+ size_t n_bytes; ///< Size in bytes (excluding null)
+ SerdNodeFlags flags; ///< Node flags (string properties)
+ SerdType type; ///< Node type
} SerdNode;
/// An unterminated string fragment
typedef struct {
- const uint8_t* SERD_NULLABLE buf; ///< Start of chunk
- size_t len; ///< Length of chunk in bytes
+ const char* SERD_NULLABLE buf; ///< Start of chunk
+ size_t len; ///< Length of chunk in bytes
} SerdChunk;
/// A mutable buffer in memory
@@ -205,12 +205,12 @@ typedef struct {
/// An error description
typedef struct {
- SerdStatus status; ///< Error code
- const uint8_t* SERD_NULLABLE filename; ///< File with error
- unsigned line; ///< Line in file with error or 0
- unsigned col; ///< Column in file with error
- const char* SERD_NONNULL fmt; ///< Printf-style format string
- va_list* SERD_NONNULL args; ///< Arguments for fmt
+ SerdStatus status; ///< Error code
+ const char* SERD_NULLABLE filename; ///< File with error
+ unsigned line; ///< Line in file with error or 0
+ unsigned col; ///< Column in file with error
+ const char* SERD_NONNULL fmt; ///< Printf-style format string
+ va_list* SERD_NONNULL args; ///< Arguments for fmt
} SerdError;
/**
@@ -262,7 +262,7 @@ serd_free(void* SERD_NULLABLE ptr);
/// Return a string describing a status code
SERD_CONST_API
-const uint8_t* SERD_NONNULL
+const char* SERD_NONNULL
serd_strerror(SerdStatus status);
/**
@@ -274,8 +274,7 @@ serd_strerror(SerdStatus status);
*/
SERD_API
size_t
-serd_strlen(const uint8_t* SERD_NONNULL str,
- SerdNodeFlags* SERD_NULLABLE flags);
+serd_strlen(const char* SERD_NONNULL str, SerdNodeFlags* SERD_NULLABLE flags);
/**
Parse a string to a double.
@@ -302,9 +301,9 @@ serd_strtod(const char* SERD_NONNULL str,
*/
SERD_API
void* SERD_ALLOCATED
-serd_base64_decode(const uint8_t* SERD_NONNULL str,
- size_t len,
- size_t* SERD_NONNULL size);
+serd_base64_decode(const char* SERD_NONNULL str,
+ size_t len,
+ size_t* SERD_NONNULL size);
/**
@}
@@ -362,19 +361,19 @@ static const SerdURI SERD_URI_NULL =
@return The path component of the URI.
*/
SERD_API
-uint8_t* SERD_NULLABLE
-serd_file_uri_parse(const uint8_t* SERD_NONNULL uri,
- uint8_t* SERD_NONNULL* SERD_NULLABLE hostname);
+char* SERD_NULLABLE
+serd_file_uri_parse(const char* SERD_NONNULL uri,
+ char* SERD_NONNULL* SERD_NULLABLE hostname);
/// Return true iff `utf8` starts with a valid URI scheme
SERD_PURE_API
bool
-serd_uri_string_has_scheme(const uint8_t* SERD_NULLABLE utf8);
+serd_uri_string_has_scheme(const char* SERD_NULLABLE utf8);
/// Parse `utf8`, writing result to `out`
SERD_API
SerdStatus
-serd_uri_parse(const uint8_t* SERD_NONNULL utf8, SerdURI* SERD_NONNULL out);
+serd_uri_parse(const char* SERD_NONNULL utf8, SerdURI* SERD_NONNULL out);
/**
Set target `t` to reference `r` resolved against `base`.
@@ -424,7 +423,7 @@ static const SerdNode SERD_NODE_NULL = {NULL, 0, 0, SERD_NOTHING};
*/
SERD_API
SerdNode
-serd_node_from_string(SerdType type, const uint8_t* SERD_NULLABLE str);
+serd_node_from_string(SerdType type, const char* SERD_NULLABLE str);
/**
Make a (shallow) node from a prefix of `str`.
@@ -434,9 +433,9 @@ serd_node_from_string(SerdType type, const uint8_t* SERD_NULLABLE str);
*/
SERD_API
SerdNode
-serd_node_from_substring(SerdType type,
- const uint8_t* SERD_NULLABLE str,
- size_t len);
+serd_node_from_substring(SerdType type,
+ const char* SERD_NULLABLE str,
+ size_t len);
/// Simple wrapper for serd_node_new_uri() to resolve a URI node
SERD_API
@@ -448,7 +447,7 @@ serd_node_new_uri_from_node(const SerdNode* SERD_NONNULL uri_node,
/// Simple wrapper for serd_node_new_uri() to resolve a URI string
SERD_API
SerdNode
-serd_node_new_uri_from_string(const uint8_t* SERD_NULLABLE str,
+serd_node_new_uri_from_string(const char* SERD_NULLABLE str,
const SerdURI* SERD_NULLABLE base,
SerdURI* SERD_NULLABLE out);
@@ -463,9 +462,9 @@ serd_node_new_uri_from_string(const uint8_t* SERD_NULLABLE str,
*/
SERD_API
SerdNode
-serd_node_new_file_uri(const uint8_t* SERD_NONNULL path,
- const uint8_t* SERD_NULLABLE hostname,
- SerdURI* SERD_NULLABLE out);
+serd_node_new_file_uri(const char* SERD_NONNULL path,
+ const char* SERD_NULLABLE hostname,
+ SerdURI* SERD_NULLABLE out);
/**
Create a new node by serialising `uri` into a new string.
@@ -666,9 +665,9 @@ serd_env_set_prefix(SerdEnv* SERD_NONNULL env,
/// Set a namespace prefix
SERD_API
SerdStatus
-serd_env_set_prefix_from_strings(SerdEnv* SERD_NONNULL env,
- const uint8_t* SERD_NONNULL name,
- const uint8_t* SERD_NONNULL uri);
+serd_env_set_prefix_from_strings(SerdEnv* SERD_NONNULL env,
+ const char* SERD_NONNULL name,
+ const char* SERD_NONNULL uri);
/// Qualify `uri` into a CURIE if possible
SERD_API
@@ -764,8 +763,8 @@ serd_reader_get_handle(const SerdReader* SERD_NONNULL reader);
*/
SERD_API
void
-serd_reader_add_blank_prefix(SerdReader* SERD_NONNULL reader,
- const uint8_t* SERD_NULLABLE prefix);
+serd_reader_add_blank_prefix(SerdReader* SERD_NONNULL reader,
+ const char* SERD_NULLABLE prefix);
/**
Set the URI of the default graph.
@@ -782,8 +781,8 @@ serd_reader_set_default_graph(SerdReader* SERD_NONNULL reader,
/// Read a file at a given `uri`
SERD_API
SerdStatus
-serd_reader_read_file(SerdReader* SERD_NONNULL reader,
- const uint8_t* SERD_NONNULL uri);
+serd_reader_read_file(SerdReader* SERD_NONNULL reader,
+ const char* SERD_NONNULL uri);
/**
Start an incremental read from a file handle.
@@ -795,10 +794,10 @@ serd_reader_read_file(SerdReader* SERD_NONNULL reader,
*/
SERD_API
SerdStatus
-serd_reader_start_stream(SerdReader* SERD_NONNULL reader,
- FILE* SERD_NONNULL file,
- const uint8_t* SERD_NULLABLE name,
- bool bulk);
+serd_reader_start_stream(SerdReader* SERD_NONNULL reader,
+ FILE* SERD_NONNULL file,
+ const char* SERD_NULLABLE name,
+ bool bulk);
/**
Start an incremental read from a user-specified source.
@@ -812,7 +811,7 @@ serd_reader_start_source_stream(SerdReader* SERD_NONNULL reader,
SerdSource SERD_NONNULL read_func,
SerdStreamErrorFunc SERD_NONNULL error_func,
void* SERD_NONNULL stream,
- const uint8_t* SERD_NULLABLE name,
+ const char* SERD_NULLABLE name,
size_t page_size);
/**
@@ -835,9 +834,9 @@ serd_reader_end_stream(SerdReader* SERD_NONNULL reader);
/// Read `file`
SERD_API
SerdStatus
-serd_reader_read_file_handle(SerdReader* SERD_NONNULL reader,
- FILE* SERD_NONNULL file,
- const uint8_t* SERD_NULLABLE name);
+serd_reader_read_file_handle(SerdReader* SERD_NONNULL reader,
+ FILE* SERD_NONNULL file,
+ const char* SERD_NULLABLE name);
/// Read a user-specified byte source
SERD_API
@@ -846,14 +845,14 @@ serd_reader_read_source(SerdReader* SERD_NONNULL reader,
SerdSource SERD_NONNULL source,
SerdStreamErrorFunc SERD_NONNULL error,
void* SERD_NONNULL stream,
- const uint8_t* SERD_NULLABLE name,
+ const char* SERD_NULLABLE name,
size_t page_size);
/// Read `utf8`
SERD_API
SerdStatus
-serd_reader_read_string(SerdReader* SERD_NONNULL reader,
- const uint8_t* SERD_NONNULL utf8);
+serd_reader_read_string(SerdReader* SERD_NONNULL reader,
+ const char* SERD_NONNULL utf8);
/// Free `reader`
SERD_API
@@ -919,7 +918,7 @@ serd_buffer_sink(const void* SERD_NONNULL buf,
terminated (by this function) and owned by the caller.
*/
SERD_API
-uint8_t* SERD_NULLABLE
+char* SERD_NULLABLE
serd_buffer_sink_finish(SerdBuffer* SERD_NONNULL stream);
/**
@@ -942,8 +941,8 @@ serd_writer_set_error_sink(SerdWriter* SERD_NONNULL writer,
*/
SERD_API
void
-serd_writer_chop_blank_prefix(SerdWriter* SERD_NONNULL writer,
- const uint8_t* SERD_NULLABLE prefix);
+serd_writer_chop_blank_prefix(SerdWriter* SERD_NONNULL writer,
+ const char* SERD_NULLABLE prefix);
/**
Set the current output base URI, and emit a directive if applicable.