diff options
author | David Robillard <d@drobilla.net> | 2022-10-01 20:12:13 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 16:27:02 -0500 |
commit | cd3d9986f40fd4e605ac2e8168512065439173e2 (patch) | |
tree | 72d0418cbd8b8b5c7e43880c68831819e12b1982 /include/serd/string.h | |
parent | 1f09497ae009daade56c450e73bf6425b27cea24 (diff) | |
download | serd-cd3d9986f40fd4e605ac2e8168512065439173e2.tar.gz serd-cd3d9986f40fd4e605ac2e8168512065439173e2.tar.bz2 serd-cd3d9986f40fd4e605ac2e8168512065439173e2.zip |
Split up public API header
Diffstat (limited to 'include/serd/string.h')
-rw-r--r-- | include/serd/string.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/include/serd/string.h b/include/serd/string.h new file mode 100644 index 00000000..373dfdf0 --- /dev/null +++ b/include/serd/string.h @@ -0,0 +1,63 @@ +// Copyright 2011-2022 David Robillard <d@drobilla.net> +// SPDX-License-Identifier: ISC + +#ifndef SERD_STRING_H +#define SERD_STRING_H + +#include "serd/attributes.h" +#include "serd/node.h" + +#include <stddef.h> + +SERD_BEGIN_DECLS + +/** + @defgroup serd_string String Utilities + @ingroup serd_utilities + @{ +*/ + +/** + Measure a UTF-8 string. + + @return Length of `str` in bytes. + @param str A null-terminated UTF-8 string. + @param flags (Output) Set to the applicable flags. +*/ +SERD_API size_t +serd_strlen(const char* SERD_NONNULL str, SerdNodeFlags* SERD_NULLABLE flags); + +/** + Parse a string to a double. + + The API of this function is identical to the standard C strtod function, + except this function is locale-independent and always matches the lexical + format used in the Turtle grammar (the decimal point is always "."). +*/ +SERD_API double +serd_strtod(const char* SERD_NONNULL str, + char* SERD_NONNULL* SERD_NULLABLE endptr); + +/** + Decode a base64 string. + + This function can be used to deserialise a blob node created with + serd_node_new_blob(). + + @param str Base64 string to decode. + @param len The length of `str`. + @param size Set to the size of the returned blob in bytes. + @return A newly allocated blob which must be freed with serd_free(). +*/ +SERD_API void* SERD_ALLOCATED +serd_base64_decode(const char* SERD_NONNULL str, + size_t len, + size_t* SERD_NONNULL size); + +/** + @} +*/ + +SERD_END_DECLS + +#endif // SERD_STRING_H |