diff options
author | David Robillard <d@drobilla.net> | 2021-07-17 17:31:53 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:07 -0500 |
commit | 08a3b8a18093d1623309f5f406865f51e7bff39a (patch) | |
tree | 4c1c0dab3680d3e1ed8cbdc1d698c10eb5a9ba49 /include/serd/node.h | |
parent | 9c613b337712314c169d4add61212f4fc4102022 (diff) | |
download | serd-08a3b8a18093d1623309f5f406865f51e7bff39a.tar.gz serd-08a3b8a18093d1623309f5f406865f51e7bff39a.tar.bz2 serd-08a3b8a18093d1623309f5f406865f51e7bff39a.zip |
Clean up base64 node construction and access API
Diffstat (limited to 'include/serd/node.h')
-rw-r--r-- | include/serd/node.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/serd/node.h b/include/serd/node.h index 427bbdd1..50108f57 100644 --- a/include/serd/node.h +++ b/include/serd/node.h @@ -7,6 +7,7 @@ #include "serd/attributes.h" #include "serd/string_view.h" #include "serd/uri.h" +#include "serd/write_result.h" #include <stdbool.h> #include <stddef.h> @@ -360,6 +361,37 @@ SERD_API int64_t serd_get_integer(const SerdNode* SERD_NONNULL node); /** + Return the maximum size of a decoded binary node in bytes. + + This returns an upper bound on the number of bytes that the node would + decode to. This is calculated as a simple constant-time arithmetic + expression based on the length of the encoded string, so may be larger than + the actual size of the data due to things like additional whitespace. +*/ +SERD_PURE_API size_t +serd_get_base64_size(const SerdNode* SERD_NONNULL node); + +/** + Decode a base64 node. + + This function can be used to decode a node created with serd_new_base64(). + + @param node A literal node which is an encoded base64 string. + + @param buf_size The size of `buf` in bytes. + + @param buf Buffer where decoded data will be written. + + @return On success, #SERD_SUCCESS is returned along with the number of bytes + written. If the output buffer is too small, then #SERD_OVERFLOW is returned + along with the number of bytes required for successful decoding. +*/ +SERD_API SerdWriteResult +serd_get_base64(const SerdNode* SERD_NONNULL node, + size_t buf_size, + void* SERD_NONNULL buf); + +/** @} @defgroup serd_node_operators Operators @{ |