| 
									
										
										
										
											2022-02-11 09:07:11 +11:00
										 |  |  | /* SPDX-License-Identifier: GPL-2.0-or-later
 | 
					
						
							|  |  |  |  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */ | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-17 18:59:41 +00:00
										 |  |  | #pragma once
 | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-18 08:08:12 +11:00
										 |  |  | /** \file
 | 
					
						
							|  |  |  |  * \ingroup bli | 
					
						
							| 
									
										
										
										
											2011-02-18 13:58:08 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-19 15:24:32 +01:00
										 |  |  | #include <inttypes.h>
 | 
					
						
							| 
									
										
										
										
											2020-03-19 09:33:03 +01:00
										 |  |  | #include <stdarg.h>
 | 
					
						
							| 
									
										
										
										
											2012-08-26 11:01:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-08 18:16:39 +02:00
										 |  |  | #include "BLI_compiler_attrs.h"
 | 
					
						
							|  |  |  | #include "BLI_utildefines.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Duplicates the first \a len bytes of cstring \a str | 
					
						
							|  |  |  |  * into a newly mallocN'd string and returns it. \a str | 
					
						
							|  |  |  |  * is assumed to be at least len bytes long. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param str: The string to be duplicated | 
					
						
							|  |  |  |  * \param len: The number of bytes to duplicate | 
					
						
							|  |  |  |  * \retval Returns the duplicated string | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2022-01-12 12:49:36 +01:00
										 |  |  | char *BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Duplicates the cstring \a str into a newly mallocN'd | 
					
						
							|  |  |  |  * string and returns it. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param str: The string to be duplicated | 
					
						
							|  |  |  |  * \retval Returns the duplicated string | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-09-01 15:01:15 +00:00
										 |  |  | char *BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC; | 
					
						
							| 
									
										
										
										
											2010-11-29 14:29:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Appends the two strings, and returns new mallocN'ed string | 
					
						
							|  |  |  |  * \param str1: first string for copy | 
					
						
							|  |  |  |  * \param str2: second string for append | 
					
						
							|  |  |  |  * \retval Returns dst | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-09-01 15:01:15 +00:00
										 |  |  | char *BLI_strdupcat(const char *__restrict str1, | 
					
						
							|  |  |  |                     const char *__restrict str2) ATTR_WARN_UNUSED_RESULT | 
					
						
							|  |  |  |     ATTR_NONNULL() ATTR_MALLOC; | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Like strncpy but ensures dst is always | 
					
						
							|  |  |  |  * '\0' terminated. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param dst: Destination for copy | 
					
						
							|  |  |  |  * \param src: Source string to copy | 
					
						
							|  |  |  |  * \param maxncpy: Maximum number of characters to copy (generally | 
					
						
							|  |  |  |  * the size of dst) | 
					
						
							|  |  |  |  * \retval Returns dst | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2022-01-12 12:49:36 +01:00
										 |  |  | char *BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2013-03-14 10:07:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Like BLI_strncpy but ensures dst is always padded by given char, | 
					
						
							|  |  |  |  * on both sides (unless src is empty). | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param dst: Destination for copy | 
					
						
							|  |  |  |  * \param src: Source string to copy | 
					
						
							|  |  |  |  * \param pad: the char to use for padding | 
					
						
							|  |  |  |  * \param maxncpy: Maximum number of characters to copy (generally the size of dst) | 
					
						
							|  |  |  |  * \retval Returns dst | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-01-06 18:21:46 +11:00
										 |  |  | char *BLI_strncpy_ensure_pad(char *__restrict dst, | 
					
						
							|  |  |  |                              const char *__restrict src, | 
					
						
							| 
									
										
										
										
											2022-01-07 11:38:08 +11:00
										 |  |  |                              char pad, | 
					
						
							| 
									
										
										
										
											2015-01-06 18:21:46 +11:00
										 |  |  |                              size_t maxncpy) ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2015-01-03 10:13:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Like strncpy but ensures dst is always | 
					
						
							|  |  |  |  * '\0' terminated. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \note This is a duplicate of #BLI_strncpy that returns bytes copied. | 
					
						
							|  |  |  |  * And is a drop in replacement for 'snprintf(str, sizeof(str), "%s", arg);' | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param dst: Destination for copy | 
					
						
							|  |  |  |  * \param src: Source string to copy | 
					
						
							|  |  |  |  * \param maxncpy: Maximum number of characters to copy (generally | 
					
						
							|  |  |  |  * the size of dst) | 
					
						
							|  |  |  |  * \retval The number of bytes copied (The only difference from BLI_strncpy). | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-09-01 15:01:15 +00:00
										 |  |  | size_t BLI_strncpy_rlen(char *__restrict dst, | 
					
						
							|  |  |  |                         const char *__restrict src, | 
					
						
							| 
									
										
										
										
											2022-01-12 12:49:36 +01:00
										 |  |  |                         size_t maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2013-06-16 08:29:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-01 15:01:15 +00:00
										 |  |  | size_t BLI_strcpy_rlen(char *__restrict dst, const char *__restrict src) ATTR_WARN_UNUSED_RESULT | 
					
						
							|  |  |  |     ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2009-10-12 11:27:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Return the range of the quoted string (excluding quotes) `str` after `prefix`. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * A version of #BLI_str_quoted_substrN that calculates the range | 
					
						
							|  |  |  |  * instead of un-escaping and allocating the result. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param str: String potentially including `prefix`. | 
					
						
							|  |  |  |  * \param prefix: Quoted string prefix. | 
					
						
							|  |  |  |  * \param r_start: The start of the quoted string (after the first quote). | 
					
						
							|  |  |  |  * \param r_end: The end of the quoted string (before the last quote). | 
					
						
							|  |  |  |  * \return True when a quoted string range could be found after `prefix`. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-09-01 15:23:58 +10:00
										 |  |  | bool BLI_str_quoted_substr_range(const char *__restrict str, | 
					
						
							|  |  |  |                                  const char *__restrict prefix, | 
					
						
							|  |  |  |                                  int *__restrict r_start, | 
					
						
							|  |  |  |                                  int *__restrict r_end) ATTR_WARN_UNUSED_RESULT | 
					
						
							|  |  |  |     ATTR_NONNULL(1, 2, 3, 4); | 
					
						
							| 
									
										
										
										
											2021-09-06 15:51:53 +10:00
										 |  |  | #if 0 /* UNUSED */
 | 
					
						
							| 
									
										
										
										
											2013-09-01 15:01:15 +00:00
										 |  |  | char *BLI_str_quoted_substrN(const char *__restrict str, | 
					
						
							|  |  |  |                              const char *__restrict prefix) ATTR_WARN_UNUSED_RESULT | 
					
						
							|  |  |  |     ATTR_NONNULL() ATTR_MALLOC; | 
					
						
							| 
									
										
										
										
											2021-09-06 15:51:53 +10:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Fills \a result with text within "" that appear after some the contents of \a prefix. | 
					
						
							|  |  |  |  * i.e. for string `pose["apples"]` with prefix `pose[`, it will return `apples`. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param str: is the entire string to chop. | 
					
						
							|  |  |  |  * \param prefix: is the part of the string to step over. | 
					
						
							|  |  |  |  * \param result: The buffer to fill. | 
					
						
							|  |  |  |  * \param result_maxlen: The maximum size of the buffer (including nil terminator). | 
					
						
							|  |  |  |  * \return True if the prefix was found and the entire quoted string was copied into result. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Assume that the strings returned must be freed afterwards, | 
					
						
							|  |  |  |  * and that the inputs will contain data we want. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-09-04 14:22:44 +10:00
										 |  |  | bool BLI_str_quoted_substr(const char *__restrict str, | 
					
						
							|  |  |  |                            const char *__restrict prefix, | 
					
						
							|  |  |  |                            char *result, | 
					
						
							|  |  |  |                            size_t result_maxlen); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * string with all instances of substr_old replaced with substr_new, | 
					
						
							|  |  |  |  * Returns a copy of the c-string \a str into a newly #MEM_mallocN'd | 
					
						
							|  |  |  |  * and returns it. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \note A rather wasteful string-replacement utility, though this shall do for now. | 
					
						
							|  |  |  |  * Feel free to replace this with an even safe + nicer alternative | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param str: The string to replace occurrences of substr_old in | 
					
						
							|  |  |  |  * \param substr_old: The text in the string to find and replace | 
					
						
							|  |  |  |  * \param substr_new: The text in the string to find and replace | 
					
						
							|  |  |  |  * \retval Returns the duplicated string | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-06-30 14:50:34 +10:00
										 |  |  | char *BLI_str_replaceN(const char *__restrict str, | 
					
						
							|  |  |  |                        const char *__restrict substr_old, | 
					
						
							|  |  |  |                        const char *__restrict substr_new) ATTR_WARN_UNUSED_RESULT | 
					
						
							|  |  |  |     ATTR_NONNULL() ATTR_MALLOC; | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * In-place replace every \a src to \a dst in \a str. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param str: The string to operate on. | 
					
						
							|  |  |  |  * \param src: The character to replace. | 
					
						
							|  |  |  |  * \param dst: The character to replace with. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-12-14 18:35:23 +11:00
										 |  |  | void BLI_str_replace_char(char *str, char src, char dst) ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:18:03 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Simple exact-match string replacement. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param replace_table: Array of source, destination pairs. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \note Larger tables should use a hash table. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-04-21 17:34:18 +10:00
										 |  |  | bool BLI_str_replace_table_exact(char *string, | 
					
						
							| 
									
										
										
										
											2022-01-12 12:49:36 +01:00
										 |  |  |                                  size_t string_len, | 
					
						
							| 
									
										
										
										
											2021-04-21 17:34:18 +10:00
										 |  |  |                                  const char *replace_table[][2], | 
					
						
							|  |  |  |                                  int replace_table_len); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Portable replacement for #snprintf | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2014-05-20 21:41:57 +10:00
										 |  |  | size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format, ...) | 
					
						
							|  |  |  |     ATTR_NONNULL(1, 3) ATTR_PRINTF_FORMAT(3, 4); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * A version of #BLI_snprintf that returns `strlen(dst)` | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-04-22 05:37:22 +10:00
										 |  |  | size_t BLI_snprintf_rlen(char *__restrict dst, size_t maxncpy, const char *__restrict format, ...) | 
					
						
							|  |  |  |     ATTR_NONNULL(1, 3) ATTR_PRINTF_FORMAT(3, 4); | 
					
						
							| 
									
										
										
										
											2009-03-25 20:29:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Portable replacement for `vsnprintf`. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2020-09-04 20:59:13 +02:00
										 |  |  | size_t BLI_vsnprintf(char *__restrict buffer, | 
					
						
							| 
									
										
										
										
											2013-09-01 15:01:15 +00:00
										 |  |  |                      size_t maxncpy, | 
					
						
							|  |  |  |                      const char *__restrict format, | 
					
						
							|  |  |  |                      va_list arg) ATTR_PRINTF_FORMAT(3, 0); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * A version of #BLI_vsnprintf that returns `strlen(buffer)` | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-04-22 05:37:22 +10:00
										 |  |  | size_t BLI_vsnprintf_rlen(char *__restrict buffer, | 
					
						
							|  |  |  |                           size_t maxncpy, | 
					
						
							|  |  |  |                           const char *__restrict format, | 
					
						
							|  |  |  |                           va_list arg) ATTR_PRINTF_FORMAT(3, 0); | 
					
						
							| 
									
										
										
										
											2011-08-23 15:08:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Print formatted string into a newly #MEM_mallocN'd string | 
					
						
							|  |  |  |  * and return it. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2014-05-20 21:41:57 +10:00
										 |  |  | char *BLI_sprintfN(const char *__restrict format, ...) ATTR_WARN_UNUSED_RESULT | 
					
						
							|  |  |  |     ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1, 2); | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * This roughly matches C and Python's string escaping with double quotes - `"`. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Since every character may need escaping, | 
					
						
							|  |  |  |  * it's common to create a buffer twice as large as the input. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param dst: The destination string, at least \a dst_maxncpy, typically `(strlen(src) * 2) + 1`. | 
					
						
							|  |  |  |  * \param src: The un-escaped source string. | 
					
						
							|  |  |  |  * \param dst_maxncpy: The maximum number of bytes allowable to copy. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \note This is used for creating animation paths in blend files. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2022-01-12 12:49:36 +01:00
										 |  |  | size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) | 
					
						
							| 
									
										
										
										
											2013-09-01 15:01:15 +00:00
										 |  |  |     ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * This roughly matches C and Python's string escaping with double quotes - `"`. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The destination will never be larger than the source, it will either be the same | 
					
						
							|  |  |  |  * or up to half when all characters are escaped. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param dst: The destination string, at least the size of `strlen(src) + 1`. | 
					
						
							|  |  |  |  * \param src: The escaped source string. | 
					
						
							|  |  |  |  * \param src_maxncpy: The maximum number of bytes allowable to copy from `src`. | 
					
						
							|  |  |  |  * \param dst_maxncpy: The maximum number of bytes allowable to copy into `dst`. | 
					
						
							|  |  |  |  * \param r_is_complete: Set to true when | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-09-04 14:22:44 +10:00
										 |  |  | size_t BLI_str_unescape_ex(char *__restrict dst, | 
					
						
							|  |  |  |                            const char *__restrict src, | 
					
						
							| 
									
										
										
										
											2022-01-12 12:49:36 +01:00
										 |  |  |                            size_t src_maxncpy, | 
					
						
							| 
									
										
										
										
											2021-09-04 14:22:44 +10:00
										 |  |  |                            /* Additional arguments. */ | 
					
						
							| 
									
										
										
										
											2022-01-12 12:49:36 +01:00
										 |  |  |                            size_t dst_maxncpy, | 
					
						
							| 
									
										
										
										
											2021-09-04 14:22:44 +10:00
										 |  |  |                            bool *r_is_complete) ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * See #BLI_str_unescape_ex doc-string. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This function makes the assumption that `dst` always has | 
					
						
							|  |  |  |  * at least `src_maxncpy` bytes available. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Use #BLI_str_unescape_ex if `dst` has a smaller fixed size. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \note This is used for parsing animation paths in blend files (runs often). | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2022-01-12 12:49:36 +01:00
										 |  |  | size_t BLI_str_unescape(char *__restrict dst, const char *__restrict src, size_t src_maxncpy) | 
					
						
							| 
									
										
										
										
											2020-12-10 13:42:59 +11:00
										 |  |  |     ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2021-09-04 14:22:44 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Find the first un-escaped quote in the string (to find the end of the string). | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param str: Typically this is the first character in a quoted string. | 
					
						
							|  |  |  |  * Where the character before `*str` would be `"`. | 
					
						
							| 
									
										
										
										
											2022-04-11 11:41:00 +10:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  |  * \return The pointer to the first un-escaped quote. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2020-12-10 15:06:16 +11:00
										 |  |  | const char *BLI_str_escape_find_quote(const char *str) ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Format ints with decimal grouping. | 
					
						
							|  |  |  |  * 1000 -> 1,000 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param dst: The resulting string | 
					
						
							|  |  |  |  * \param num: Number to format | 
					
						
							|  |  |  |  * \return The length of \a dst | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2014-07-17 14:54:12 +10:00
										 |  |  | size_t BLI_str_format_int_grouped(char dst[16], int num) ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Format uint64_t with decimal grouping. | 
					
						
							|  |  |  |  * 1000 -> 1,000 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param dst: The resulting string | 
					
						
							|  |  |  |  * \param num: Number to format | 
					
						
							|  |  |  |  * \return The length of \a dst | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2018-11-19 15:24:32 +01:00
										 |  |  | size_t BLI_str_format_uint64_grouped(char dst[16], uint64_t num) ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Format a size in bytes using binary units. | 
					
						
							|  |  |  |  * 1000 -> 1 KB | 
					
						
							|  |  |  |  * Number of decimal places grows with the used unit (e.g. 1.5 MB, 1.55 GB, 1.545 TB). | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param dst: The resulting string. | 
					
						
							|  |  |  |  * Dimension of 14 to support largest possible value for \a bytes (#LLONG_MAX). | 
					
						
							|  |  |  |  * \param bytes: Number to format. | 
					
						
							|  |  |  |  * \param base_10: Calculate using base 10 (GB, MB, ...) or 2 (GiB, MiB, ...). | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2022-01-07 11:38:08 +11:00
										 |  |  | void BLI_str_format_byte_unit(char dst[15], long long int bytes, bool base_10) ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Format a count to up to 6 places (plus '\0' terminator) string using long number | 
					
						
							|  |  |  |  * names abbreviations. Used to produce a compact representation of large numbers. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 1 -> 1 | 
					
						
							|  |  |  |  * 15 -> 15 | 
					
						
							|  |  |  |  * 155 -> 155 | 
					
						
							|  |  |  |  * 1555 -> 1.6K | 
					
						
							|  |  |  |  * 15555 -> 15.6K | 
					
						
							|  |  |  |  * 155555 -> 156K | 
					
						
							|  |  |  |  * 1555555 -> 1.6M | 
					
						
							|  |  |  |  * 15555555 -> 15.6M | 
					
						
							|  |  |  |  * 155555555 -> 156M | 
					
						
							|  |  |  |  * 1000000000 -> 1B | 
					
						
							|  |  |  |  * ... | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Length of 7 is the maximum of the resulting string, for example, `-15.5K\0`. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2022-05-11 22:46:19 +10:00
										 |  |  | void BLI_str_format_decimal_unit(char dst[7], int number_to_format) ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Compare two strings without regard to case. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \retval True if the strings are equal, false otherwise. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-09-01 15:01:15 +00:00
										 |  |  | int BLI_strcaseeq(const char *a, const char *b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Portable replacement for `strcasestr` (not available in MSVC) | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-09-01 15:01:15 +00:00
										 |  |  | char *BLI_strcasestr(const char *s, const char *find) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Variation of #BLI_strcasestr with string length limited to \a len | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2016-03-23 18:45:32 +11:00
										 |  |  | char *BLI_strncasestr(const char *s, const char *find, size_t len) ATTR_WARN_UNUSED_RESULT | 
					
						
							|  |  |  |     ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2013-09-01 15:01:15 +00:00
										 |  |  | int BLI_strcasecmp(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); | 
					
						
							|  |  |  | int BLI_strncasecmp(const char *s1, const char *s2, size_t len) ATTR_WARN_UNUSED_RESULT | 
					
						
							|  |  |  |     ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Case insensitive, *natural* string comparison, | 
					
						
							|  |  |  |  * keeping numbers in order. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2019-08-31 17:28:48 +10:00
										 |  |  | int BLI_strcasecmp_natural(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Like strcmp, but will ignore any heading/trailing pad char for comparison. | 
					
						
							|  |  |  |  * So e.g. if pad is '*', '*world' and 'world*' will compare equal. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2022-01-07 11:38:08 +11:00
										 |  |  | int BLI_strcmp_ignore_pad(const char *str1, const char *str2, char pad) ATTR_WARN_UNUSED_RESULT | 
					
						
							|  |  |  |     ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2015-01-03 10:13:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Determine the length of a fixed-size string. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2022-01-12 12:49:36 +01:00
										 |  |  | size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2013-09-01 15:01:15 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-09 17:17:03 +02:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * String case conversion, not affected by locale. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-12 12:49:36 +01:00
										 |  |  | void BLI_str_tolower_ascii(char *str, size_t len) ATTR_NONNULL(); | 
					
						
							|  |  |  | void BLI_str_toupper_ascii(char *str, size_t len) ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2022-05-09 17:17:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | char BLI_tolower_ascii(const char c); | 
					
						
							|  |  |  | char BLI_toupper_ascii(const char c); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Strip white-space from end of the string. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2018-08-15 14:47:48 +02:00
										 |  |  | void BLI_str_rstrip(char *str) ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Strip trailing zeros from a float, eg: | 
					
						
							|  |  |  |  *   0.0000 -> 0.0 | 
					
						
							|  |  |  |  *   2.0010 -> 2.001 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param str: | 
					
						
							|  |  |  |  * \param pad: | 
					
						
							|  |  |  |  * \return The number of zeros stripped. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2022-01-07 11:38:08 +11:00
										 |  |  | int BLI_str_rstrip_float_zero(char *str, char pad) ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2011-05-26 09:58:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Return index of a string in a string array. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param str: The string to find. | 
					
						
							|  |  |  |  * \param str_array: Array of strings. | 
					
						
							|  |  |  |  * \param str_array_len: The length of the array, or -1 for a NULL-terminated array. | 
					
						
							|  |  |  |  * \return The index of str in str_array or -1. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2014-06-17 15:58:07 +02:00
										 |  |  | int BLI_str_index_in_array_n(const char *__restrict str, | 
					
						
							|  |  |  |                              const char **__restrict str_array, | 
					
						
							| 
									
										
										
										
											2022-01-07 11:38:08 +11:00
										 |  |  |                              int str_array_len) ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Return index of a string in a string array. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param str: The string to find. | 
					
						
							|  |  |  |  * \param str_array: Array of strings, (must be NULL-terminated). | 
					
						
							|  |  |  |  * \return The index of str in str_array or -1. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2014-06-17 15:58:07 +02:00
										 |  |  | int BLI_str_index_in_array(const char *__restrict str, const char **__restrict str_array) | 
					
						
							|  |  |  |     ATTR_NONNULL(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Find if a string starts with another string. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param str: The string to search within. | 
					
						
							|  |  |  |  * \param start: The string we look for at the start. | 
					
						
							|  |  |  |  * \return If str starts with start. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2020-02-12 12:48:44 +01:00
										 |  |  | bool BLI_str_startswith(const char *__restrict str, const char *__restrict start) ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Find if a string ends with another string. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param str: The string to search within. | 
					
						
							|  |  |  |  * \param end: The string we look for at the end. | 
					
						
							|  |  |  |  * \return If str ends with end. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-01-09 23:38:23 +11:00
										 |  |  | bool BLI_str_endswith(const char *__restrict str, const char *__restrict end) ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2015-01-10 19:13:38 +01:00
										 |  |  | bool BLI_strn_endswith(const char *__restrict str, const char *__restrict end, size_t length) | 
					
						
							|  |  |  |     ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Find the first char matching one of the chars in \a delim, from left. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param str: The string to search within. | 
					
						
							|  |  |  |  * \param delim: The set of delimiters to search for, as unicode values. | 
					
						
							|  |  |  |  * \param sep: Return value, set to the first delimiter found (or NULL if none found). | 
					
						
							|  |  |  |  * \param suf: Return value, set to next char after the first delimiter found | 
					
						
							|  |  |  |  * (or NULL if none found). | 
					
						
							|  |  |  |  * \return The length of the prefix (i.e. *sep - str). | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-06-27 11:00:47 +02:00
										 |  |  | size_t BLI_str_partition(const char *str, const char delim[], const char **sep, const char **suf) | 
					
						
							|  |  |  |     ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Find the first char matching one of the chars in \a delim, from right. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param str: The string to search within. | 
					
						
							|  |  |  |  * \param delim: The set of delimiters to search for, as unicode values. | 
					
						
							|  |  |  |  * \param sep: Return value, set to the first delimiter found (or NULL if none found). | 
					
						
							|  |  |  |  * \param suf: Return value, set to next char after the first delimiter found | 
					
						
							|  |  |  |  * (or NULL if none found). | 
					
						
							|  |  |  |  * \return The length of the prefix (i.e. *sep - str). | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-06-27 11:00:47 +02:00
										 |  |  | size_t BLI_str_rpartition(const char *str, const char delim[], const char **sep, const char **suf) | 
					
						
							|  |  |  |     ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Find the first char matching one of the chars in \a delim, either from left or right. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param str: The string to search within. | 
					
						
							|  |  |  |  * \param end: If non-NULL, the right delimiter of the string. | 
					
						
							|  |  |  |  * \param delim: The set of delimiters to search for, as unicode values. | 
					
						
							|  |  |  |  * \param sep: Return value, set to the first delimiter found (or NULL if none found). | 
					
						
							|  |  |  |  * \param suf: Return value, set to next char after the first delimiter found | 
					
						
							|  |  |  |  * (or NULL if none found). | 
					
						
							|  |  |  |  * \param from_right: If %true, search from the right of \a str, else, search from its left. | 
					
						
							|  |  |  |  * \return The length of the prefix (i.e. *sep - str). | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-06-27 10:22:29 +02:00
										 |  |  | size_t BLI_str_partition_ex(const char *str, | 
					
						
							| 
									
										
										
										
											2015-06-27 11:00:47 +02:00
										 |  |  |                             const char *end, | 
					
						
							|  |  |  |                             const char delim[], | 
					
						
							|  |  |  |                             const char **sep, | 
					
						
							|  |  |  |                             const char **suf, | 
					
						
							| 
									
										
										
										
											2022-01-07 11:38:08 +11:00
										 |  |  |                             bool from_right) ATTR_NONNULL(1, 3, 4, 5); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-07 11:38:08 +11:00
										 |  |  | int BLI_string_max_possible_word_count(int str_len); | 
					
						
							| 
									
										
										
										
											2020-07-07 10:08:42 +02:00
										 |  |  | bool BLI_string_has_word_prefix(const char *haystack, const char *needle, size_t needle_len); | 
					
						
							|  |  |  | bool BLI_string_all_words_matched(const char *name, | 
					
						
							|  |  |  |                                   const char *str, | 
					
						
							|  |  |  |                                   int (*words)[2], | 
					
						
							| 
									
										
										
										
											2022-01-07 11:38:08 +11:00
										 |  |  |                                   int words_len); | 
					
						
							| 
									
										
										
										
											2020-07-07 10:08:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 20:01:44 +11:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Find the ranges needed to split \a str into its individual words. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param str: The string to search for words. | 
					
						
							|  |  |  |  * \param len: Size of the string to search. | 
					
						
							|  |  |  |  * \param delim: Character to use as a delimiter. | 
					
						
							|  |  |  |  * \param r_words: Info about the words found. Set to [index, len] pairs. | 
					
						
							|  |  |  |  * \param words_max: Max number of words to find | 
					
						
							|  |  |  |  * \return The number of words found in \a str | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2016-03-23 18:45:32 +11:00
										 |  |  | int BLI_string_find_split_words(const char *str, | 
					
						
							| 
									
										
										
										
											2022-01-12 12:49:36 +01:00
										 |  |  |                                 size_t len, | 
					
						
							| 
									
										
										
										
											2022-01-07 11:38:08 +11:00
										 |  |  |                                 char delim, | 
					
						
							| 
									
										
										
										
											2016-03-23 18:45:32 +11:00
										 |  |  |                                 int r_words[][2], | 
					
						
							|  |  |  |                                 int words_max) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-10 09:24:40 +02:00
										 |  |  | /* -------------------------------------------------------------------- */ | 
					
						
							| 
									
										
										
										
											2018-04-05 16:44:48 +02:00
										 |  |  | /** \name String Copy/Format Macros
 | 
					
						
							|  |  |  |  * Avoid repeating destination with `sizeof(..)`. | 
					
						
							|  |  |  |  * \note `ARRAY_SIZE` allows pointers on some platforms. | 
					
						
							|  |  |  |  * \{ */ | 
					
						
							| 
									
										
										
										
											2021-12-14 15:49:31 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 16:44:48 +02:00
										 |  |  | #define STRNCPY(dst, src) BLI_strncpy(dst, src, ARRAY_SIZE(dst))
 | 
					
						
							|  |  |  | #define STRNCPY_RLEN(dst, src) BLI_strncpy_rlen(dst, src, ARRAY_SIZE(dst))
 | 
					
						
							|  |  |  | #define SNPRINTF(dst, format, ...) BLI_snprintf(dst, ARRAY_SIZE(dst), format, __VA_ARGS__)
 | 
					
						
							|  |  |  | #define SNPRINTF_RLEN(dst, format, ...) \
 | 
					
						
							|  |  |  |   BLI_snprintf_rlen(dst, ARRAY_SIZE(dst), format, __VA_ARGS__) | 
					
						
							| 
									
										
										
										
											2019-03-07 12:01:32 +01:00
										 |  |  | #define STR_CONCAT(dst, len, suffix) \
 | 
					
						
							|  |  |  |   len += BLI_strncpy_rlen(dst + len, suffix, ARRAY_SIZE(dst) - len) | 
					
						
							|  |  |  | #define STR_CONCATF(dst, len, format, ...) \
 | 
					
						
							|  |  |  |   len += BLI_snprintf_rlen(dst + len, ARRAY_SIZE(dst) - len, format, __VA_ARGS__) | 
					
						
							| 
									
										
										
										
											2021-12-14 15:49:31 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 16:44:48 +02:00
										 |  |  | /** \} */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-10 09:24:40 +02:00
										 |  |  | /* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /** \name Equal to Any Element (STR_ELEM) Macro
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Follows #ELEM macro convention. | 
					
						
							|  |  |  |  * \{ */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-20 13:02:20 +02:00
										 |  |  | /* Manual line breaks for readability. */ | 
					
						
							|  |  |  | /* clang-format off */ | 
					
						
							| 
									
										
										
										
											2019-04-10 09:24:40 +02:00
										 |  |  | /* STR_ELEM#(v, ...): is the first arg equal any others? */ | 
					
						
							|  |  |  | /* Internal helpers. */ | 
					
						
							|  |  |  | #define _VA_STR_ELEM2(v, a) (strcmp(v, a) == 0)
 | 
					
						
							| 
									
										
										
										
											2019-04-20 13:02:20 +02:00
										 |  |  | #define _VA_STR_ELEM3(v, a, b) \
 | 
					
						
							|  |  |  |   (_VA_STR_ELEM2(v, a) || (_VA_STR_ELEM2(v, b))) | 
					
						
							|  |  |  | #define _VA_STR_ELEM4(v, a, b, c) \
 | 
					
						
							|  |  |  |   (_VA_STR_ELEM3(v, a, b) || (_VA_STR_ELEM2(v, c))) | 
					
						
							|  |  |  | #define _VA_STR_ELEM5(v, a, b, c, d) \
 | 
					
						
							|  |  |  |   (_VA_STR_ELEM4(v, a, b, c) || (_VA_STR_ELEM2(v, d))) | 
					
						
							|  |  |  | #define _VA_STR_ELEM6(v, a, b, c, d, e) \
 | 
					
						
							|  |  |  |   (_VA_STR_ELEM5(v, a, b, c, d) || (_VA_STR_ELEM2(v, e))) | 
					
						
							|  |  |  | #define _VA_STR_ELEM7(v, a, b, c, d, e, f) \
 | 
					
						
							|  |  |  |   (_VA_STR_ELEM6(v, a, b, c, d, e) || (_VA_STR_ELEM2(v, f))) | 
					
						
							| 
									
										
										
										
											2019-04-19 14:49:57 +02:00
										 |  |  | #define _VA_STR_ELEM8(v, a, b, c, d, e, f, g) \
 | 
					
						
							| 
									
										
										
										
											2019-04-20 13:02:20 +02:00
										 |  |  |   (_VA_STR_ELEM7(v, a, b, c, d, e, f) || (_VA_STR_ELEM2(v, g))) | 
					
						
							| 
									
										
										
										
											2019-04-10 09:24:40 +02:00
										 |  |  | #define _VA_STR_ELEM9(v, a, b, c, d, e, f, g, h) \
 | 
					
						
							| 
									
										
										
										
											2019-04-20 13:02:20 +02:00
										 |  |  |   (_VA_STR_ELEM8(v, a, b, c, d, e, f, g) || (_VA_STR_ELEM2(v, h))) | 
					
						
							| 
									
										
										
										
											2019-04-10 09:24:40 +02:00
										 |  |  | #define _VA_STR_ELEM10(v, a, b, c, d, e, f, g, h, i) \
 | 
					
						
							| 
									
										
										
										
											2019-04-20 13:02:20 +02:00
										 |  |  |   (_VA_STR_ELEM9(v, a, b, c, d, e, f, g, h) || (_VA_STR_ELEM2(v, i))) | 
					
						
							| 
									
										
										
										
											2019-04-10 09:24:40 +02:00
										 |  |  | #define _VA_STR_ELEM11(v, a, b, c, d, e, f, g, h, i, j) \
 | 
					
						
							| 
									
										
										
										
											2019-04-20 13:02:20 +02:00
										 |  |  |   (_VA_STR_ELEM10(v, a, b, c, d, e, f, g, h, i) || (_VA_STR_ELEM2(v, j))) | 
					
						
							| 
									
										
										
										
											2019-04-10 09:24:40 +02:00
										 |  |  | #define _VA_STR_ELEM12(v, a, b, c, d, e, f, g, h, i, j, k) \
 | 
					
						
							| 
									
										
										
										
											2019-04-20 13:02:20 +02:00
										 |  |  |   (_VA_STR_ELEM11(v, a, b, c, d, e, f, g, h, i, j) || (_VA_STR_ELEM2(v, k))) | 
					
						
							| 
									
										
										
										
											2019-04-10 09:24:40 +02:00
										 |  |  | #define _VA_STR_ELEM13(v, a, b, c, d, e, f, g, h, i, j, k, l) \
 | 
					
						
							| 
									
										
										
										
											2019-04-20 13:02:20 +02:00
										 |  |  |   (_VA_STR_ELEM12(v, a, b, c, d, e, f, g, h, i, j, k) || (_VA_STR_ELEM2(v, l))) | 
					
						
							| 
									
										
										
										
											2019-04-10 09:24:40 +02:00
										 |  |  | #define _VA_STR_ELEM14(v, a, b, c, d, e, f, g, h, i, j, k, l, m) \
 | 
					
						
							| 
									
										
										
										
											2019-04-20 13:02:20 +02:00
										 |  |  |   (_VA_STR_ELEM13(v, a, b, c, d, e, f, g, h, i, j, k, l) || (_VA_STR_ELEM2(v, m))) | 
					
						
							| 
									
										
										
										
											2019-04-10 09:24:40 +02:00
										 |  |  | #define _VA_STR_ELEM15(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n) \
 | 
					
						
							| 
									
										
										
										
											2019-04-20 13:02:20 +02:00
										 |  |  |   (_VA_STR_ELEM14(v, a, b, c, d, e, f, g, h, i, j, k, l, m) || (_VA_STR_ELEM2(v, n))) | 
					
						
							| 
									
										
										
										
											2019-04-10 09:24:40 +02:00
										 |  |  | #define _VA_STR_ELEM16(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) \
 | 
					
						
							| 
									
										
										
										
											2019-04-20 13:02:20 +02:00
										 |  |  |   (_VA_STR_ELEM15(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n) || (_VA_STR_ELEM2(v, o))) | 
					
						
							| 
									
										
										
										
											2019-04-10 09:24:40 +02:00
										 |  |  | #define _VA_STR_ELEM17(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \
 | 
					
						
							| 
									
										
										
										
											2019-04-20 13:02:20 +02:00
										 |  |  |   (_VA_STR_ELEM16(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) || (_VA_STR_ELEM2(v, p))) | 
					
						
							|  |  |  | /* clang-format on */ | 
					
						
							| 
									
										
										
										
											2019-04-10 09:24:40 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* reusable STR_ELEM macro */ | 
					
						
							|  |  |  | #define STR_ELEM(...) VA_NARGS_CALL_OVERLOAD(_VA_STR_ELEM, __VA_ARGS__)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** \} */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-20 10:02:00 +00:00
										 |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 |