aboutsummaryrefslogtreecommitdiffstats
path: root/include/serd
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-02-28 14:24:24 -0500
committerDavid Robillard <d@drobilla.net>2022-01-13 23:05:21 -0500
commitb9cc3b642a9365c033c1fa31458d7822b42d0913 (patch)
tree845344958d1a338173071c3d6599889fb0b2d9a5 /include/serd
parent52183dea33ec4f3f0fbf5657c88cbdf10666b3f7 (diff)
downloadserd-b9cc3b642a9365c033c1fa31458d7822b42d0913.tar.gz
serd-b9cc3b642a9365c033c1fa31458d7822b42d0913.tar.bz2
serd-b9cc3b642a9365c033c1fa31458d7822b42d0913.zip
Make serd_uri_string_length() precise and add it to public API
Diffstat (limited to 'include/serd')
-rw-r--r--include/serd/serd.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h
index 47eca580..72a4c3fa 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -469,6 +469,18 @@ 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.
@@ -476,7 +488,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