src/ucx/string.h

changeset 378
952c2df7e7ac
parent 364
5577d6c27a33
equal deleted inserted replaced
377:2099a3aff61e 378:952c2df7e7ac
1070 * @param string the input string 1070 * @param string the input string
1071 * @return the resulting upper case string 1071 * @return the resulting upper case string
1072 */ 1072 */
1073 #define sstrupper_a(allocator, string) scstrupper_a(allocator, string) 1073 #define sstrupper_a(allocator, string) scstrupper_a(allocator, string)
1074 1074
1075
1076 /**
1077 * Replaces a pattern in a string with another string.
1078 *
1079 * The pattern is taken literally and is no regular expression.
1080 * Replaces at most <code>replmax</code> occurrences.
1081 *
1082 * The resulting string is allocated by the specified allocator. I.e. it
1083 * depends on the used allocator, whether the sstr_t.ptr must be freed
1084 * manually.
1085 *
1086 * If allocation fails, the sstr_t.ptr of the return value is NULL.
1087 *
1088 * @param allocator the allocator to use
1089 * @param str the string where replacements should be applied
1090 * @param pattern the pattern to search for
1091 * @param replacement the replacement string
1092 * @param replmax maximum number of replacements
1093 * @return the resulting string after applying the replacements
1094 */
1095 sstr_t scstrreplacen_a(UcxAllocator *allocator, scstr_t str,
1096 scstr_t pattern, scstr_t replacement, size_t replmax);
1097
1098 /**
1099 * Replaces a pattern in a string with another string.
1100 *
1101 * The pattern is taken literally and is no regular expression.
1102 * Replaces at most <code>replmax</code> occurrences.
1103 *
1104 * The sstr_t.ptr of the resulting string must be freed manually.
1105 *
1106 * If allocation fails, the sstr_t.ptr of the return value is NULL.
1107 *
1108 * @param str the string where replacements should be applied
1109 * @param pattern the pattern to search for
1110 * @param replacement the replacement string
1111 * @param replmax maximum number of replacements
1112 * @return the resulting string after applying the replacements
1113 */
1114 sstr_t scstrreplacen(scstr_t str, scstr_t pattern,
1115 scstr_t replacement, size_t replmax);
1116
1117 /**
1118 * Replaces a pattern in a string with another string.
1119 *
1120 * The pattern is taken literally and is no regular expression.
1121 * Replaces at most <code>replmax</code> occurrences.
1122 *
1123 * The resulting string is allocated by the specified allocator. I.e. it
1124 * depends on the used allocator, whether the sstr_t.ptr must be freed
1125 * manually.
1126 *
1127 * @param allocator the allocator to use
1128 * @param str the string where replacements should be applied
1129 * @param pattern the pattern to search for
1130 * @param replacement the replacement string
1131 * @param replmax maximum number of replacements
1132 * @return the resulting string after applying the replacements
1133 */
1134 #define sstrreplacen_a(allocator, str, pattern, replacement, replmax) \
1135 scstrreplacen_a(allocator, SCSTR(str), SCSTR(pattern), \
1136 SCSTR(replacement), replmax)
1137
1138 /**
1139 * Replaces a pattern in a string with another string.
1140 *
1141 * The pattern is taken literally and is no regular expression.
1142 * Replaces at most <code>replmax</code> occurrences.
1143 *
1144 * The sstr_t.ptr of the resulting string must be freed manually.
1145 *
1146 * If allocation fails, the sstr_t.ptr of the return value is NULL.
1147 *
1148 * @param str the string where replacements should be applied
1149 * @param pattern the pattern to search for
1150 * @param replacement the replacement string
1151 * @param replmax maximum number of replacements
1152 * @return the resulting string after applying the replacements
1153 */
1154 #define sstrreplacen(str, pattern, replacement, replmax) \
1155 scstrreplacen(SCSTR(str), SCSTR(pattern), SCSTR(replacement), replmax)
1156
1157 /**
1158 * Replaces a pattern in a string with another string.
1159 *
1160 * The pattern is taken literally and is no regular expression.
1161 * Replaces at most <code>replmax</code> occurrences.
1162 *
1163 * The resulting string is allocated by the specified allocator. I.e. it
1164 * depends on the used allocator, whether the sstr_t.ptr must be freed
1165 * manually.
1166 *
1167 * If allocation fails, the sstr_t.ptr of the return value is NULL.
1168 *
1169 * @param allocator the allocator to use
1170 * @param str the string where replacements should be applied
1171 * @param pattern the pattern to search for
1172 * @param replacement the replacement string
1173 * @return the resulting string after applying the replacements
1174 */
1175 #define sstrreplace_a(allocator, str, pattern, replacement) \
1176 scstrreplacen_a(allocator, SCSTR(str), SCSTR(pattern), \
1177 SCSTR(replacement), SIZE_MAX)
1178
1179 /**
1180 * Replaces a pattern in a string with another string.
1181 *
1182 * The pattern is taken literally and is no regular expression.
1183 * Replaces at most <code>replmax</code> occurrences.
1184 *
1185 * The sstr_t.ptr of the resulting string must be freed manually.
1186 *
1187 * If allocation fails, the sstr_t.ptr of the return value is NULL.
1188 *
1189 * @param str the string where replacements should be applied
1190 * @param pattern the pattern to search for
1191 * @param replacement the replacement string
1192 * @return the resulting string after applying the replacements
1193 */
1194 #define sstrreplace(str, pattern, replacement) \
1195 scstrreplacen(SCSTR(str), SCSTR(pattern), SCSTR(replacement), SIZE_MAX)
1196
1075 #ifdef __cplusplus 1197 #ifdef __cplusplus
1076 } 1198 }
1077 #endif 1199 #endif
1078 1200
1079 #endif /* UCX_STRING_H */ 1201 #endif /* UCX_STRING_H */

mercurial