80 ## Comparison |
80 ## Comparison |
81 |
81 |
82 ```C |
82 ```C |
83 #include <cx/string.h> |
83 #include <cx/string.h> |
84 |
84 |
85 int cx_strcmp(cxstring s1, cxstring s2); |
85 int cx_strcmp(AnyStr s1, AnyStr s2); |
86 |
86 |
87 int cx_strcmp_p(const void *s1, const void *s2); |
87 int cx_strcmp_p(const void *s1, const void *s2); |
88 |
88 |
89 bool cx_strprefix(cxstring string, cxstring prefix); |
|
90 |
|
91 bool cx_strsuffix(cxstring string, cxstring suffix); |
|
92 |
|
93 int cx_strcasecmp(cxstring s1, cxstring s2); |
|
94 |
|
95 int cx_strcasecmp_p(const void *s1, const void *s2); |
89 int cx_strcasecmp_p(const void *s1, const void *s2); |
96 |
90 |
97 bool cx_strcaseprefix(cxstring string, cxstring prefix); |
91 bool cx_strprefix(AnyStr string, AnyStr prefix); |
98 |
92 |
99 bool cx_strcasesuffix(cxstring string, cxstring suffix); |
93 bool cx_strsuffix(AnyStr string, AnyStr suffix); |
100 ``` |
94 |
101 |
95 int cx_strcasecmp(AnyStr s1, AnyStr s2); |
102 The `cx_strcmp()` function compares two UCX strings lexicographically |
96 |
|
97 bool cx_strcaseprefix(AnyStr string, AnyStr prefix); |
|
98 |
|
99 bool cx_strcasesuffix(AnyStr string, AnyStr suffix); |
|
100 ``` |
|
101 |
|
102 The `cx_strcmp()` function compares two strings lexicographically |
103 and returns an integer greater than, equal to, or less than 0, if `s1` is greater than, equal to, or less than `s2`, respectively. |
103 and returns an integer greater than, equal to, or less than 0, if `s1` is greater than, equal to, or less than `s2`, respectively. |
104 The `cx_strcmp_p()` function is equivalent, except that it takes pointers to the UCX strings and the signature is compatible with `cx_compare_func`. |
104 |
|
105 The `cx_strcmp_p()` function takes pointers to UCX strings (i.e., only to `cxstring` and `cxmutstr`) and the signature is compatible with `cx_compare_func`. |
|
106 Use this as a compare function for lists or other data structures. |
105 |
107 |
106 The functions `cx_strprefix()` and `cx_strsuffic()` check if `string` starts with `prefix` or ends with `suffix`, respectively. |
108 The functions `cx_strprefix()` and `cx_strsuffic()` check if `string` starts with `prefix` or ends with `suffix`, respectively. |
107 |
109 |
108 The functions `cx_strcasecmp()`, `cx_strcasecmp_p()`, `cx_strcaseprefix()`, and `cx_strcasesuffix()` are equivalent, |
110 The functions `cx_strcasecmp()`, `cx_strcasecmp_p()`, `cx_strcaseprefix()`, and `cx_strcasesuffix()` are equivalent, |
109 except that they compare the strings case-insensitive. |
111 except that they compare the strings case-insensitive. |