| 
									
										
										
										
											2017-01-16 17:33:34 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  |  * of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							|  |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2017 by the Blender Foundation. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef __BLI_STRING_UTILS_H__
 | 
					
						
							|  |  |  | #define __BLI_STRING_UTILS_H__
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-18 08:08:12 +11:00
										 |  |  | /** \file
 | 
					
						
							|  |  |  |  * \ingroup bli | 
					
						
							| 
									
										
										
										
											2017-01-16 17:33:34 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <stdarg.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "BLI_compiler_attrs.h"
 | 
					
						
							| 
									
										
										
										
											2017-09-19 20:16:05 +10:00
										 |  |  | #include "BLI_utildefines_variadic.h"
 | 
					
						
							| 
									
										
										
										
											2017-01-16 17:33:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | struct ListBase; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef bool (*UniquenameCheckCallback)(void *arg, const char *name); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-20 12:21:04 +01:00
										 |  |  | size_t BLI_split_name_num(char *left, int *nr, const char *name, const char delim); | 
					
						
							| 
									
										
										
										
											2017-01-16 17:33:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-16 20:34:13 +01:00
										 |  |  | void BLI_string_split_suffix(const char *string, char *r_body, char *r_suf, const size_t str_len); | 
					
						
							|  |  |  | void BLI_string_split_prefix(const char *string, char *r_pre, char *r_body, const size_t str_len); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-23 18:16:46 +10:00
										 |  |  | /* Join strings, return newly allocated string. */ | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | char *BLI_string_join_arrayN(const char *strings[], uint strings_len) ATTR_WARN_UNUSED_RESULT | 
					
						
							|  |  |  |     ATTR_NONNULL(); | 
					
						
							|  |  |  | char *BLI_string_join_array_by_sep_charN(char sep, | 
					
						
							|  |  |  |                                          const char *strings[], | 
					
						
							|  |  |  |                                          uint strings_len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); | 
					
						
							|  |  |  | char *BLI_string_join_array_by_sep_char_with_tableN(char sep, | 
					
						
							|  |  |  |                                                     char *table[], | 
					
						
							|  |  |  |                                                     const char *strings[], | 
					
						
							|  |  |  |                                                     uint strings_len) ATTR_NONNULL(); | 
					
						
							| 
									
										
										
										
											2017-08-23 18:16:46 +10:00
										 |  |  | /* Take multiple arguments, pass as (array, length). */ | 
					
						
							|  |  |  | #define BLI_string_joinN(...) \
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   BLI_string_join_arrayN(((const char *[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__)) | 
					
						
							| 
									
										
										
										
											2017-08-23 18:16:46 +10:00
										 |  |  | #define BLI_string_join_by_sep_charN(sep, ...) \
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   BLI_string_join_array_by_sep_charN( \ | 
					
						
							|  |  |  |       sep, ((const char *[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__)) | 
					
						
							| 
									
										
										
										
											2017-08-23 18:16:46 +10:00
										 |  |  | #define BLI_string_join_by_sep_char_with_tableN(sep, table, ...) \
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   BLI_string_join_array_by_sep_char_with_tableN( \ | 
					
						
							|  |  |  |       sep, table, ((const char *[]){__VA_ARGS__}), VA_NARGS_COUNT(__VA_ARGS__)) | 
					
						
							| 
									
										
										
										
											2017-08-23 18:16:46 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | void BLI_string_flip_side_name(char *r_name, | 
					
						
							|  |  |  |                                const char *from_name, | 
					
						
							|  |  |  |                                const bool strip_number, | 
					
						
							|  |  |  |                                const size_t name_len); | 
					
						
							| 
									
										
										
										
											2017-01-16 20:34:13 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | bool BLI_uniquename_cb(UniquenameCheckCallback unique_check, | 
					
						
							|  |  |  |                        void *arg, | 
					
						
							|  |  |  |                        const char *defname, | 
					
						
							|  |  |  |                        char delim, | 
					
						
							|  |  |  |                        char *name, | 
					
						
							|  |  |  |                        size_t name_len); | 
					
						
							|  |  |  | bool BLI_uniquename(struct ListBase *list, | 
					
						
							|  |  |  |                     void *vlink, | 
					
						
							|  |  |  |                     const char *defname, | 
					
						
							|  |  |  |                     char delim, | 
					
						
							|  |  |  |                     int name_offs, | 
					
						
							|  |  |  |                     size_t len); | 
					
						
							| 
									
										
										
										
											2017-01-16 17:33:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | #endif /* __BLI_STRING_UTILS_H__ */
 |