21#define FURI_STRING_FAILURE ((size_t) - 1)
66 _ATTRIBUTE((__format__(__printf__, 1, 2)));
242 _ATTRIBUTE((__format__(__printf__, 2, 3)));
292 _ATTRIBUTE((__format__(__printf__, 2, 3)));
460 const
char replace[],
599 FuriStringUTF8StateStarting,
600 FuriStringUTF8StateDecoding1,
601 FuriStringUTF8StateDecoding2,
602 FuriStringUTF8StateDecoding3,
603 FuriStringUTF8StateError
631#define FURI_STRING_SELECT1(func1, func2, a) \
632 _Generic((a), char*: func2, const char*: func2, FuriString*: func1, const FuriString*: func1)( \
636#define FURI_STRING_SELECT2(func1, func2, a, b) \
637 _Generic((b), char*: func2, const char*: func2, FuriString*: func1, const FuriString*: func1)( \
641#define FURI_STRING_SELECT3(func1, func2, a, b, c) \
642 _Generic((b), char*: func2, const char*: func2, FuriString*: func1, const FuriString*: func1)( \
646#define FURI_STRING_SELECT4(func1, func2, a, b, c, d) \
647 _Generic((b), char*: func2, const char*: func2, FuriString*: func1, const FuriString*: func1)( \
654#define furi_string_alloc_set(a) \
655 FURI_STRING_SELECT1(furi_string_alloc_set, furi_string_alloc_set_str, a)
661#define furi_string_set(a, b) FURI_STRING_SELECT2(furi_string_set, furi_string_set_str, a, b)
668#define furi_string_cmp(a, b) FURI_STRING_SELECT2(furi_string_cmp, furi_string_cmp_str, a, b)
675#define furi_string_cmpi(a, b) FURI_STRING_SELECT2(furi_string_cmpi, furi_string_cmpi_str, a, b)
681#define furi_string_equal(a, b) FURI_STRING_SELECT2(furi_string_equal, furi_string_equal_str, a, b)
687#define furi_string_replace_all(a, b, c) \
688 FURI_STRING_SELECT3(furi_string_replace_all, furi_string_replace_all_str, a, b, c)
694#define furi_string_search(...) \
696 FURI_STRING_SELECT3, \
697 furi_string_search, \
698 furi_string_search_str, \
699 M_DEFAULT_ARGS(3, (0), __VA_ARGS__))
704#define furi_string_search_str(...) furi_string_search_str(M_DEFAULT_ARGS(3, (0), __VA_ARGS__))
710#define furi_string_start_with(a, b) \
711 FURI_STRING_SELECT2(furi_string_start_with, furi_string_start_with_str, a, b)
717#define furi_string_end_with(a, b) \
718 FURI_STRING_SELECT2(furi_string_end_with, furi_string_end_with_str, a, b)
724#define furi_string_end_withi(a, b) \
725 FURI_STRING_SELECT2(furi_string_end_withi, furi_string_end_withi_str, a, b)
731#define furi_string_cat(a, b) FURI_STRING_SELECT2(furi_string_cat, furi_string_cat_str, a, b)
737#define furi_string_trim(...) furi_string_trim(M_DEFAULT_ARGS(2, (" \n\r\t"), __VA_ARGS__))
743#define furi_string_search_char(...) furi_string_search_char(M_DEFAULT_ARGS(3, (0), __VA_ARGS__))
749#define furi_string_search_rchar(...) furi_string_search_rchar(M_DEFAULT_ARGS(3, (0), __VA_ARGS__))
755#define furi_string_replace(...) \
757 FURI_STRING_SELECT4, \
758 furi_string_replace, \
759 furi_string_replace_str, \
760 M_DEFAULT_ARGS(4, (0), __VA_ARGS__))
766#define furi_string_replace_str(...) furi_string_replace_str(M_DEFAULT_ARGS(4, (0), __VA_ARGS__))
769#define F_STR_INIT(a) ((a) = furi_string_alloc())
772#define F_STR_INIT_SET(a, b) ((a) = furi_string_alloc_set(b))
775#define F_STR_INIT_MOVE(a, b) ((a) = furi_string_alloc_move(b))
778#define FURI_STRING_OPLIST \
780 INIT_SET(F_STR_INIT_SET), \
781 SET(furi_string_set), \
782 INIT_MOVE(F_STR_INIT_MOVE), \
783 MOVE(furi_string_move), \
784 SWAP(furi_string_swap), \
785 RESET(furi_string_reset), \
786 EMPTY_P(furi_string_empty), \
787 CLEAR(furi_string_free), \
788 HASH(furi_string_hash), \
789 EQUAL(furi_string_equal), \
790 CMP(furi_string_cmp), \
#define furi_string_set(a, b)
Set the string content to string (or C string).
Definition string.h:661
FuriString FuriString * furi_string_alloc_vprintf(const char format[], va_list args)
Allocate new FuriString and printf to it.
Definition string.c:52
char furi_string_get_char(const FuriString *string, size_t index)
Get the character at the given index.
Definition string.c:93
bool furi_string_end_withi_str(const FuriString *string, const char end[])
Test if the string ends with the given C string (case insensitive according to the current locale).
Definition string.c:230
void furi_string_replace_all_str(FuriString *string, const char needle[], const char replace[])
Replace all occurrences of 'needle' C string into 'replace' C string.
Definition string.c:202
#define furi_string_cmp(a, b)
Compare string with string (or C string) and return the sort order.
Definition string.h:668
void furi_string_push_back(FuriString *string, char c)
Append a character to the string.
Definition string.c:149
#define furi_string_end_withi(a, b)
Test if the string ends with the given string (or C string) (case insensitive according to the curren...
Definition string.h:724
bool furi_string_equal_str(const FuriString *string_1, const char cstring_2[])
Test if the string is equal to the C string.
Definition string.c:145
bool furi_string_end_with_str(const FuriString *string, const char end[])
Test if the string ends with the given C string.
Definition string.c:226
void furi_string_cat_str(FuriString *string_1, const char cstring_2[])
Append a C string to the string.
Definition string.c:272
size_t furi_string_size(const FuriString *string)
Get string size (usually length, but not for UTF-8)
Definition string.c:153
#define furi_string_search(...)
Search for a string (or C string) in a string.
Definition string.h:694
void furi_string_swap(FuriString *string_1, FuriString *string_2)
Swap two strings.
Definition string.c:79
void furi_string_free(FuriString *string)
Free FuriString.
Definition string.c:65
void furi_string_right(FuriString *string, size_t index)
Trim the string right from the 'index' position to the last position.
Definition string.c:256
void furi_string_set_str(FuriString *string, const char source[])
Set the string to the other C string.
Definition string.c:105
void furi_string_set_n(FuriString *string, const FuriString *source, size_t offset, size_t length)
Set the string to the n first characters of other one.
Definition string.c:276
#define furi_string_cat(a, b)
Append a string (or C string) to the string.
Definition string.h:731
FuriString * furi_string_alloc_set_str(const char cstr_source[])
Allocate new FuriString and set it to C string.
Definition string.c:38
#define furi_string_search_char(...)
Search for a character in a string.
Definition string.h:743
FuriStringUTF8State
State of the UTF8 decoding machine state.
Definition string.h:598
#define furi_string_trim(...)
Trim a string from the given set of characters (default is " \n\r\t").
Definition string.h:737
int int furi_string_vprintf(FuriString *string, const char format[], va_list args)
Format in the string the given printf format.
Definition string.c:165
const char * furi_string_get_cstr(const FuriString *string)
Return the string view a classic C string.
Definition string.c:97
bool furi_string_empty(const FuriString *string)
Check that string is empty or not.
Definition string.c:185
unsigned int FuriStringUnicodeValue
An unicode value.
Definition string.h:580
#define furi_string_search_str(...)
Search for a C string in a string.
Definition string.h:704
int furi_string_cmp_str(const FuriString *string_1, const char cstring_2[])
Compare string with C string and return the sort order.
Definition string.c:121
FuriString * furi_string_alloc_printf(const char format[],...) _ATTRIBUTE((__format__(__printf__
Allocate new FuriString and printf to it.
void furi_string_utf8_decode(char c, FuriStringUTF8State *state, FuriStringUnicodeValue *unicode)
Main generic UTF8 decoder.
Definition string.c:318
int furi_string_cat_printf(FuriString *string, const char format[],...) _ATTRIBUTE((__format__(__printf__
Append to the string the formatted string of the given printf format.
#define furi_string_replace_all(a, b, c)
Replace all occurrences of string into string (or C string to another C string) in a string.
Definition string.h:687
void furi_string_move(FuriString *destination, FuriString *source)
Move string_2 content to string_1.
Definition string.c:83
void furi_string_reset(FuriString *string)
Reset string.
Definition string.c:74
int int furi_string_cat_vprintf(FuriString *string, const char format[], va_list args)
Append to the string the formatted string of the given printf format.
Definition string.c:177
#define furi_string_search_rchar(...)
Reverse Search for a character in a string.
Definition string.h:749
#define furi_string_alloc_set(a)
Allocate new FuriString and set it content to string (or C string).
Definition string.h:654
size_t furi_string_utf8_length(FuriString *string)
Compute the length in UTF8 characters in the string.
Definition string.c:280
FuriString * furi_string_alloc(void)
Allocate new FuriString.
Definition string.c:26
int furi_string_cmpi_str(const FuriString *string_1, const char cstring_2[])
Compare string with C string (case insensitive according to the current locale) and return the sort o...
Definition string.c:129
#define furi_string_end_with(a, b)
Test if the string ends with the given string (or C string).
Definition string.h:717
int furi_string_printf(FuriString *string, const char format[],...) _ATTRIBUTE((__format__(__printf__
Format in the string the given printf format.
#define furi_string_start_with(a, b)
Test if the string starts with the given string (or C string).
Definition string.h:710
void furi_string_reserve(FuriString *string, size_t size)
Reserve memory for string.
Definition string.c:70
#define furi_string_replace_str(...)
Replace a C string to another C string in a string.
Definition string.h:766
#define furi_string_equal(a, b)
Test if the string is equal to the string (or C string).
Definition string.h:681
void furi_string_left(FuriString *string, size_t index)
Trim the string left to the first 'index' bytes.
Definition string.c:252
void furi_string_mid(FuriString *string, size_t index, size_t size)
Trim the string from position index to size bytes.
Definition string.c:260
void furi_string_replace_at(FuriString *string, size_t pos, size_t len, const char replace[])
Replace in the string the sub-string at position 'pos' for 'len' bytes into the C string 'replace'.
Definition string.c:189
#define furi_string_replace(...)
Replace a string to another string (or C string to another C string) in a string.
Definition string.h:755
void furi_string_set_char(FuriString *string, size_t index, const char c)
Set the character at the given index.
Definition string.c:113
void furi_string_utf8_push(FuriString *string, FuriStringUnicodeValue unicode)
Push unicode into string, encoding it in UTF8.
Definition string.c:284
bool furi_string_start_with_str(const FuriString *string, const char start[])
Test if the string starts with the given C string.
Definition string.c:214
size_t furi_string_hash(const FuriString *string)
Compute a hash for the string.
Definition string.c:89
#define furi_string_cmpi(a, b)
Compare string with string (or C string) (case insensitive according to the current locale) and retur...
Definition string.h:675
void furi_string_set_strn(FuriString *string, const char source[], size_t length)
Set the string to the n first characters of the C string.
Definition string.c:109
FuriString * furi_string_alloc_move(FuriString *source)
Allocate new FuriString and move source string content to it.
Definition string.c:58