aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-02-28 14:24:24 -0500
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:07 -0500
commitb7cce4a24dbc544129a9fabc44cb22025767f10b (patch)
treef085e200dc7b4b8a67ffebc191e752d0be366d53 /include
parent154e33ef21d175bb97263a8318dc0cc461a64321 (diff)
downloadserd-b7cce4a24dbc544129a9fabc44cb22025767f10b.tar.gz
serd-b7cce4a24dbc544129a9fabc44cb22025767f10b.tar.bz2
serd-b7cce4a24dbc544129a9fabc44cb22025767f10b.zip
Make serd_uri_string_length() precise and add it to public API
Diffstat (limited to 'include')
-rw-r--r--include/serd/uri.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/include/serd/uri.h b/include/serd/uri.h
index 93409075..3170fa89 100644
--- a/include/serd/uri.h
+++ b/include/serd/uri.h
@@ -123,6 +123,17 @@ SERD_PURE_API bool
serd_uri_is_within(SerdURIView r, SerdURIView base);
/**
+ Return the length of `uri` as a string.
+
+ This can be used to get the expected number of bytes that will be written by
+ serd_write_uri().
+
+ @return A string length in bytes, not including the null terminator.
+*/
+SERD_PURE_API size_t
+serd_uri_string_length(SerdURIView uri);
+
+/**
Write `uri` as a string to `sink`.
This will call `sink` several times to emit the URI.
@@ -130,7 +141,9 @@ serd_uri_is_within(SerdURIView r, SerdURIView base);
@param uri URI to write as a string.
@param sink Sink to write string output to.
@param stream Opaque user argument to pass to `sink`.
- @return The number of bytes written.
+
+ @return The number of bytes written, which is less than
+ `serd_uri_string_length(uri)` on error.
*/
SERD_API size_t
serd_write_uri(SerdURIView uri,