diff options
author | David Robillard <d@drobilla.net> | 2016-03-16 16:21:20 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-04-13 19:15:32 +0200 |
commit | c678dcfa54f3cf6784ac505f9e669ee233ba34c9 (patch) | |
tree | 9609a6978f1c25d009543d6d88043078b613a0c4 /serd | |
parent | 2a480d8cc56fe4d29fba2759b62d9f09fc0cc87e (diff) | |
download | serd-c678dcfa54f3cf6784ac505f9e669ee233ba34c9.tar.gz serd-c678dcfa54f3cf6784ac505f9e669ee233ba34c9.tar.bz2 serd-c678dcfa54f3cf6784ac505f9e669ee233ba34c9.zip |
Use char* for strings in public API
The constant casting just makes user code a mess, for no benefit.
Diffstat (limited to 'serd')
-rw-r--r-- | serd/serd.h | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/serd/serd.h b/serd/serd.h index ddfc39f9..db15cfc8 100644 --- a/serd/serd.h +++ b/serd/serd.h @@ -214,7 +214,7 @@ typedef uint32_t SerdNodeFlags; A syntactic RDF node. */ typedef struct { - const uint8_t* buf; /**< Value string */ + const char* buf; /**< Value string */ size_t n_bytes; /**< Size in bytes (not including null) */ SerdNodeFlags flags; /**< Node flags (e.g. string properties) */ SerdType type; /**< Node type */ @@ -224,8 +224,8 @@ typedef struct { An unterminated string fragment. */ typedef struct { - const uint8_t* buf; /**< Start of chunk */ - size_t len; /**< Length of chunk in bytes */ + const char* buf; /**< Start of chunk */ + size_t len; /**< Length of chunk in bytes */ } SerdChunk; /** @@ -240,12 +240,12 @@ typedef struct { An error description. */ typedef struct { - SerdStatus status; /**< Error code */ - const uint8_t* filename; /**< File where error was encountered, or NULL */ - unsigned line; /**< Line where error was encountered, or 0 */ - unsigned col; /**< Column where error was encountered */ - const char* fmt; /**< Message format string (printf style) */ - va_list* args; /**< Arguments for fmt */ + SerdStatus status; /**< Error code */ + const char* filename; /**< File where error was encountered, or NULL */ + unsigned line; /**< Line where error was encountered, or 0 */ + unsigned col; /**< Column where error was encountered */ + const char* fmt; /**< Message format string (printf style) */ + va_list* args; /**< Arguments for fmt */ } SerdError; /** @@ -300,7 +300,7 @@ serd_free(void* ptr); Return a string describing a status code. */ SERD_API -const uint8_t* +const char* serd_strerror(SerdStatus status); /** @@ -311,7 +311,7 @@ serd_strerror(SerdStatus status); */ SERD_API size_t -serd_strlen(const uint8_t* str, SerdNodeFlags* flags); +serd_strlen(const char* str, SerdNodeFlags* flags); /** Parse a string to a double. @@ -336,7 +336,7 @@ serd_strtod(const char* str, char** endptr); */ SERD_API void* -serd_base64_decode(const uint8_t* str, size_t len, size_t* size); +serd_base64_decode(const char* str, size_t len, size_t* size); /** @} @@ -393,8 +393,8 @@ static const SerdURI SERD_URI_NULL = { a path, use serd_file_uri_parse(). */ SERD_API -const uint8_t* -serd_uri_to_path(const uint8_t* uri); +const char* +serd_uri_to_path(const char* uri); /** Get the unescaped path and hostname from a file URI. @@ -405,22 +405,22 @@ serd_uri_to_path(const uint8_t* uri); The returned path and `*hostname` must be freed with serd_free(). */ SERD_API -uint8_t* -serd_file_uri_parse(const uint8_t* uri, uint8_t** hostname); +char* +serd_file_uri_parse(const char* uri, char** hostname); /** Return true iff `utf8` starts with a valid URI scheme. */ SERD_API bool -serd_uri_string_has_scheme(const uint8_t* utf8); +serd_uri_string_has_scheme(const char* utf8); /** Parse `utf8`, writing result to `out`. */ SERD_API SerdStatus -serd_uri_parse(const uint8_t* utf8, SerdURI* out); +serd_uri_parse(const char* utf8, SerdURI* out); /** Set target `t` to reference `r` resolved against `base`. @@ -468,7 +468,7 @@ static const SerdNode SERD_NODE_NULL = { NULL, 0, 0, SERD_NOTHING }; */ SERD_API SerdNode -serd_node_from_string(SerdType type, const uint8_t* str); +serd_node_from_string(SerdType type, const char* str); /** Make a (shallow) node from a prefix of `str`. @@ -478,7 +478,7 @@ serd_node_from_string(SerdType type, const uint8_t* str); */ SERD_API SerdNode -serd_node_from_substring(SerdType type, const uint8_t* str, size_t len); +serd_node_from_substring(SerdType type, const char* str, size_t len); /** Make a deep copy of `node`. @@ -510,7 +510,7 @@ serd_node_new_uri_from_node(const SerdNode* uri_node, */ SERD_API SerdNode -serd_node_new_uri_from_string(const uint8_t* str, +serd_node_new_uri_from_string(const char* str, const SerdURI* base, SerdURI* out); @@ -526,10 +526,10 @@ serd_node_new_uri_from_string(const uint8_t* str, */ SERD_API SerdNode -serd_node_new_file_uri(const uint8_t* path, - const uint8_t* hostname, - SerdURI* out, - bool escape); +serd_node_new_file_uri(const char* path, + const char* hostname, + SerdURI* out, + bool escape); /** Create a new node by serialising `uri` into a new string. @@ -719,9 +719,9 @@ serd_env_set_prefix(SerdEnv* env, */ SERD_API SerdStatus -serd_env_set_prefix_from_strings(SerdEnv* env, - const uint8_t* name, - const uint8_t* uri); +serd_env_set_prefix_from_strings(SerdEnv* env, + const char* name, + const char* uri); /** Qualify `uri` into a CURIE if possible. @@ -825,8 +825,8 @@ serd_reader_get_handle(const SerdReader* reader); */ SERD_API void -serd_reader_add_blank_prefix(SerdReader* reader, - const uint8_t* prefix); +serd_reader_add_blank_prefix(SerdReader* reader, + const char* prefix); /** Set the URI of the default graph. @@ -845,8 +845,8 @@ serd_reader_set_default_graph(SerdReader* reader, */ SERD_API SerdStatus -serd_reader_read_file(SerdReader* reader, - const uint8_t* uri); +serd_reader_read_file(SerdReader* reader, + const char* uri); /** Start an incremental read from a file handle. @@ -858,10 +858,10 @@ serd_reader_read_file(SerdReader* reader, */ SERD_API SerdStatus -serd_reader_start_stream(SerdReader* reader, - FILE* file, - const uint8_t* name, - bool bulk); +serd_reader_start_stream(SerdReader* reader, + FILE* file, + const char* name, + bool bulk); /** Start an incremental read from a user-specified source. @@ -875,7 +875,7 @@ serd_reader_start_source_stream(SerdReader* reader, SerdSource read_func, SerdStreamErrorFunc error_func, void* stream, - const uint8_t* name, + const char* name, size_t page_size); /** @@ -902,9 +902,9 @@ serd_reader_end_stream(SerdReader* reader); */ SERD_API SerdStatus -serd_reader_read_file_handle(SerdReader* reader, - FILE* file, - const uint8_t* name); +serd_reader_read_file_handle(SerdReader* reader, + FILE* file, + const char* name); /** Read a user-specified byte source. @@ -915,7 +915,7 @@ serd_reader_read_source(SerdReader* reader, SerdSource source, SerdStreamErrorFunc error, void* stream, - const uint8_t* name, + const char* name, size_t page_size); /** @@ -923,7 +923,7 @@ serd_reader_read_source(SerdReader* reader, */ SERD_API SerdStatus -serd_reader_read_string(SerdReader* reader, const uint8_t* utf8); +serd_reader_read_string(SerdReader* reader, const char* utf8); /** Free `reader`. @@ -993,7 +993,7 @@ serd_buffer_sink(const void* buf, size_t len, void* stream); terminated (by this function) and owned by the caller. */ SERD_API -uint8_t* +char* serd_buffer_sink_finish(SerdBuffer* stream); /** @@ -1013,8 +1013,8 @@ serd_writer_set_error_sink(SerdWriter* writer, */ SERD_API void -serd_writer_chop_blank_prefix(SerdWriter* writer, - const uint8_t* prefix); +serd_writer_chop_blank_prefix(SerdWriter* writer, + const char* prefix); /** Set the current output base URI (and emit directive if applicable). |