36#ifndef __UTILS_STRING_H__
37#define __UTILS_STRING_H__
39#include "ext/juce/juce.h"
63 void insert (
int index,
const char * s)
65 juce::StringArray::insert (index, juce::CharPointer_UTF8 (s));
67 void add (
const char * s)
69 juce::StringArray::add (juce::CharPointer_UTF8 (s));
71 void set (
int index,
const char * s)
73 juce::StringArray::set (index, juce::CharPointer_UTF8 (s));
75 char * getCStr (
int index);
76 const char * operator[] (
size_t i)
78 return juce::StringArray::getReference (i).toRawUTF8 ();
80 void removeString (
const char * s)
82 juce::StringArray::removeString (juce::CharPointer_UTF8 (s));
107string_contains_substr_case_insensitive (
const char * str,
const char * substr);
132#define string_is_equal(str1, str2) (!g_strcmp0 (str1, str2))
175string_replace (
const char * str,
const char * from,
const char * to);
269string_print_strv (
const char * prefix,
char ** strv);
String array that auto-converts given char pointers to UTF8 (so JUCE doesn't complain.
char ** getNullTerminated() const
Returns the strings in a newly-allocated NULL-terminated array.
char * string_get_regex_group(const char *str, const char *regex, int group)
Gets the string in the given regex group.
void string_copy_w_realloc(char **dest, const char *src)
Copies the string src to the buffer in dest after reallocating the buffer in dest to the length of sr...
void string_to_upper(const char *in, char *out)
Converts the given string to uppercase in out.
char * string_symbolify(const char *in)
Returns a new string with only ASCII alphanumeric characters and replaces the rest with underscore.
void string_replace_regex(char **str, const char *regex, const char *replace_str)
Replaces src_str with replace_str in all instances matched by regex.
MALLOC NONNULL char * string_get_substr_before_suffix(const char *str, const char *suffix)
Removes the suffix starting from suffix from full_str and returns a newly allocated string.
char ** string_array_sort_and_remove_duplicates(char **str_arr)
TODO Sorts the given string array and removes duplicates.
bool string_contains_substr(const char *str, const char *substr)
Returns if the given string contains the given substring.
char * string_expand_env_vars(const char *src)
Expands environment variables enclosed in ${} in the given string.
int string_utf8_strcasecmp(const char *s1, const char *s2)
Compares two UTF-8 strings using approximate case-insensitive ordering.
int string_get_regex_group_as_int(const char *str, const char *regex, int group, int def)
Gets the string in the given regex group as an integer.
bool string_is_equal_ignore_case(const char *str1, const char *str2)
Returns if the two strings are equal ignoring case.
int string_get_int_after_last_space(const char *str, char *str_without_num)
Returns the integer found at the end of a string like "My String 3" -> 3, or -1 if no number is found...
char ** string_array_clone(const char **src)
Clones the given string array.
int string_is_ascii(const char *string)
Returns if the string is ASCII.
char * string_remove_until_after_first_match(const char *str, const char *match)
Removes everything up to and including the first match of match from the start of the string and retu...
NONNULL char * string_convert_to_filename(const char *str)
Returns a newly allocated string that is a filename version of the given string.
void string_to_lower(const char *in, char *out)
Converts the given string to lowercase in out.
bool string_is_empty(const char *str)
Returns whether the string is NULL or empty.
char * string_array_contains_substr(char **str_array, int num_str, const char *substr)
Returns the matched string if the string array contains the given substring.